Commit 2935f228 authored by jonasseidel's avatar jonasseidel
Browse files

test update

parent fe9c92cb
......@@ -24,12 +24,13 @@ gather_data_to_csv
graph_display
data
test_sets
./mk_tests/nincidences_nedges_cyclic
./mk_tests/nincidences_nedges
./mk_tests/share-of-critical_dummy_constant_nincidences
./mk_tests/nsteps_nepochs
./mk_tests/nnodes_nedges
./mk_tests/share-of-critical_dummy_network_connectors_buffer
./mk_tests/nepochs_decentralization_clusters_aggregated_networks
./mk_tests/nsteps_nepochs_multiple_sources
./mk_tests/share-of-critical_dummy
nincidences_nedges_cyclic
nincidences_nedges
share-of-critical_dummy_constant_nincidences
nsteps_nepochs
nnodes_nedges
share-of-critical_dummy_network_connectors_buffer
nepochs_decentralization_clusters_aggregated_networks
nsteps_nepochs_multiple_sources
share-of-critical_dummy
execute_single_test
......@@ -9,7 +9,7 @@ void gather_data(std::filesystem::path path, std::vector<Data>& data_vector, int
}
//typedef std::vector<Data>::iterator Iter;
std::cout << buffer.str() << "--> going into " << path.string() << std::endl;
std::cerr << buffer.str() << "--> going into " << path.string() << std::endl;
// iterate over instances in folder
for (const auto & entry : std::filesystem::directory_iterator(path)){
......@@ -30,13 +30,13 @@ void gather_data(std::filesystem::path path, std::vector<Data>& data_vector, int
if(!data_vector.back().values_complete()) {
throw std::range_error("not all data has been calculated; execute the models first");
}
std::cout << buffer.str() << "data appears correct; collecting..." << std::endl;
std::cerr << buffer.str() << "data appears correct; collecting..." << std::endl;
}catch(std::invalid_argument& e){
data_vector.pop_back();
std::cout << buffer.str() << "file doesn't appear to contain test data" << std::endl;
std::cerr << buffer.str() << "file doesn't appear to contain test data" << std::endl;
}catch(std::range_error& e){
data_vector.pop_back();
std::cout << buffer.str() << "scipping instance, due to it not having been executed" << std::endl;
std::cerr << buffer.str() << "scipping instance, due to it not having been executed" << std::endl;
}catch(std::exception& e){
data_vector.pop_back();
throw e;
......
bool execute_tests(std::filesystem::path path, bool check_all_problem_data, bool add_new_execution){
std::cout << "-----------------> execution started in " << path.string() << std::endl;
std::cerr << "-----------------> execution started in " << path.string() << std::endl;
// execution function
std::function<bool(Data&)> exec = [check_all_problem_data, add_new_execution](Data& data){
......@@ -60,11 +60,11 @@ bool execute_tests(std::filesystem::path path, bool check_all_problem_data, bool
&& exec_vector.back().gap.first
&& exec_vector.back().number_of_primal_sols.first)
{
std::cout << "problem execution: skipping execution of " << SCIPgetProbName(current_scip) << " due to it having been previously executed" << std::endl;
std::cerr << "problem execution: skipping execution of " << SCIPgetProbName(current_scip) << " due to it having been previously executed" << std::endl;
continue;
}
std::cout << "---------------->" << SCIPgetProbName(current_scip) << ":" << std::endl;
std::cerr << "---------------->" << SCIPgetProbName(current_scip) << ":" << std::endl;
SCIPsolve(current_scip);
if(add_new_execution || exec_vector.size() == 0){
......@@ -106,7 +106,7 @@ bool execute_tests(std::filesystem::path path, bool check_all_problem_data, bool
for (const auto & entry : std::filesystem::directory_iterator(path)){
if(entry.is_directory()){
std::filesystem::path data_path = entry.path()/"instance.test_data";
std::cout << "problem execution: reading data for instance " << "\033[1;31m" << data_path.parent_path().filename() << "\033[0m" << std::endl;
std::cerr << "problem execution: reading data for instance " << "\033[1;31m" << data_path.parent_path().filename() << "\033[0m" << std::endl;
std::fstream data_file;
......@@ -122,7 +122,7 @@ bool execute_tests(std::filesystem::path path, bool check_all_problem_data, bool
Generic_Performance_Tester<Data> tester(curr_data, exec);
std::cout << "problem execution: executing" << std::endl;
std::cerr << "problem execution: executing" << std::endl;
if(!tester.populate_data()) success = false;
for( auto [formulation, exec_vector] : tester._data.derived_performance ){
......@@ -169,7 +169,7 @@ bool execute_tests(std::filesystem::path path, bool check_all_problem_data, bool
}
}
std::cout << std::endl;
std::cerr << std::endl;
return success;
}
bool generate_and_execute_2d_plot_test(std::filesystem::path path, size_t number_of_instances_per_coord, const axis_data& x_axis_data, const axis_data& y_axis_data, std::function<maintenance_problem_generator(double x, double y)> test_generator){
std::cout << "-----------------> starting testing raster in " << path.string() << std::endl;
std::cerr << "-----------------> starting testing raster in " << path.string() << std::endl;
bool success = true;
......@@ -15,7 +15,7 @@ bool generate_and_execute_2d_plot_test(std::filesystem::path path, size_t number
if(y_axis_data.resolution > 1){
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.name << " = " << x << ", " << y_axis_data.name << " = " << y << std::endl;
std::cerr << "-----------------> rasterized testing loop state: " << x_axis_data.name << " = " << x << ", " << y_axis_data.name << " = " << y << std::endl;
maintenance_problem_generator current_generation_parameters = test_generator(x, y);
......@@ -25,7 +25,7 @@ bool generate_and_execute_2d_plot_test(std::filesystem::path path, size_t number
// 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::cerr << "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);
maintenance_problem_generator compare(parameters_file);
......@@ -40,12 +40,12 @@ bool generate_and_execute_2d_plot_test(std::filesystem::path path, size_t number
parameters_file << current_generation_parameters;
parameters_file.close();
}
std::cout << std::endl;
std::cerr << 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;
std::cerr << "\n" << std::endl;
}
}
return success;
......
......@@ -3,17 +3,17 @@
#include <cstdlib>
bool generate_tests_data(std::filesystem::path path, int number_of_instances){
std::cout << "-----------------> generation started in " << path.string() << std::endl;
std::cerr << "-----------------> generation started in " << path.string() << std::endl;
// reading path from arguments
std::filesystem::path param_path = path/"test_parameters.mpg";
std::cout << "problem generation: reading " << path.string() << std::endl;
std::cerr << "problem generation: reading " << path.string() << std::endl;
// read generation parameters from top level folder
std::fstream test_generator_file;
test_generator_file.open(param_path, std::ios::in);
maintenance_problem_generator test_generator(test_generator_file);
std::cout << "problem generation: generator is given by" << std::endl;
std::cerr << "problem generation: generator is given by" << std::endl;
// populate folder with instances
for(int instance = 0; instance < number_of_instances; ++instance){
......@@ -21,7 +21,7 @@ bool generate_tests_data(std::filesystem::path path, int number_of_instances){
// 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::cout << current_file_path.parent_path() << " already exists, checking validity" << std::endl;
std::cerr << current_file_path.parent_path() << " already exists, checking validity" << std::endl;
// try reading said instance
......@@ -35,7 +35,7 @@ bool generate_tests_data(std::filesystem::path path, int number_of_instances){
if( curr_data.generator != test_generator ) throw std::runtime_error("generator mismatch");
std::cout << "data appears correct; skipping" << std::endl;
std::cerr << "data appears correct; skipping" << std::endl;
continue;
}catch(std::invalid_argument& e){
std::cerr << e.what() << std::endl;
......@@ -60,16 +60,16 @@ bool generate_tests_data(std::filesystem::path path, int number_of_instances){
Data new_data = {};
std::cout << "problem generation: generation " << instance << ": " << "[metadata]" << std::flush;
std::cerr << "problem generation: generation " << instance << ": " << "[metadata]" << std::flush;
new_data.marked = false;
new_data.path = current_file_path.parent_path().string();
new_data.name = current_file_path.filename().string();
new_data.generator = test_generator;
std::cout << " [problem]" << std::flush;
std::cerr << " [problem]" << std::flush;
new_data.mp = std::move(test_generator.next());
std::cout << " [empty derived data]" << std::endl;
std::cerr << " [empty derived data]" << std::endl;
new_data.derived_problem = Derived_Problem_Data{
{false, 0},
{false, 0},
......@@ -81,14 +81,14 @@ bool generate_tests_data(std::filesystem::path path, int number_of_instances){
};
new_data.derived_performance = {};
std::cout << "problem generation: writing instance data" << "\n" << std::endl;
std::cerr << "problem generation: writing instance data" << "\n" << std::endl;
std::fstream data_file;
data_file.open(current_file_path, std::ios::out);
data_file << new_data << std::endl;
data_file.close();
}
std::cout << std::endl;
std::cerr << std::endl;
return true;
}
......@@ -33,5 +33,5 @@ int main(int argc, char** argv){
};
return generate_and_execute_2d_plot_test(path, number_of_instances_per_coord, axis_data{"nincidences", 18, 1.5, 10}, axis_data{"nedges", 11, 25, 35}, test_generator);
return generate_and_execute_2d_plot_test(path, number_of_instances_per_coord, axis_data{"nincidences", 18, 1.5, 10}, axis_data{"nedges", 9, 20, 28}, test_generator);
}
......@@ -33,5 +33,5 @@ int main(int argc, char** argv){
};
return generate_and_execute_2d_plot_test(path, number_of_instances_per_coord, axis_data{"nincidences", 18, 1.5, 10}, axis_data{"nedges", 11, 25, 35}, test_generator);
return generate_and_execute_2d_plot_test(path, number_of_instances_per_coord, axis_data{"nincidences", 18, 1.5, 10}, axis_data{"nedges", 9, 20, 28}, test_generator);
}
......@@ -33,5 +33,5 @@ int main(int argc, char** argv){
};
return generate_and_execute_2d_plot_test(path, number_of_instances_per_coord, axis_data{"nincidences", 21, 20, 40}, axis_data{"nedges", 11, 30, 40}, test_generator);
return generate_and_execute_2d_plot_test(path, number_of_instances_per_coord, axis_data{"nnodes", 21, 20, 40}, axis_data{"nedges", 11, 30, 40}, test_generator);
}
#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]);
execute_tests(path, true, false);
}
......@@ -9,8 +9,8 @@ echo "tests loaded:"
echo "${exec}"
let count=0
mkdir .data
mkdir .data/test_data
mkdir data
mkdir data/test_data
while [ $count -lt 200 ]; do
......@@ -23,11 +23,11 @@ while [ $count -lt 200 ]; do
columns=$(echo "$test" | rev | cut -d'/' -f1 | rev | cut -d'_' -f1,2 --output-delimiter=" ")
test_filename=$(echo $test | rev | cut -d'/' -f1 | rev)
mkdir .data/test_data/$test_filename
echo "executing $test .data/test_data/$test_filename $count";
bash -c "$test .data/test_data/$test_filename $count 2> >(tee -a stderr.log >&2)"
echo "executing ./mk_gather/gather_data_to_csv .data/test_data/$test_filename $columns ${models[*]}"
bash -c "./mk_gather/gather_data_to_csv .data/test_data/$test_filename $columns ${models[*]} -o .data/test_data/$test_filename/$test_filename.csv 2> >(tee -a stderr.log >&2)"
mkdir data/test_data/$test_filename
echo "executing $test data/test_data/$test_filename $count";
bash -c "$test data/test_data/$test_filename $count 2> >(tee -a stderr.log >&2)"
echo "executing ./mk_utils/gather_data_to_csv data/test_data/$test_filename $columns ${models[*]}"
bash -c "./mk_utils/gather_data_to_csv data/test_data/$test_filename $columns ${models[*]} -o data/test_data/$test_filename/$test_filename.csv 2> >(tee -a stderr.log >&2)"
done
make push
let count=count+10;
......
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