1 #include "./../includes.h" 18 std::vector<float>
td;
30 using C_type = std::function<int(float t)>;
37 : C(C_para), DepartureTimes(dept_para)
41 server_status.assign(mxN, -1);
42 current_customer.assign(mxN, -1);
49 for (
int j = 0; j < std::min(n, c); j++)
53 current_customer[j] = j;
55 for (
int i = std::min(n, c); i <
n; i++)
57 current_queue.push(i);
61 station(
long init_mxN,
C_type C_para,
float init_dept,
float t = 0,
int init_n = 0)
63 DepartureTimes([init_dept](float t) -> float {
return init_dept; })
67 server_status.assign(mxN, -1);
68 current_customer.assign(mxN, -1);
75 for (
int j = 0; j < std::min(n, c); j++)
79 current_customer[j] = j;
81 for (
int i = std::min(n, c); i <
n; i++)
83 current_queue.push(i);
87 station(
long init_mxN,
int init_C,
float init_dept,
float t = 0,
int init_n = 0)
88 : C([init_C](float t) -> int {
return init_C; }),
89 DepartureTimes([init_dept](
float t) ->
float {
return init_dept; })
93 server_status.assign(mxN, -1);
94 current_customer.assign(mxN, -1);
101 for (
int j = 0; j < std::min(n, c); j++)
103 server_status[j] = 1;
105 current_customer[j] = j;
107 for (
int i = std::min(n, c); i <
n; i++)
109 current_queue.push(i);
114 : C([init_C](float t) -> int {
return init_C; }),
119 server_status.assign(mxN, -1);
120 current_customer.assign(mxN, -1);
127 for (
int j = 0; j < std::min(n, c); j++)
129 server_status[j] = 1;
131 current_customer[j] = j;
133 for (
int i = std::min(n, c); i <
n; i++)
135 current_queue.push(i);
148 void logger(
int station_id,
float t);
149 void logger(std::string station_id,
float t);
159 std::vector<float>
read_csv(std::string filename,
int index);
int find_min_k()
Finds the server index which has the minimal departure time.
Definition: station.cpp:11
station(long init_mxN, C_type C_para, event_type dept_para, float t=0, int init_n=0)
Definition: station.h:36
std::vector< int > server_status
Definition: station.h:11
int c
Definition: station.h:19
std::vector< int > current_customer
Definition: station.h:16
std::vector< float > read_csv(std::string filename, int index)
Reads data from a CSV file.
Definition: station.cpp:691
std::queue< int > current_queue
Definition: station.h:17
void print_station_status(float t)
Beautifully outputs station status to the console.
Definition: station.cpp:378
float minimum_residual_time(float t)
Gives the minimum residual time i.e. time left for next departure.
Definition: station.cpp:624
station(long init_mxN, C_type C_para, float init_dept, float t=0, int init_n=0)
Definition: station.h:61
void logger(int station_id, float t)
Beautifully outputs station status a file in folder logs.
Definition: station.cpp:441
std::vector< float > td
Definition: station.h:18
station(long init_mxN, int init_C, event_type init_dept, float t=0, int init_n=0)
Definition: station.h:113
station(long init_mxN, int init_C, float init_dept, float t=0, int init_n=0)
Definition: station.h:87
void server_updates(float t)
Makes server updates.
Definition: station.cpp:58
event_type DepartureTimes
Definition: station.h:33
float find_min_td()
Finds the minimum departure time of all the servers working.
Definition: station.cpp:33
int departure_updates(float t)
Makes departure updates.
Definition: station.cpp:314
C_type C
Definition: station.h:32
void initialize_CSV(std::string file_name)
Definition: station.cpp:633
void add_customer_to_station(float t, int customer_id)
Add a single customer to the front of the system.
Definition: station.cpp:237
int n
Definition: station.h:20
void dump_counter_variable_memory()
Definition: station.cpp:672
void write_to_csv(std::string file_name)
Writes the station::counter_variable to a csv file.
Definition: station.cpp:578
std::function< int(float t)> C_type
Definition: station.h:30
std::tuple< int, int, int > access_system_state(float t)
Definition: station.cpp:629
std::function< float(float t)> event_type
Definition: station.h:31
void reset_queue(float t)
Resets the queue.
Definition: station.cpp:605
std::vector< std::tuple< int, float, int, int, float, float > > counter_variable
Definition: station.h:22
long mxN
Definition: station.h:10
int Na
Definition: station.h:21
std::vector< std::tuple< int, float, int, int, float, float > > get_counter_variable()
Gives back the station::counter_variable.
Definition: station.cpp:273