Commit 71cf088e authored by jonasseidel's avatar jonasseidel
Browse files

Group test generation using raster to generate test data (used in...

Group test generation using raster to generate test data (used in maintenance_problem_test_incid_edges.cpp)
parent 47a58f51
Relevant Targets Relevant Targets
=== ===
**make maintenance_problem_test**: creates _Maintenance\_Problem_ (Baustellenproblem) instance by way of first generating an acyclic Graph (here _CircSelectNetwork_) with random edge capacities in [0,5) and lets polymake output facets. **make maintenance_problem_test**: creates _Maintenance\_Problem_ instances by way of first generating an acyclic Graph with random edge capacities in {0, .., 100} and lets polymake output facets or compute solution by using scip. Also opens display_graph with the problems network if available.
**make maintenance_problem_test_incid_edges**: creates raster of _Maintenance\_Problem_ (Baustellenproblem) instances and executes them:
- Instances are generated with varying amount of incidences per node and edges per node.
- The amount of nodes is adjusted as to make the edge/node ratio fit the required incidenes per nodes.
- All other parameters are supposed to remain constant between generated instances and can be adjusted easily.
Problem data gets saved to path provided in **argv[1]**.
bool generate_and_execute_2d_plot_test(std::filesystem::path path, size_t number_of_instances_per_coord, axis_data x_axis_data, axis_data y_axis_data, std::function<Generation_Parameters(double x, double y)> test_generator){
std::cout << "-----------------> starting testing raster in " << path.string() << std::endl;
bool success = true;
for(int xn = 0; xn < x_axis_data.resolution; xn++){
for(int yn = 0; yn < y_axis_data.resolution; yn++){
double x = ((double)xn/(x_axis_data.resolution-1))*x_axis_data.upper_bound + (1-(double)xn/(x_axis_data.resolution-1))*x_axis_data.lower_bound;
double y = ((double)yn/(y_axis_data.resolution-1))*y_axis_data.upper_bound + (1-(double)yn/(y_axis_data.resolution-1))*y_axis_data.lower_bound;
std::cout << "-----------------> rasterized testing loop state: " << x_axis_data.axis_name << " = " << x << ", " << y_axis_data.axis_name << " = " << y << std::endl;
Generation_Parameters current_generation_parameters = test_generator(x, y);
std::stringstream folder;
folder << x << "_" << y;
std::filesystem::path current_file_path = path/folder.str()/"test_parameters.test_param";
// check if the folder has been populated with an instance before
if(std::filesystem::status(current_file_path.parent_path()).type() == std::filesystem::file_type::directory && std::filesystem::status(current_file_path).type() == std::filesystem::file_type::regular){
std::cout << "rasterized testing: " << current_file_path.parent_path() << " already exists checking if parameters conincide" << std::endl;
std::fstream parameters_file(current_file_path, std::ios::in);
Generation_Parameters compare = {};
parameters_file >> compare;
parameters_file.close();
if(compare != current_generation_parameters) throw;
}else{
assert(std::filesystem::create_directory(current_file_path.parent_path()));
}
if(std::filesystem::status(current_file_path).type() != std::filesystem::file_type::regular){
std::fstream parameters_file(current_file_path, std::ios::out);
parameters_file << current_generation_parameters;
parameters_file.close();
}
std::cout << std::endl;
if( !generate_tests_data(current_file_path.parent_path(), number_of_instances_per_coord) ) success = false;
if( !execute_tests(current_file_path.parent_path()) ) success = false;
std::cout << "\n" << std::endl;
}
}
return success;
}
...@@ -11,4 +11,16 @@ ...@@ -11,4 +11,16 @@
bool generate_tests_data(std::filesystem::path path, int number_of_instances); bool generate_tests_data(std::filesystem::path path, int number_of_instances);
bool execute_tests(std::filesystem::path path, bool check_all_problem_data = false, bool add_new_execution = false); bool execute_tests(std::filesystem::path path, bool check_all_problem_data = false, bool add_new_execution = false);
// generates raster of tests
struct axis_data{
std::string axis_name;
size_t resolution;
double lower_bound;
double upper_bound;
};
bool generate_and_execute_2d_plot_test(std::filesystem::path path, size_t number_of_instances_per_coord, axis_data x_axis_data, axis_data y_axis_data, std::function<Generation_Parameters(double x, double y)> test_generator);
// gathers specified fields into a table which can be easily be plotted afterwards with pgfplots
#endif #endif
#include "Specialization/LP_Problems/Maintenance_Problem/Testing/maintenance_problem_testing.h"
#include <cmath>
int main(int argc, char** argv){
assert(argc == 2);
std::string path(argv[1]);
std::function<Generation_Parameters(double, double)> test_generator = [](double nincid, double nedges){
return Generation_Parameters{
"0",
(size_t) round((double)(2*nedges)/nincid),
nincid,
.8,
(size_t) round((double)(2*nedges)/nincid),
0,
3
};
};
return generate_and_execute_2d_plot_test(path, 15, axis_data{"nincidences", 5, 3, 7}, axis_data{"nedges", 4, 50, 125}, test_generator);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment