Skip to content

Commit 2823f86

Browse files
committed
Automate parameter search measurements
1 parent 18b8723 commit 2823f86

6 files changed

+48
-16
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bin/
1717
build/
1818
develop-eggs/
1919
dist/
20+
results/
2021
eggs/
2122
lib/
2223
lib64/

apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp

+18-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ int main(int argc, char** argv) {
1717

1818
const std::string model_path = args[1];
1919
const std::string output_path = args[2];
20+
const std::string model_name =
21+
model_path.substr(model_path.find_last_of("/"), model_path.length());
2022

2123
cda_rail::Network network =
2224
cda_rail::Network::import_network(model_path + "/network");
@@ -69,7 +71,10 @@ int main(int argc, char** argv) {
6971
workers.pop_back();
7072
}
7173

72-
score_coll.export_csv(output_path + "/score_hist_" +
74+
auto save_path =
75+
output_path + "/results/genetic_params/crossover/" + model_name;
76+
cda_rail::is_directory_and_create(save_path);
77+
score_coll.export_csv(save_path + "/score_hist_" +
7378
std::to_string(xover_fraction).substr(0, 5) +
7479
".csv");
7580
}
@@ -105,7 +110,10 @@ int main(int argc, char** argv) {
105110
workers.pop_back();
106111
}
107112

108-
score_coll.export_csv(output_path + "/score_hist_" +
113+
auto save_path =
114+
output_path + "/results/genetic_params/mut_rate/" + model_name;
115+
cda_rail::is_directory_and_create(save_path);
116+
score_coll.export_csv(save_path + "/score_hist_" +
109117
std::to_string(mut_rate).substr(0, 5) + ".csv");
110118
}
111119
}
@@ -141,7 +149,10 @@ int main(int argc, char** argv) {
141149
workers.pop_back();
142150
}
143151

144-
score_coll.export_csv(output_path + "/score_hist_" +
152+
auto save_path =
153+
output_path + "/results/genetic_params/pop/" + model_name;
154+
cda_rail::is_directory_and_create(save_path);
155+
score_coll.export_csv(save_path + "/score_hist_" +
145156
std::to_string(pop).substr(0, 5) + ".csv");
146157
}
147158
}
@@ -177,7 +188,10 @@ int main(int argc, char** argv) {
177188
workers.pop_back();
178189
}
179190

180-
score_coll.export_csv(output_path + "/score_hist_" +
191+
auto save_path =
192+
output_path + "/results/genetic_params/elite/" + model_name;
193+
cda_rail::is_directory_and_create(save_path);
194+
score_coll.export_csv(save_path + "/score_hist_" +
181195
std::to_string(elite).substr(0, 5) + ".csv");
182196
}
183197
}

apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ int main(int argc, char** argv) {
1717

1818
const std::string model_path = args[1];
1919
const std::string output_path = args[2];
20+
const std::string model_name =
21+
model_path.substr(model_path.find_last_of("/"), model_path.length());
2022

2123
cda_rail::Network network =
2224
cda_rail::Network::import_network(model_path + "/network");
@@ -29,7 +31,7 @@ int main(int argc, char** argv) {
2931
if (processor_count == 0)
3032
processor_count = 1;
3133

32-
std::vector<size_t> test_timeouts = {5, 10, 50, 100, 250, 500};
34+
std::vector<size_t> test_timeouts = {1, 2, 5, 10, 50, 100, 250};
3335

3436
for (size_t train_to : test_timeouts) {
3537
cda_rail::sim::ScoreHistoryCollection score_coll;
@@ -59,7 +61,10 @@ int main(int argc, char** argv) {
5961
workers.pop_back();
6062
}
6163

62-
score_coll.export_csv(output_path + "/score_hist_" +
64+
auto save_path =
65+
output_path + "/results/greedy_params/stall_time/" + model_name;
66+
cda_rail::is_directory_and_create(save_path);
67+
score_coll.export_csv(save_path + "/score_hist_" +
6368
std::to_string(train_to).substr(0, 5) + ".csv");
6469
}
6570
}

apps/vss_generation_timetable_simulator_local_parameter_testing.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ int main(int argc, char** argv) {
1717

1818
const std::string model_path = args[1];
1919
const std::string output_path = args[2];
20+
const std::string model_name =
21+
model_path.substr(model_path.find_last_of("/"), model_path.length());
2022

2123
cda_rail::Network network =
2224
cda_rail::Network::import_network(model_path + "/network");
@@ -60,8 +62,10 @@ int main(int argc, char** argv) {
6062
workers.pop_back();
6163
}
6264

65+
auto save_path = output_path + "/results/local_params/multi/" + model_name;
66+
cda_rail::is_directory_and_create(save_path);
6367
score_coll.export_csv(
64-
output_path + "/score_hist_" +
68+
save_path + "/score_hist_" +
6569
std::to_string(std::get<0>(param)).substr(0, 5) + "-" +
6670
std::to_string(std::get<1>(param)).substr(0, 5) + "-" +
6771
std::to_string((std::get<2>(param))).substr(0, 5) + ".csv");

apps/vss_generation_timetable_simulator_search_methods_testing.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int main(int argc, char** argv) {
4949
};
5050

5151
std::vector<std::string> methods = {"random", "random+local", "greedy",
52-
"grasp", "genetic"};
52+
"grasp"};
5353

5454
for (std::string method : methods) {
5555
cda_rail::sim::ScoreHistoryCollection score_coll;
@@ -63,9 +63,9 @@ int main(int argc, char** argv) {
6363
int max_samples;
6464
if (method == "random" || method == "greedy" ||
6565
method == "random+local" || method == "grasp")
66-
max_samples = 4;
66+
max_samples = 1;
6767
else
68-
max_samples = 2;
68+
max_samples = 1;
6969

7070
for (size_t sample = 0; sample < max_samples; sample++) {
7171
// Method here
@@ -74,15 +74,15 @@ int main(int argc, char** argv) {
7474
cda_rail::sim::ScoreHistory>
7575
res;
7676
if (method == "random") {
77-
res = solver.random_search(std::chrono::seconds{2500}, {});
77+
res = solver.random_search(std::chrono::seconds{10}, {});
7878
} else if (method == "greedy") {
79-
res = solver.greedy_search(std::chrono::seconds{2500}, {},
79+
res = solver.greedy_search(std::chrono::seconds{10}, {},
8080
{std::chrono::milliseconds{50}});
8181
} else if (method == "random+local") {
82-
res = solver.random_local_search(std::chrono::seconds{2500},
82+
res = solver.random_local_search(std::chrono::seconds{10},
8383
loc_params);
8484
} else if (method == "grasp") {
85-
res = solver.grasp_search(std::chrono::seconds{2500},
85+
res = solver.grasp_search(std::chrono::seconds{10},
8686
{std::chrono::milliseconds{50}},
8787
loc_params);
8888
} else if (method == "genetic") {
@@ -109,8 +109,10 @@ int main(int argc, char** argv) {
109109
workers.pop_back();
110110
}
111111

112-
score_coll.export_csv(output_path + "/" + model_name + "_" + method +
113-
".csv");
112+
cda_rail::is_directory_and_create(output_path + "/results/methods/" +
113+
model_name);
114+
score_coll.export_csv(output_path + "/methods/" + model_name +
115+
"/score_hist_" + method + ".csv");
114116
}
115117
}
116118

dev_scripts/launch_all_measures.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
2+
3+
sh $SCRIPT_DIR/launch_genetic_paramsearch.sh
4+
sh $SCRIPT_DIR/launch_greedy_paramsearch.sh
5+
sh $SCRIPT_DIR/launch_local_paramsearch.sh
6+
sh $SCRIPT_DIR/launch_method_compare_all.sh

0 commit comments

Comments
 (0)