Bug fix in scheduling test (empty set of objects) and reformating of tests using test macros.

This commit is contained in:
surynek 2024-11-10 21:26:08 +01:00 committed by Lukas Matena
parent 847dc52a24
commit c65315ce5a
13 changed files with 517 additions and 658 deletions

View File

@ -8,6 +8,9 @@ set(CMAKE_CXX_EXTENSIONS False)
find_package(Z3 REQUIRED)
slic3r_remap_configs("z3::libz3" RelWithDebInfo Release)
find_package(Catch2 2.9 REQUIRED)
include(Catch)
add_library(libseqarrange STATIC src/seq_interface.cpp src/seq_preprocess.cpp src/seq_sequential.cpp src/seq_utilities.cpp)
target_include_directories(libseqarrange PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange)
target_link_libraries(libseqarrange libslic3r z3::libz3)
@ -29,7 +32,7 @@ target_link_libraries(sequential_decimator libseqarrange)
# target_link_libraries(seq_test_arrangement libseqarrange)
add_executable(seq_test_polygon test/seq_test_polygon.cpp test/prusaparts.cpp)
target_link_libraries(seq_test_polygon libseqarrange)
target_link_libraries(seq_test_polygon Catch2::Catch2 libseqarrange)
target_include_directories(seq_test_polygon PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange")
add_executable(seq_test_sequential test/seq_test_sequential.cpp)
@ -44,3 +47,7 @@ add_executable(seq_test_interface test/seq_test_interface.cpp)
target_link_libraries(seq_test_interface libseqarrange)
target_include_directories(seq_test_interface PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange")
add_test(seq_test_polygon seq_test_polygon)
add_test(seq_test_preprocess seq_test_preprocess)
add_test(seq_test_sequential seq_test_sequential)
add_test(seq_test_interface seq_test_interface)

View File

@ -249,6 +249,8 @@ void introduce_TemporalOrdering(z3::solver &Solver,
int temporal_spread,
const std::vector<Slic3r::Polygon> &polygons)
{
if (!polygons.empty())
{
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -256,6 +258,7 @@ void introduce_TemporalOrdering(z3::solver &Solver,
Solver.add(dec_vars_T[i] > dec_vars_T[j] + temporal_spread || dec_vars_T[i] + temporal_spread < dec_vars_T[j]);
}
}
}
}
@ -268,6 +271,8 @@ void introduce_SequentialTemporalOrderingAgainstFixed(z3::solver
int temporal_spread,
const std::vector<Slic3r::Polygon> &SEQ_UNUSED(polygons))
{
if (!undecided.empty())
{
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -275,6 +280,7 @@ void introduce_SequentialTemporalOrderingAgainstFixed(z3::solver
Solver.add(dec_vars_T[undecided[i]] > dec_vars_T[undecided[j]] + temporal_spread || dec_vars_T[undecided[i]] + temporal_spread < dec_vars_T[undecided[j]]);
}
}
}
for (unsigned int i = 0; i < undecided.size(); ++i)
{
@ -306,6 +312,8 @@ void introduce_ConsequentialTemporalOrderingAgainstFixed(z3::solver
int temporal_spread,
const std::vector<Slic3r::Polygon> &SEQ_UNUSED(polygons))
{
if (!undecided.empty())
{
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -313,6 +321,7 @@ void introduce_ConsequentialTemporalOrderingAgainstFixed(z3::solver
Solver.add(dec_vars_T[undecided[i]] > dec_vars_T[undecided[j]] + temporal_spread || dec_vars_T[undecided[i]] + temporal_spread < dec_vars_T[undecided[j]]);
}
}
}
for (unsigned int i = 0; i < undecided.size(); ++i)
{
@ -373,6 +382,8 @@ void introduce_ConsequentialTemporalLepoxAgainstFixed(z3::solver
Solver.add(dec_vars_T[undecided[i]] + temporal_spread < dec_vars_T[next_i] && dec_vars_T[undecided[i]] + temporal_spread + temporal_spread / 2 > dec_vars_T[next_i]);
}
else
{
if (!undecided.empty())
{
for (unsigned int j = 0; j < undecided.size() - 1; ++j)
{
@ -381,6 +392,7 @@ void introduce_ConsequentialTemporalLepoxAgainstFixed(z3::solver
}
}
}
}
#ifdef DEBUG
{
@ -2991,6 +3003,8 @@ void introduce_PolygonWeakNonoverlapping(z3::solver &Sol
const z3::expr_vector &dec_vars_Y,
const std::vector<Slic3r::Polygon> &polygons)
{
if (!polygons.empty())
{
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -3005,6 +3019,7 @@ void introduce_PolygonWeakNonoverlapping(z3::solver &Sol
polygons[j]);
}
}
}
}
@ -3042,6 +3057,8 @@ void introduce_SequentialPolygonWeakNonoverlapping(z3::solver
const std::vector<Slic3r::Polygon> &polygons,
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
{
if (!polygons.empty())
{
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -3060,6 +3077,7 @@ void introduce_SequentialPolygonWeakNonoverlapping(z3::solver
unreachable_polygons[j]);
}
}
}
}
@ -3097,6 +3115,8 @@ void introduce_ConsequentialPolygonWeakNonoverlapping(z3::solver
const std::vector<Slic3r::Polygon> &polygons,
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
{
if (!polygons.empty())
{
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -3115,6 +3135,7 @@ void introduce_ConsequentialPolygonWeakNonoverlapping(z3::solver
unreachable_polygons[j]);
}
}
}
}
@ -3128,6 +3149,8 @@ void introduce_PolygonWeakNonoverlapping(z3::solver &Sol
const std::vector<int> &undecided,
const std::vector<Slic3r::Polygon> &polygons)
{
if (!undecided.empty())
{
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -3142,6 +3165,7 @@ void introduce_PolygonWeakNonoverlapping(z3::solver &Sol
polygons[undecided[j]]);
}
}
}
for (unsigned int i = 0; i < undecided.size(); ++i)
{
@ -3209,6 +3233,8 @@ void introduce_SequentialPolygonWeakNonoverlapping(z3::solver
const std::vector<Slic3r::Polygon> &polygons,
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
{
if (!undecided.empty())
{
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -3232,6 +3258,7 @@ void introduce_SequentialPolygonWeakNonoverlapping(z3::solver
unreachable_polygons[undecided[j]]);
}
}
}
for (unsigned int i = 0; i < undecided.size(); ++i)
{
@ -3311,6 +3338,8 @@ void introduce_ConsequentialPolygonWeakNonoverlapping(const SolverConfiguration
const std::vector<Slic3r::Polygon> &polygons,
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
{
if (!undecided.empty())
{
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -3334,6 +3363,7 @@ void introduce_ConsequentialPolygonWeakNonoverlapping(const SolverConfiguration
unreachable_polygons[undecided[j]]);
}
}
}
if (fixed.size() < (unsigned int)solver_configuration.fixed_object_grouping_limit)
{
@ -3470,6 +3500,8 @@ void introduce_PolygonStrongNonoverlapping(z3::solver &S
dec_vars_Y,
polygons);
if (!polygons.empty())
{
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -3499,6 +3531,7 @@ void introduce_PolygonStrongNonoverlapping(z3::solver &S
}
}
}
}
}
@ -3731,6 +3764,7 @@ bool refine_PolygonWeakNonoverlapping(z3::solver &Solver
{
bool refined = false;
assert(!polygons.empty());
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -3816,6 +3850,7 @@ bool refine_PolygonWeakNonoverlapping(z3::solver &Solver
{
bool refined = false;
assert(!polygons.empty());
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -3896,6 +3931,7 @@ bool refine_PolygonWeakNonoverlapping(z3::solver &Solver
{
bool refined = false;
assert(!polygons.empty());
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -3979,6 +4015,7 @@ bool refine_SequentialPolygonWeakNonoverlapping(z3::solver
{
bool refined = false;
assert(!polygons.empty());
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -4168,6 +4205,7 @@ bool refine_SequentialPolygonWeakNonoverlapping(z3::solver
{
bool refined = false;
assert(!polygons.empty());
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -4374,6 +4412,7 @@ bool refine_ConsequentialPolygonWeakNonoverlapping(z3::solver
{
bool refined = false;
assert(!polygons.empty());
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -4560,6 +4599,7 @@ bool refine_ConsequentialPolygonWeakNonoverlapping(z3::solver
{
bool refined = false;
assert(!polygons.empty());
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -4766,6 +4806,8 @@ void introduce_PolygonWeakNonoverlappingAgainstFixed(z3::solver
const std::vector<int> &undecided,
const std::vector<Slic3r::Polygon> &polygons)
{
if (!undecided.empty())
{
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -4780,6 +4822,7 @@ void introduce_PolygonWeakNonoverlappingAgainstFixed(z3::solver
polygons[undecided[j]]);
}
}
}
for (unsigned int i = 0; i < undecided.size(); ++i)
{
@ -4810,6 +4853,7 @@ bool refine_PolygonWeakNonoverlapping(z3::solver &Solver
{
bool refined = false;
assert(!undecided.empty());
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -4974,6 +5018,7 @@ bool refine_PolygonWeakNonoverlapping(z3::solver &Solver
printf("Refining ***************************\n");
}
#endif
assert(!undecided.empty());
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -5216,6 +5261,7 @@ bool refine_SequentialPolygonWeakNonoverlapping(z3::solver
}
#endif
assert(!undecided.empty());
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -5728,6 +5774,7 @@ bool refine_ConsequentialPolygonWeakNonoverlapping(z3::solver
}
#endif
assert(!undecided.empty());
for (unsigned int i = 0; i < undecided.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < undecided.size(); ++j)
@ -6191,6 +6238,8 @@ bool check_PointsOutsidePolygons(const std::vector<Rational>
const std::vector<Slic3r::Polygon> &polygons,
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
{
if (!polygons.empty())
{
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -6332,6 +6381,7 @@ bool check_PointsOutsidePolygons(const std::vector<Rational>
}
}
}
}
#ifdef DEBUG
{
printf("Points DONE !!!\n");
@ -6348,6 +6398,8 @@ bool check_PolygonLineIntersections(const std::vector<Rational>
const std::vector<Slic3r::Polygon> &polygons,
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
{
if (!polygons.empty())
{
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
{
for (unsigned int j = i + 1; j < polygons.size(); ++j)
@ -6452,7 +6504,6 @@ bool check_PolygonLineIntersections(const std::vector<Rational>
next_point1.x() - point1.x(), next_point1.y() - point1.y(),
dec_values_X[j].as_double() + point2.x(), dec_values_Y[j].as_double() + point2.y(),
next_point2.x() - point2.x(), next_point2.y() - point2.y()))
{
#ifdef DEBUG
{
@ -6493,6 +6544,7 @@ bool check_PolygonLineIntersections(const std::vector<Rational>
}
}
}
}
#ifdef DEBUG
{

View File

@ -19,6 +19,10 @@
#include <gecode/minimodel.hh>
#include <gecode/search.hh>
#define CATCH_CONFIG_EXTERNAL_INTERFACES
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include "seq_defs.hpp"
#include "seq_test_arrangement.hpp"
@ -81,9 +85,9 @@ public:
};
void test_arrangement_1(void)
TEST_CASE("Arrangement test 1", "[Classical Arrangement]")
{
printf("Testing sheet arrangement 1 ...\n");
printf("Testing plate arrangement 1 ...\n");
SizeOptions opt("Queens");
opt.iterations(200);
@ -92,7 +96,7 @@ void test_arrangement_1(void)
Script::run<Queens,LDS,SizeOptions>(opt);
printf("Testing sheet arrangement 1 ... finished\n");
printf("Testing plate arrangement 1 ... finished\n");
}
@ -140,7 +144,7 @@ public:
};
const int sheet_size = 9;
const int plate_size = 9;
const int Obj1_width = 5;
const int Obj1_height = 4;
@ -161,7 +165,7 @@ public:
public:
ArrangementProblem()
: vars(*this, 6, 0, sheet_size - 1)
: vars(*this, 6, 0, plate_size - 1)
, Obj1_x(vars[0])
, Obj1_y(vars[1])
, Obj2_x(vars[2])
@ -191,16 +195,16 @@ public:
nooverlap(*this, Xs, widths, Ys, heights);
rel(*this, Obj1_x + Obj1_width <= sheet_size);
rel(*this, Obj2_x + Obj2_width <= sheet_size);
rel(*this, Obj3_x + Obj3_width <= sheet_size);
rel(*this, Obj1_x + Obj1_width <= plate_size);
rel(*this, Obj2_x + Obj2_width <= plate_size);
rel(*this, Obj3_x + Obj3_width <= plate_size);
rel(*this, Obj2_x == Obj1_x + 5);
rel(*this, Obj2_y == Obj1_y + 1);
rel(*this, Obj1_y + Obj1_height <= sheet_size);
rel(*this, Obj2_y + Obj2_height <= sheet_size);
rel(*this, Obj3_y + Obj3_height <= sheet_size);
rel(*this, Obj1_y + Obj1_height <= plate_size);
rel(*this, Obj2_y + Obj2_height <= plate_size);
rel(*this, Obj3_y + Obj3_height <= plate_size);
branch(*this, vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN());
};
@ -236,7 +240,7 @@ public:
};
const int sheet_resolution = 20;
const int plate_resolution = 20;
const int time_resolution = 80;
const int low_Obj1_width = 5;
@ -274,9 +278,9 @@ public:
public:
SimpleSequentialProblem()
: space_vars(*this, 8, 0, sheet_resolution)
: space_vars(*this, 8, 0, plate_resolution)
, time_vars(*this, 4, 0, time_resolution)
, kine_vars(*this, 2, 0, sheet_resolution)
, kine_vars(*this, 2, 0, plate_resolution)
, low_Obj1_x(space_vars[0])
, low_Obj1_y(space_vars[1])
@ -362,15 +366,15 @@ public:
rel(*this, low_Obj2_t >= high_Obj1_t + high_Obj1_duration || high_Obj1_t >= low_Obj2_t + low_Obj2_duration);
rel(*this, low_Obj1_t >= high_Obj1_t + high_Obj1_duration || high_Obj1_t >= low_Obj1_t + low_Obj1_duration);
rel(*this, low_Obj1_x + low_Obj1_width <= sheet_resolution);
rel(*this, low_Obj2_x + low_Obj2_width <= sheet_resolution);
rel(*this, low_Obj3_x + low_Obj3_width <= sheet_resolution);
rel(*this, high_Obj1_x + high_Obj1_width <= sheet_resolution);
rel(*this, low_Obj1_x + low_Obj1_width <= plate_resolution);
rel(*this, low_Obj2_x + low_Obj2_width <= plate_resolution);
rel(*this, low_Obj3_x + low_Obj3_width <= plate_resolution);
rel(*this, high_Obj1_x + high_Obj1_width <= plate_resolution);
rel(*this, low_Obj1_y + low_Obj1_height <= sheet_resolution);
rel(*this, low_Obj2_y + low_Obj2_height <= sheet_resolution);
rel(*this, low_Obj3_y + low_Obj3_height <= sheet_resolution);
rel(*this, high_Obj1_y + high_Obj1_height <= sheet_resolution);
rel(*this, low_Obj1_y + low_Obj1_height <= plate_resolution);
rel(*this, low_Obj2_y + low_Obj2_height <= plate_resolution);
rel(*this, low_Obj3_y + low_Obj3_height <= plate_resolution);
rel(*this, high_Obj1_y + high_Obj1_height <= plate_resolution);
rel(*this, low_Obj1_t + low_Obj1_duration <= time_resolution);
rel(*this, low_Obj2_t + low_Obj2_duration <= time_resolution);
@ -436,10 +440,10 @@ public:
};
int complex_sheet_resolution = 30;
int complex_plate_resolution = 30;
int complex_sheet_resolution_min = 10;
int complex_sheet_resolution_max = 200;
int complex_plate_resolution_min = 10;
int complex_plate_resolution_max = 200;
int complex_time_resolution = 1000;
int complex_height_threshold = 25;
@ -482,9 +486,9 @@ public:
public:
ComplexSequentialProblem()
: space_vars(*this, 2 * complex_Obj_count, 0, complex_sheet_resolution)
: space_vars(*this, 2 * complex_Obj_count, 0, complex_plate_resolution)
, time_vars(*this, complex_Obj_count, 0, complex_time_resolution)
, kine_vars(*this, 2 * complex_Obj_count, 0, complex_sheet_resolution)
, kine_vars(*this, 2 * complex_Obj_count, 0, complex_plate_resolution)
{
/*
int width_span = max_width - min_width;
@ -535,8 +539,8 @@ public:
for (int i = 0; i < complex_Obj_count; ++i)
{
rel(*this, complex_Obj_x[i] + complex_Obj_widths[i] <= complex_sheet_resolution, IPL_BND);
rel(*this, complex_Obj_y[i] + complex_Obj_heights[i] <= complex_sheet_resolution, IPL_BND);
rel(*this, complex_Obj_x[i] + complex_Obj_widths[i] <= complex_plate_resolution, IPL_BND);
rel(*this, complex_Obj_y[i] + complex_Obj_heights[i] <= complex_plate_resolution, IPL_BND);
}
for (int i = 0; i < complex_Obj_count; ++i)
@ -617,16 +621,16 @@ public:
};
int complex_sheet_resolution_X = 200;
int complex_plate_resolution_X = 200;
int complex_sheet_resolution_X_min = 10;
int complex_sheet_resolution_X_max = 200;
int complex_plate_resolution_X_min = 10;
int complex_plate_resolution_X_max = 200;
int complex_sheet_resolution_Y = 30;
int complex_plate_resolution_Y = 30;
int complex_sheet_resolution_Y_min = 10;
int complex_sheet_resolution_Y_max = 200;
int complex_plate_resolution_Y_min = 10;
int complex_plate_resolution_Y_max = 200;
void generate_random_complex_objects(void)
@ -665,11 +669,11 @@ public:
public:
ComplexSequentialProblemXY()
: space_vars_X(*this, 2 * complex_Obj_count, 0, complex_sheet_resolution_X)
, space_vars_Y(*this, 2 * complex_Obj_count, 0, complex_sheet_resolution_Y)
: space_vars_X(*this, 2 * complex_Obj_count, 0, complex_plate_resolution_X)
, space_vars_Y(*this, 2 * complex_Obj_count, 0, complex_plate_resolution_Y)
, time_vars(*this, complex_Obj_count, 0, complex_time_resolution)
, kine_vars_L(*this, complex_Obj_count, 0, complex_sheet_resolution_Y)
, kine_vars_R(*this, complex_Obj_count, 0, complex_sheet_resolution_Y)
, kine_vars_L(*this, complex_Obj_count, 0, complex_plate_resolution_Y)
, kine_vars_R(*this, complex_Obj_count, 0, complex_plate_resolution_Y)
{
for (int i = 0; i < complex_Obj_count; ++i)
{
@ -709,8 +713,8 @@ public:
for (int i = 0; i < complex_Obj_count; ++i)
{
rel(*this, complex_Obj_x[i] + complex_Obj_widths[i] <= complex_sheet_resolution_X, IPL_BND);
rel(*this, complex_Obj_y[i] + complex_Obj_heights[i] <= complex_sheet_resolution_Y, IPL_BND);
rel(*this, complex_Obj_x[i] + complex_Obj_widths[i] <= complex_plate_resolution_X, IPL_BND);
rel(*this, complex_Obj_y[i] + complex_Obj_heights[i] <= complex_plate_resolution_Y, IPL_BND);
}
@ -794,9 +798,9 @@ public:
};
void test_arrangement_2(void)
TEST_CASE("Arrangement test 2", "[Classical Arrangement]")
{
printf("Testing sheet arrangement 2 ...\n");
printf("Testing plate arrangement 2 ...\n");
SimpleProblem *simple_problem = new SimpleProblem();
DFS<SimpleProblem> engine(simple_problem);
@ -810,13 +814,13 @@ void test_arrangement_2(void)
Search::Statistics stat = engine.statistics();
printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood);
printf("Testing sheet arrangement 2 ... finished\n");
printf("Testing plate arrangement 2 ... finished\n");
}
void test_arrangement_3(void)
TEST_CASE("Arrangement test 3", "[Classical Arrangement]")
{
printf("Testing sheet arrangement 3 ...\n");
printf("Testing plate arrangement 3 ...\n");
ArrangementProblem *arrangement_problem = new ArrangementProblem();
DFS<ArrangementProblem> engine(arrangement_problem);
@ -832,13 +836,13 @@ void test_arrangement_3(void)
Search::Statistics stat = engine.statistics();
printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood);
printf("Testing sheet arrangement 3 ... finished\n");
printf("Testing plate arrangement 3 ... finished\n");
}
void test_arrangement_4(void)
TEST_CASE("Arrangement test 4", "[Classical Arrangement]")
{
printf("Testing sheet arrangement 4 ...\n");
printf("Testing plate arrangement 4 ...\n");
SimpleSequentialProblem *sequential_problem = new SimpleSequentialProblem();
DFS<SimpleSequentialProblem> engine(sequential_problem);
@ -855,13 +859,13 @@ void test_arrangement_4(void)
getchar();
}
printf("Testing sheet arrangement 4 ... finished\n");
printf("Testing plate arrangement 4 ... finished\n");
}
void test_arrangement_5(void)
TEST_CASE("Arrangement test 5", "[Classical Arrangement]")
{
printf("Testing sheet arrangement 5 ...\n");
printf("Testing plate arrangement 5 ...\n");
generate_random_complex_objects();
ComplexSequentialProblem *sequential_problem = new ComplexSequentialProblem();
@ -889,20 +893,20 @@ void test_arrangement_5(void)
clock_t end = clock();
printf("Time (CPU): %.3fs\n", (end - begin) / (double)CLOCKS_PER_SEC);
printf("Testing sheet arrangement 5 ... finished\n");
printf("Testing plate arrangement 5 ... finished\n");
}
void test_arrangement_6(void)
TEST_CASE("Arrangement test 6", "[Classical Arrangement]")
{
printf("Testing sheet arrangement 6 ...\n");
printf("Testing plate arrangement 6 ...\n");
generate_random_complex_objects();
complex_sheet_resolution = complex_sheet_resolution_max;
complex_plate_resolution = complex_plate_resolution_max;
while (complex_sheet_resolution > complex_sheet_resolution_min)
while (complex_plate_resolution > complex_plate_resolution_min)
{
printf("Trying sheet resolution = %d\n", complex_sheet_resolution);
printf("Trying plate resolution = %d\n", complex_plate_resolution);
ComplexSequentialProblem *sequential_problem = new ComplexSequentialProblem();
@ -943,23 +947,23 @@ void test_arrangement_6(void)
}
delete sequential_P;
complex_sheet_resolution -= 1;
complex_plate_resolution -= 1;
}
printf("Testing sheet arrangement 6 ... finished\n");
printf("Testing plate arrangement 6 ... finished\n");
}
void test_arrangement_7(void)
TEST_CASE("Arrangement test 7", "[Classical Arrangement]")
{
printf("Testing sheet arrangement 7 ...\n");
printf("Testing plate arrangement 7 ...\n");
generate_random_complex_objects();
complex_sheet_resolution_X = complex_sheet_resolution_X_max;
complex_plate_resolution_X = complex_plate_resolution_X_max;
while (complex_sheet_resolution_X > complex_sheet_resolution_X_min)
while (complex_plate_resolution_X > complex_plate_resolution_X_min)
{
printf("Trying sheet resolution X = %d, Y = %d\n", complex_sheet_resolution_X, complex_sheet_resolution_Y);
printf("Trying plate resolution X = %d, Y = %d\n", complex_plate_resolution_X, complex_plate_resolution_Y);
ComplexSequentialProblemXY *sequential_problem = new ComplexSequentialProblemXY();
Search::Options options;
@ -998,26 +1002,12 @@ void test_arrangement_7(void)
}
delete sequential_P;
complex_sheet_resolution_X -= 1;
complex_plate_resolution_X -= 1;
}
printf("Testing sheet arrangement 7 ... finished\n");
printf("Testing plate arrangement 7 ... finished\n");
}
/*----------------------------------------------------------------*/
int main(int UNUSED(argc), char **UNUSED(argv))
{
// test_arrangement_1();
// test_arrangement_2();
// test_arrangement_3();
// test_arrangement_4();
// test_arrangement_5();
// test_arrangement_6();
test_arrangement_7();
return 0;
}

View File

@ -15,30 +15,5 @@
/*----------------------------------------------------------------*/
/* Plate arrangment test 1 */
void test_arrangement_1(void);
/* Plate arrangment test 2 */
void test_arrangement_2(void);
/* Plate arrangment test 3 */
void test_arrangement_3(void);
/* Plate arrangment test 4 */
void test_arrangement_4(void);
/* Plate arrangment test 5 */
void test_arrangement_5(void);
/* Plate arrangment test 6 */
void test_arrangement_6(void);
/* Plate arrangment test 7 */
void test_arrangement_7(void);
/*----------------------------------------------------------------*/
#endif /* __SEQ_TEST_ARRANGEMENT_HPP__ */

View File

@ -19,6 +19,10 @@
#include "libslic3r/Geometry/ConvexHull.hpp"
#include "libslic3r/SVG.hpp"
#define CATCH_CONFIG_EXTERNAL_INTERFACES
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include <z3++.h>
#include "seq_interface.hpp"
@ -111,7 +115,7 @@ void save_import_data(const std::string &filename,
/*----------------------------------------------------------------*/
void test_interface_1(void)
TEST_CASE("Interface test 1", "[Sequential Arrangement Interface]")
{
clock_t start, finish;
@ -159,7 +163,7 @@ void test_interface_1(void)
}
void test_interface_2(void)
TEST_CASE("Interface test 2", "[Sequential Arrangement Interface]")
{
clock_t start, finish;
@ -216,7 +220,7 @@ void test_interface_2(void)
}
void test_interface_3(void)
TEST_CASE("Interface test 3", "[Sequential Arrangement Interface]")
{
clock_t start, finish;
@ -266,7 +270,7 @@ void test_interface_3(void)
}
int test_interface_4(void)
TEST_CASE("Interface test 4", "[Sequential Arrangement Interface]")
{
clock_t start, finish;
@ -290,7 +294,7 @@ int test_interface_4(void)
if (result != 0)
{
printf("Cannot load printer geometry (code: %d).\n", result);
return result;
return;
}
solver_configuration.setup(printer_geometry);
printf("Loading printer geometry ... finished\n");
@ -320,12 +324,10 @@ int test_interface_4(void)
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing interface 4 ... finished\n");
return 0;
}
int test_interface_5(void)
TEST_CASE("Interface test 5", "[Sequential Arrangement Interface]")
{
clock_t start, finish;
@ -349,7 +351,7 @@ int test_interface_5(void)
if (result != 0)
{
printf("Cannot load printer geometry (code: %d).\n", result);
return result;
return;
}
solver_configuration.setup(printer_geometry);
printf("Loading printer geometry ... finished\n");
@ -396,12 +398,10 @@ int test_interface_5(void)
printf("Checking time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing interface 5 ... finished\n");
return 0;
}
int test_interface_6(void)
TEST_CASE("Interface test 6", "[Sequential Arrangement Interface]")
{
clock_t start, finish;
@ -430,7 +430,7 @@ int test_interface_6(void)
if (result != 0)
{
printf("Cannot load printer geometry (code: %d).\n", result);
return result;
return;
}
solver_configuration.setup(printer_geometry);
printf("Loading printer geometry ... finished\n");
@ -477,23 +477,9 @@ int test_interface_6(void)
printf("Checking time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing interface 6 ... finished\n");
return 0;
}
/*----------------------------------------------------------------*/
int main(int SEQ_UNUSED(argc), char **SEQ_UNUSED(argv))
{
// test_interface_1();
// test_interface_2();
// test_interface_3();
// test_interface_4();
test_interface_5();
// test_interface_6();
return 0;
}

View File

@ -14,24 +14,5 @@
/*----------------------------------------------------------------*/
/* Interface test 1 */
void test_interface_1(void);
/* Interface test 2 */
void test_interface_2(void);
/* Interface test 3 */
void test_interface_3(void);
/* Interface test 4 */
int test_interface_4(void);
/* Interface test 5 */
int test_interface_5(void);
/* Interface test 6 */
int test_interface_6(void);
/*----------------------------------------------------------------*/
#endif /* __SEQ_TEST_PREPROCESS_HPP__ */

View File

@ -18,6 +18,10 @@
#include "libslic3r/Geometry/ConvexHull.hpp"
#include "libslic3r/SVG.hpp"
#define CATCH_CONFIG_EXTERNAL_INTERFACES
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include <z3++.h>
#include "prusaparts.hpp"
@ -45,7 +49,7 @@ using namespace Sequential;
/*----------------------------------------------------------------*/
void test_polygon_1(void)
TEST_CASE("Polygon test 1", "[Polygon]")
{
printf("Testing polygon 1 ...\n");
@ -61,7 +65,7 @@ void test_polygon_1(void)
}
void test_polygon_2(void)
TEST_CASE("Polygon test 2", "[Polygon]")
{
printf("Testing polygon 2 ...\n");
@ -130,8 +134,6 @@ void test_polygon_2(void)
bool ins4 = is_inside(point_1 - point_2);
printf("%s\n", ins4 ? "yes" : "no");
}
getchar();
}
printf("Testing polygon 2 ... finished\n");
@ -141,7 +143,7 @@ void test_polygon_2(void)
int line_count = 4;
Line lines[] = {{Point(100,100), Point(200,200)}, {Point(200,100), Point(100,200)}, {Point(0,0), Point(100,10)}, {Point(50,0), Point(60,100)} };
void test_polygon_3(void)
TEST_CASE("Polygon test 3", "[Polygon]")
{
clock_t start, finish;
@ -281,7 +283,7 @@ void test_polygon_3(void)
}
void test_polygon_4(void)
TEST_CASE("Polygon test 4", "[Polygon]")
{
clock_t start, finish;
@ -425,7 +427,7 @@ int poly_line_count = 4;
Line poly_lines[] = {{Point(100,100), Point(200,100)}, {Point(200,100), Point(200,200)}, {Point(200,200), Point(100,200)}, {Point(100,200), Point(100,100)} };
void test_polygon_5(void)
TEST_CASE("Polygon test 5", "[Polygon]")
{
clock_t start, finish;
@ -566,7 +568,7 @@ Polygon polygon_1 = {{0, 0}, {50, 0}, {50, 50}, {0, 50}};
//Polygon polygon_1 = {{scale_(0), scale_(0)}, {scale_(50), scale_(0)}, {scale_(50), scale_(50)}, {scale_(0), scale_(50)}};
void test_polygon_6(void)
TEST_CASE("Polygon test 6", "[Polygon]")
{
clock_t start, finish;
@ -692,7 +694,7 @@ Polygon polygon_2 = {{0, 0}, {150, 0}, {150, 50}, {75, 120}, {0, 50} };
//Polygon polygon_2 = {{scale_(0), scale_(0)}, {scale_(150), scale_(0)}, {scale_(150), scale_(50)}, {scale_(75), scale_(120)}, {scale_(0), scale_(50)} };
void test_polygon_7(void)
TEST_CASE("Polygon test 7", "[Polygon]")
{
clock_t start, finish;
@ -900,7 +902,7 @@ Polygon scale_UP(const Polygon &polygon, double x_pos, double y_pos)
Polygon polygon_3 = {{40, 0}, {80, 40}, {40, 80}, {0, 40}};
//Polygon polygon_3 = {{20, 0}, {40, 0}, {60, 30}, {30, 50}, {0, 30}};
void test_polygon_8(void)
TEST_CASE("Polygon test 8", "[Polygon]")
{
clock_t start, finish;
@ -1202,7 +1204,7 @@ void test_polygon_8(void)
}
void test_polygon_9(void)
TEST_CASE("Polygon test 9", "[Polygon]")
{
clock_t start, finish;
@ -1502,7 +1504,7 @@ void test_polygon_9(void)
Polygon polygon_4 = {{20, 0}, {40, 0}, {60, 30}, {30, 50}, {0, 30}};
void test_polygon_10(void)
TEST_CASE("Polygon test 10", "[Polygon]")
{
clock_t start, finish;
@ -1837,7 +1839,7 @@ void test_polygon_10(void)
}
void test_polygon_11(void)
TEST_CASE("Polygon test 11", "[Polygon]")
{
clock_t start, finish;
@ -2290,7 +2292,7 @@ void test_polygon_11(void)
}
void test_polygon_12(void)
TEST_CASE("Polygon test 12", "[Polygon]")
{
clock_t start, finish;
@ -2400,7 +2402,7 @@ void test_polygon_12(void)
}
void test_polygon_13(void)
TEST_CASE("Polygon test 13", "[Polygon]")
{
clock_t start, finish;
@ -2556,7 +2558,7 @@ void test_polygon_13(void)
}
void test_polygon_14(void)
TEST_CASE("Polygon test 14", "[Polygon]")
{
clock_t start, finish;
@ -2810,7 +2812,7 @@ void test_polygon_14(void)
}
void test_polygon_15(void)
TEST_CASE("Polygon test 15", "[Polygon]")
{
clock_t start, finish;
@ -3006,7 +3008,7 @@ void test_polygon_15(void)
}
void test_polygon_16(void)
TEST_CASE("Polygon test 16", "[Polygon]")
{
clock_t start, finish;
@ -3034,26 +3036,3 @@ void test_polygon_16(void)
/*----------------------------------------------------------------*/
int main(int SEQ_UNUSED(argc), char **SEQ_UNUSED(argv))
{
//test_polygon_1();
//test_polygon_2();
//test_polygon_3();
//test_polygon_4();
//test_polygon_5();
//test_polygon_6();
//test_polygon_7();
//test_polygon_8();
//test_polygon_9();
//test_polygon_10();
//test_polygon_11();
//test_polygon_12();
//test_polygon_13();
//test_polygon_14();
//test_polygon_15();
test_polygon_16();
return 0;
}

View File

@ -14,54 +14,5 @@
/*----------------------------------------------------------------*/
/* Polygon test 1 */
void test_polygon_1(void);
/* Polygon test 2 */
void test_polygon_2(void);
/* Polygon test 3 */
void test_polygon_3(void);
/* Polygon test 4 */
void test_polygon_4(void);
/* Polygon test 5 */
void test_polygon_5(void);
/* Polygon test 6 */
void test_polygon_6(void);
/* Polygon test 7 */
void test_polygon_7(void);
/* Polygon test 8 */
void test_polygon_8(void);
/* Polygon test 9 */
void test_polygon_9(void);
/* Polygon test 10 */
void test_polygon_10(void);
/* Polygon test 11 */
void test_polygon_11(void);
/* Polygon test 12 */
void test_polygon_12(void);
/* Polygon test 13 */
void test_polygon_13(void);
/* Polygon test 14 */
void test_polygon_14(void);
/* Polygon test 15 */
void test_polygon_15(void);
/* Polygon test 16 */
void test_polygon_16(void);
/*----------------------------------------------------------------*/
#endif /* __SEQ_TEST_POLYGON_HPP__ */

View File

@ -20,6 +20,10 @@
#include "libslic3r/Geometry/ConvexHull.hpp"
#include "libslic3r/SVG.hpp"
#define CATCH_CONFIG_EXTERNAL_INTERFACES
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include <z3++.h>
#include "prusaparts.hpp"
@ -76,7 +80,7 @@ Polygon scale_UP(const Polygon &polygon, double x_pos, double y_pos)
std::vector<Polygon> test_polygons;
void test_preprocess_1(void)
TEST_CASE("Preprocessing test 1", "[Sequential Arrangement Preprocessing]")
{
clock_t start, finish;
@ -109,7 +113,7 @@ void test_preprocess_1(void)
}
void test_preprocess_2(void)
TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
{
clock_t start, finish;
@ -326,7 +330,7 @@ void test_preprocess_2(void)
}
void test_preprocess_3(void)
TEST_CASE("Preprocessing test 3", "[Sequential Arrangement Preprocessing]")
{
clock_t start, finish;
@ -595,7 +599,7 @@ void test_preprocess_3(void)
}
void test_preprocess_4(void)
TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
{
clock_t start, finish;
@ -825,7 +829,7 @@ void test_preprocess_4(void)
}
void test_preprocess_5(void)
TEST_CASE("Preprocessing test 5", "[Sequential Arrangement Preprocessing]")
{
clock_t start, finish;
@ -884,7 +888,7 @@ void test_preprocess_5(void)
}
void test_preprocess_6(void)
TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
{
clock_t start, finish;
@ -1121,16 +1125,3 @@ void test_preprocess_6(void)
/*----------------------------------------------------------------*/
int main(int SEQ_UNUSED(argc), char **SEQ_UNUSED(argv))
{
//test_preprocess_1();
//test_preprocess_2();
//test_preprocess_3();
//test_preprocess_4();
//test_preprocess_5();
test_preprocess_6();
return 0;
}

View File

@ -14,25 +14,5 @@
/*----------------------------------------------------------------*/
/* Preprocess test 1 */
void test_preprocess_1(void);
/* Preprocess test 2 */
void test_preprocess_2(void);
/* Preprocess test 3 */
void test_preprocess_3(void);
/* Preprocess test 4 */
void test_preprocess_4(void);
/* Preprocess test 5 */
void test_preprocess_5(void);
/* Preprocess test 6 */
void test_preprocess_6(void);
/*----------------------------------------------------------------*/
#endif /* __SEQ_TEST_PREPROCESS_HPP__ */

View File

@ -19,6 +19,10 @@
#include "libslic3r/Geometry/ConvexHull.hpp"
#include "libslic3r/SVG.hpp"
#define CATCH_CONFIG_EXTERNAL_INTERFACES
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include <z3++.h>
#include "seq_defs.hpp"
@ -69,7 +73,7 @@ Polygon scale_UP(const Polygon &polygon, double x_pos, double y_pos)
}
void test_sequential_1(void)
TEST_CASE("Sequential test 1", "[Sequential Arrangement Core]")
{
printf("Testing sequential scheduling 1 ...\n");
@ -239,7 +243,7 @@ void generate_random_complex_objects(void)
typedef std::basic_string<char> sString;
void test_sequential_2(void)
TEST_CASE("Sequential test 2", "[Sequential Arrangement Core]")
{
clock_t start, finish;
@ -489,7 +493,7 @@ void generate_random_rotated_complex_objects(void)
}
void test_sequential_3(void)
TEST_CASE("Sequential test 3", "[Sequential Arrangement Core]")
{
clock_t start, finish;
@ -767,7 +771,7 @@ std::vector<Polygon> unreachable_polygons_4 = {
};
void test_sequential_4(void)
TEST_CASE("Sequential test 4", "[Sequential Arrangement Core]")
{
clock_t start, finish;
@ -1228,7 +1232,7 @@ void test_sequential_4(void)
}
void test_sequential_5(void)
TEST_CASE("Sequential test 5", "[Sequential Arrangement Core]")
{
clock_t start, finish;
@ -1724,8 +1728,7 @@ void test_sequential_5(void)
}
void test_sequential_6(void)
TEST_CASE("Sequential test 6", "[Sequential Arrangement Core]")
{
clock_t start, finish;
@ -2017,7 +2020,7 @@ void test_sequential_6(void)
}
void test_sequential_7(void)
TEST_CASE("Sequential test 7", "[Sequential Arrangement Core]")
{
clock_t start, finish;
@ -2298,16 +2301,3 @@ void test_sequential_7(void)
/*----------------------------------------------------------------*/
int main(int SEQ_UNUSED(argc), char **SEQ_UNUSED(argv))
{
// test_sequential_1();
// test_sequential_2();
// test_sequential_3();
// test_sequential_4();
// test_sequential_5();
// test_sequential_6();
test_sequential_7();
return 0;
}

View File

@ -14,28 +14,5 @@
/*----------------------------------------------------------------*/
/* Sequential arrangment test 1 */
void test_sequential_1(void);
/* Sequential arrangment test 2 */
void test_sequential_2(void);
/* Sequential arrangment test 3 */
void test_sequential_3(void);
/* Sequential arrangment test 4 */
void test_sequential_4(void);
/* Sequential arrangment test 5 */
void test_sequential_5(void);
/* Sequential arrangment test 6 */
void test_sequential_6(void);
/* Sequential arrangment test 7 */
void test_sequential_7(void);
/*----------------------------------------------------------------*/
#endif /* __SEQ_TEST_SEQUENTIAL_HPP__ */