diff --git a/src/libseqarrange/include/libseqarrange/seq_interface.hpp b/src/libseqarrange/include/libseqarrange/seq_interface.hpp index f91f7f2cf8..3d62409b66 100644 --- a/src/libseqarrange/include/libseqarrange/seq_interface.hpp +++ b/src/libseqarrange/include/libseqarrange/seq_interface.hpp @@ -89,8 +89,7 @@ struct SolverConfiguration struct ObjectToPrint { int id = 0; - bool lepox = false; /* object must be scheduled right after the previous object */ - int previous_id = -1; /* object 'id' will be scheduled right after object 'previous_id' */ + bool glued_to_next = false; /* the next object must be scheduled right after this object */ coord_t total_height = 0; std::vector> pgns_at_height; }; diff --git a/src/libseqarrange/src/seq_interface.cpp b/src/libseqarrange/src/seq_interface.cpp index 5e7dada43d..deaa4629a3 100644 --- a/src/libseqarrange/src/seq_interface.cpp +++ b/src/libseqarrange/src/seq_interface.cpp @@ -318,7 +318,7 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver std::vector > unreachable_polygons; std::map original_index_map; - std::vector previous_polygons; + std::vector lepox_to_next; #ifdef DEBUG { @@ -360,21 +360,21 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver unreachable_polygons.push_back(scale_down_unreachable_polygons); polygons.push_back(scale_down_object_polygon); - previous_polygons.push_back(objects_to_print[i].previous_id); + lepox_to_next.push_back(objects_to_print[i].glued_to_next); } - vector remaining_polygons; - vector polygon_index_map; - vector decided_polygons; + std::vector remaining_polygons; + std::vector polygon_index_map; + std::vector decided_polygons; for (unsigned int index = 0; index < polygons.size(); ++index) { polygon_index_map.push_back(index); } - vector poly_positions_X; - vector poly_positions_Y; - vector times_T; + std::vector poly_positions_X; + std::vector poly_positions_Y; + std::vector times_T; #ifdef DEBUG { @@ -406,7 +406,7 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver times_T, polygons, unreachable_polygons, - previous_polygons, + lepox_to_next, polygon_index_map, decided_polygons, remaining_polygons, @@ -484,28 +484,30 @@ void schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver } #endif - vector next_polygons; - vector > next_unreachable_polygons; - vector next_previous_polygons; + std::vector next_polygons; + std::vector > next_unreachable_polygons; + std::vector next_lepox_to_next; for (unsigned int i = 0; i < remaining_polygons.size(); ++i) { next_polygons.push_back(polygons[remaining_polygons[i]]); next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]); - next_previous_polygons.push_back(previous_polygons[remaining_polygons[i]]); + next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]); } - + + /* TODO: remove */ polygons.clear(); unreachable_polygons.clear(); - previous_polygons.clear(); + lepox_to_next.clear(); + polygon_index_map.clear(); polygons = next_polygons; unreachable_polygons = next_unreachable_polygons; - previous_polygons = next_previous_polygons; + lepox_to_next = next_lepox_to_next; - vector next_polygon_index_map; - map next_original_index_map; + std::vector next_polygon_index_map; + std::map next_original_index_map; for (unsigned int index = 0; index < polygons.size(); ++index) { @@ -561,9 +563,9 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_ std::vector polygons; std::vector > unreachable_polygons; - std::vector previous_polygons; + std::vector lepox_to_next; - map original_index_map; + std::map original_index_map; #ifdef DEBUG { @@ -770,7 +772,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_ } unreachable_polygons.push_back(scale_down_unreachable_polygons); - previous_polygons.push_back(objects_to_print[i].previous_id); + lepox_to_next.push_back(objects_to_print[i].glued_to_next); } vector remaining_polygons; @@ -816,7 +818,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_ times_T, polygons, unreachable_polygons, - previous_polygons, + lepox_to_next, polygon_index_map, decided_polygons, remaining_polygons, @@ -893,28 +895,30 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration &solver_ } #endif - vector next_polygons; - vector > next_unreachable_polygons; - vector next_previous_polygons; + std::vector next_polygons; + std::vector > next_unreachable_polygons; + std::vector next_lepox_to_next; for (unsigned int i = 0; i < remaining_polygons.size(); ++i) { next_polygons.push_back(polygons[remaining_polygons[i]]); next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]); - next_previous_polygons.push_back(previous_polygons[remaining_polygons[i]]); + next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]); } - + + /* TODO: remove */ polygons.clear(); unreachable_polygons.clear(); - previous_polygons.clear(); + lepox_to_next.clear(); + polygon_index_map.clear(); polygons = next_polygons; unreachable_polygons = next_unreachable_polygons; - previous_polygons = next_previous_polygons; + lepox_to_next = next_lepox_to_next; - vector next_polygon_index_map; - map next_original_index_map; + std::vector next_polygon_index_map; + std::map next_original_index_map; for (unsigned int index = 0; index < polygons.size(); ++index) { @@ -1007,7 +1011,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration std::vector > unreachable_polygons; std::map original_index_map; - std::vector previous_polygons; + std::vector lepox_to_next; #ifdef DEBUG { @@ -1109,21 +1113,21 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration scale_down_unreachable_polygons); unreachable_polygons.push_back(scale_down_unreachable_polygons); - previous_polygons.push_back(objects_to_print[i].previous_id); + lepox_to_next.push_back(objects_to_print[i].glued_to_next); } - vector remaining_polygons; - vector polygon_index_map; - vector decided_polygons; + std::vector remaining_polygons; + std::vector polygon_index_map; + std::vector decided_polygons; for (unsigned int index = 0; index < polygons.size(); ++index) { polygon_index_map.push_back(index); } - vector poly_positions_X; - vector poly_positions_Y; - vector times_T; + std::vector poly_positions_X; + std::vector poly_positions_Y; + std::vector times_T; #ifdef DEBUG { @@ -1155,7 +1159,7 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration times_T, polygons, unreachable_polygons, - previous_polygons, + lepox_to_next, polygon_index_map, decided_polygons, remaining_polygons, @@ -1235,26 +1239,28 @@ int schedule_ObjectsForSequentialPrint(const SolverConfiguration std::vector next_polygons; std::vector > next_unreachable_polygons; - std::vector next_previous_polygons; + std::vector next_lepox_to_next; for (unsigned int i = 0; i < remaining_polygons.size(); ++i) { next_polygons.push_back(polygons[remaining_polygons[i]]); next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]); - next_previous_polygons.push_back(previous_polygons[remaining_polygons[i]]); + next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]); } - + + /* TODO: remove */ polygons.clear(); unreachable_polygons.clear(); - previous_polygons.clear(); + lepox_to_next.clear(); + polygon_index_map.clear(); polygons = next_polygons; unreachable_polygons = next_unreachable_polygons; - previous_polygons = next_previous_polygons; + lepox_to_next = next_lepox_to_next; - vector next_polygon_index_map; - map next_original_index_map; + std::vector next_polygon_index_map; + std::map next_original_index_map; for (unsigned int index = 0; index < polygons.size(); ++index) { diff --git a/src/libseqarrange/src/seq_sequential.cpp b/src/libseqarrange/src/seq_sequential.cpp index 5e23a88f46..765a1e3ad4 100644 --- a/src/libseqarrange/src/seq_sequential.cpp +++ b/src/libseqarrange/src/seq_sequential.cpp @@ -341,15 +341,16 @@ void introduce_ConsequentialTemporalLepoxAgainstFixed(z3::solver const std::vector &undecided, int temporal_spread, const std::vector &SEQ_UNUSED(polygons), - const std::vector &previous_polygons) + const std::vector &lepox_to_next) { std::set fixed_(fixed.begin(), fixed.end()); std::set undecided_(undecided.begin(), undecided.end()); for (unsigned int i = 0; i < undecided.size(); ++i) { - if (previous_polygons[undecided[i]] >= 0) + if (lepox_to_next[undecided[i]]) { + /* TODO: we know what to do */ //Solver.add(dec_vars_T[previous_polygons[undecided[i]]] + temporal_spread < dec_vars_T[undecided[i]] && dec_vars_T[previous_polygons[undecided[i]]] + temporal_spread + temporal_spread / 2 > dec_vars_T[undecided[i]]); } } @@ -9939,7 +9940,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So std::vector &dec_values_T, const std::vector &polygons, const std::vector &unreachable_polygons, - const std::vector &previous_polygons, + const std::vector &lepox_to_next, const std::vector &undecided_polygons, std::vector &decided_polygons, std::vector &remaining_polygons, @@ -9961,7 +9962,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So dec_values_T, polygons, _unreachable_polygons, - previous_polygons, + lepox_to_next, undecided_polygons, decided_polygons, remaining_polygons, @@ -9982,7 +9983,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So std::vector &dec_values_T, const std::vector &polygons, const std::vector > &unreachable_polygons, - const std::vector &previous_polygons, + const std::vector &lepox_to_next, const std::vector &undecided_polygons, std::vector &decided_polygons, std::vector &remaining_polygons, @@ -10123,7 +10124,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So undecided, solver_configuration.temporal_spread, polygons, - previous_polygons); + lepox_to_next); #ifdef DEBUG { @@ -10174,7 +10175,7 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So { dec_values_X[undecided[i]] = local_values_X[undecided[i]]; dec_values_Y[undecided[i]] = local_values_Y[undecided[i]]; - dec_values_T[undecided[i]] = local_values_T[undecided[i]]; + dec_values_T[undecided[i]] = local_values_T[undecided[i]]; decided_polygons.push_back(undecided[i]); } augment_TemporalSpread(solver_configuration, dec_values_T, decided_polygons); @@ -10207,7 +10208,6 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So undecided.pop_back(); --object_group_size; - progress_callback((SEQ_PROGRESS_RANGE * (decided_polygons.size() + objects_done)) / total_objects); } diff --git a/src/libseqarrange/src/seq_sequential.hpp b/src/libseqarrange/src/seq_sequential.hpp index b880bb0fb7..9cd02f6e6b 100644 --- a/src/libseqarrange/src/seq_sequential.hpp +++ b/src/libseqarrange/src/seq_sequential.hpp @@ -64,7 +64,7 @@ const double SEQ_DECIMATION_TOLERANCE = 400000.0; const double SEQ_DECIMATION_TOLERANCE_VALUE_UNDEFINED = 0.0; const double SEQ_DECIMATION_TOLERANCE_VALUE_LOW = 150000.0; -const double SEQ_DECIMATION_TOLERANCE_VALUE_HIGH = 450000.0; +const double SEQ_DECIMATION_TOLERANCE_VALUE_HIGH = 650000.0; /*----------------------------------------------------------------*/ @@ -300,6 +300,16 @@ void introduce_ConsequentialTemporalOrderingAgainstFixed(z3::solver int temporal_spread, const std::vector &polygons); +void introduce_ConsequentialTemporalLepoxAgainstFixed(z3::solver &Solver, + z3::context &Context, + const z3::expr_vector &dec_vars_T, + std::vector &dec_values_T, + const std::vector &fixed, + const std::vector &undecided, + int temporal_spread, + const std::vector &SEQ_UNUSED(polygons), + const std::vector &lepox_to_next); + /*----------------------------------------------------------------*/ void introduce_LineNonIntersection(z3::solver &Solver, @@ -1537,13 +1547,13 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So std::vector &dec_values_T, const std::vector &polygons, const std::vector &unreachable_polygons, - const std::vector &previous_polygons, + const std::vector &lepox_to_next, const std::vector &undecided_polygons, std::vector &decided_polygons, std::vector &remaining_polygons, int objects_done, - int total_objects, - std::function progress_callback = [](int progress){}); + int total_objects, + std::function progress_callback = [](int progress){}); bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const SolverConfiguration &solver_configuration, std::vector &dec_values_X, @@ -1551,12 +1561,12 @@ bool optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(const So std::vector &dec_values_T, const std::vector &polygons, const std::vector > &unreachable_polygons, - const std::vector &previous_polygons, + const std::vector &lepox_to_next, const std::vector &undecided_polygons, std::vector &decided_polygons, std::vector &remaining_polygons, int objects_done, - int total_objects, + int total_objects, std::function progress_callback = [](int progress){}); /*----------------------------------------------------------------*/ diff --git a/src/libseqarrange/src/sequential_prusa.cpp b/src/libseqarrange/src/sequential_prusa.cpp index 9cf2e437dc..de752dfcb5 100644 --- a/src/libseqarrange/src/sequential_prusa.cpp +++ b/src/libseqarrange/src/sequential_prusa.cpp @@ -210,7 +210,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters) std::vector polygons; std::vector > unreachable_polygons; - std::vector previous_polygons; + std::vector lepox_to_next; printf(" Preparing objects ...\n"); @@ -318,7 +318,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters) scale_down_unreachable_polygons); unreachable_polygons.push_back(scale_down_unreachable_polygons); - previous_polygons.push_back(objects_to_print[i].previous_id); + lepox_to_next.push_back(objects_to_print[i].glued_to_next); } else { @@ -344,7 +344,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters) unreachable_polygons.push_back(scale_down_unreachable_polygons); polygons.push_back(scale_down_object_polygon); - previous_polygons.push_back(objects_to_print[i].previous_id); + lepox_to_next.push_back(objects_to_print[i].glued_to_next); } SVG preview_svg("sequential_prusa.svg"); @@ -397,7 +397,7 @@ int solve_SequentialPrint(const CommandParameters &command_parameters) times_T, polygons, unreachable_polygons, - previous_polygons, + lepox_to_next, polygon_index_map, decided_polygons, remaining_polygons, @@ -733,9 +733,9 @@ int solve_SequentialPrint(const CommandParameters &command_parameters) printf("All objects fit onto plate.\n"); } - vector next_polygons; - vector > next_unreachable_polygons; - vector next_previous_polygons; + std::vector next_polygons; + std::vector > next_unreachable_polygons; + std::vector next_lepox_to_next; #ifdef DEBUG { @@ -749,21 +749,22 @@ int solve_SequentialPrint(const CommandParameters &command_parameters) { next_polygons.push_back(polygons[remaining_polygons[i]]); next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]); - next_previous_polygons.push_back(previous_polygons[remaining_polygons[i]]); + next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]); } - + + /* TODO: remove */ polygons.clear(); unreachable_polygons.clear(); - previous_polygons.clear(); + lepox_to_next.clear(); + polygon_index_map.clear(); polygons = next_polygons; unreachable_polygons = next_unreachable_polygons; - previous_polygons = next_previous_polygons; + lepox_to_next = next_lepox_to_next; - vector next_polygon_index_map; - //vector next_original_index_map; - map next_original_index_map; + std::vector next_polygon_index_map; + std::map next_original_index_map; for (unsigned int index = 0; index < polygons.size(); ++index) { diff --git a/src/libseqarrange/test/seq_test_interface.cpp b/src/libseqarrange/test/seq_test_interface.cpp index 258e1678c0..2753409769 100644 --- a/src/libseqarrange/test/seq_test_interface.cpp +++ b/src/libseqarrange/test/seq_test_interface.cpp @@ -334,7 +334,7 @@ int test_interface_5(void) start = clock(); SolverConfiguration solver_configuration; - solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_HIGH; + solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_LOW; solver_configuration.object_group_size = 4; printf("Loading objects ...\n");