Skip to content
Snippets Groups Projects
Commit 18d49d6b authored by Francois Hamonic's avatar Francois Hamonic
Browse files

marseille execution time scaling

parent cbf74db4
No related branches found
No related tags found
No related merge requests found
...@@ -117,3 +117,9 @@ target_link_libraries(time_marseille PUBLIC landscape_opt) ...@@ -117,3 +117,9 @@ target_link_libraries(time_marseille PUBLIC landscape_opt)
add_executable(contraction_benefits add_executable(contraction_benefits
exec/execution_times/contraction_benefits.cpp) exec/execution_times/contraction_benefits.cpp)
target_link_libraries(contraction_benefits PUBLIC landscape_opt) target_link_libraries(contraction_benefits PUBLIC landscape_opt)
add_executable(marseille_execution_time_scaling
exec/marseille_execution_time_scaling.cpp)
target_link_libraries(marseille_execution_time_scaling PUBLIC landscape_opt)
This diff is collapsed.
#include <iostream>
#include "solvers/glutton_eca_dec.hpp"
#include "solvers/naive_eca_inc.hpp"
#include "solvers/pl_eca_3.hpp"
#include "instances_helper.hpp"
#include "print_helper.hpp"
int main() {
std::ofstream data_log("output/marseille_execution_time_scaling.csv");
data_log << std::fixed << std::setprecision(6);
data_log << "wastelands "
<< "local_inc "
<< "greedy_dec "
<< "MIP " << std::endl;
std::vector<int> nbs_wastelands;
for(int i = 10; i <= 200; i += 10) nbs_wastelands.push_back(i);
std::vector<int> seeds;
for(int i = 0; i < 10; ++i) seeds.push_back(299 + i);
std::vector<double> budget_percents;
for(int i = 10; i < 90; i += 10) budget_percents.push_back(i);
const int nb_tests = seeds.size() + budget_percents.size();
Solvers::Naive_ECA_Inc naive_eca_inc;
naive_eca_inc.setLogLevel(0).setParallel(true);
Solvers::Glutton_ECA_Dec glutton_eca_dec;
glutton_eca_dec.setLogLevel(0).setParallel(true);
Solvers::PL_ECA_3 pl_eca_3;
pl_eca_3.setLogLevel(0).setTimeout(3600);
for(double nb_wastelands : nbs_wastelands) {
double local_inc_time = 0;
double greedy_dec_time = 0;
double mip_time = 0;
for(double seed : seeds) {
Instance instance =
make_instance_marseille(1, 0.135, 3000, nb_wastelands, seed);
instance.plan.initElementIDs();
const MutableLandscape & landscape = instance.landscape;
const RestorationPlan<MutableLandscape> & plan = instance.plan;
for(double budget_percent : budget_percents) {
const double B = plan.totalCost() * budget_percent / 100;
Solution naive_eca_inc_solution =
naive_eca_inc.solve(landscape, plan, B);
Solution glutton_eca_dec_solution =
glutton_eca_dec.solve(landscape, plan, B);
Solution pl_eca_3_solution = pl_eca_3.solve(landscape, plan, B);
local_inc_time += naive_eca_inc_solution.getComputeTimeMs();
greedy_dec_time += glutton_eca_dec_solution.getComputeTimeMs();
mip_time += pl_eca_3_solution.getComputeTimeMs();
}
}
local_inc_time /= nb_tests;
greedy_dec_time /= nb_tests;
mip_time /= nb_tests;
data_log << nb_wastelands << "," << local_inc_time << ","
<< greedy_dec_time << "," << mip_time << std::endl;
}
return EXIT_SUCCESS;
}
\ No newline at end of file
...@@ -372,7 +372,7 @@ Instance make_instance_biorevaix(const double restoration_coef = 2, ...@@ -372,7 +372,7 @@ Instance make_instance_biorevaix(const double restoration_coef = 2,
} }
Instance make_instance_marseille(double pow, double thresold, double median, Instance make_instance_marseille(double pow, double thresold, double median,
int nb_friches = 100) { int nb_friches = 100, int seed = 9876) {
Instance instance; Instance instance;
MutableLandscape & landscape = instance.landscape; MutableLandscape & landscape = instance.landscape;
...@@ -394,7 +394,7 @@ Instance make_instance_marseille(double pow, double thresold, double median, ...@@ -394,7 +394,7 @@ Instance make_instance_marseille(double pow, double thresold, double median,
double price; double price;
MutableLandscape::Node node; MutableLandscape::Node node;
}; };
RandomChooser<FricheData> friches_chooser(9876); RandomChooser<FricheData> friches_chooser(seed);
std::vector<FricheData> friches_list; std::vector<FricheData> friches_list;
io::CSVReader<5> patches( io::CSVReader<5> patches(
...@@ -451,11 +451,11 @@ Instance make_instance_marseille(double pow, double thresold, double median, ...@@ -451,11 +451,11 @@ Instance make_instance_marseille(double pow, double thresold, double median,
landscape.addArc(u, v, probability); landscape.addArc(u, v, probability);
landscape.addArc(v, u, probability); landscape.addArc(v, u, probability);
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
std::cout << graph.id(u) << "," << graph.id(v) << "," // std::cout << graph.id(u) << "," << graph.id(v) << ","
<< landscape.getCoords(u).x << "," // << landscape.getCoords(u).x << ","
<< landscape.getCoords(u).y << "," // << landscape.getCoords(u).y << ","
<< landscape.getCoords(v).x << "," // << landscape.getCoords(v).x << ","
<< landscape.getCoords(v).y << std::endl; // << landscape.getCoords(v).y << std::endl;
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment