From dba2281f13b3003731ee38e81bfbbdee27a0d7a5 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Wed, 4 Dec 2024 17:47:10 +0100 Subject: [PATCH] [CP-SAT] more work on no_overlap_2d; revisit all includes --- .../ortools/sat/AutomatonConstraint.java | 1 + ortools/sat/2d_orthogonal_packing.cc | 2 +- ortools/sat/2d_orthogonal_packing.h | 4 +- ortools/sat/2d_orthogonal_packing_testing.cc | 2 +- ortools/sat/2d_orthogonal_packing_testing.h | 2 +- ortools/sat/2d_packing_brute_force.cc | 2 +- ortools/sat/2d_packing_brute_force.h | 2 +- ortools/sat/2d_packing_brute_force_test.cc | 2 +- ortools/sat/2d_rectangle_presolve.cc | 2 +- ortools/sat/2d_rectangle_presolve.h | 2 +- ortools/sat/2d_rectangle_presolve_test.cc | 2 +- ortools/sat/2d_try_edge_propagator.cc | 1 + ortools/sat/2d_try_edge_propagator.h | 1 + ortools/sat/2d_try_edge_propagator_test.cc | 2 +- ortools/sat/BUILD.bazel | 227 ++++---- ortools/sat/all_different.cc | 1 + ortools/sat/all_different.h | 4 +- ortools/sat/all_different_test.cc | 2 +- ortools/sat/circuit.cc | 1 + ortools/sat/circuit.h | 5 +- ortools/sat/circuit_test.cc | 1 - ortools/sat/clause.cc | 1 + ortools/sat/clause.h | 1 + ortools/sat/clause_test.cc | 1 - ortools/sat/constraint_violation_test.cc | 1 - ortools/sat/cp_constraints.cc | 1 + ortools/sat/cp_constraints.h | 5 +- ortools/sat/cp_constraints_test.cc | 2 +- ortools/sat/cp_model.h | 4 +- ortools/sat/cp_model_checker.h | 1 - ortools/sat/cp_model_expand.h | 3 - ortools/sat/cp_model_lns.cc | 2 +- ortools/sat/cp_model_lns.h | 3 +- ortools/sat/cp_model_loader.cc | 1 + ortools/sat/cp_model_loader.h | 13 +- ortools/sat/cp_model_mapping.h | 6 +- ortools/sat/cp_model_postsolve.h | 1 - ortools/sat/cp_model_presolve.cc | 1 + ortools/sat/cp_model_search.cc | 2 +- ortools/sat/cp_model_search.h | 4 +- ortools/sat/cp_model_search_test.cc | 2 - ortools/sat/cp_model_solver.cc | 3 + ortools/sat/cp_model_solver_helpers.cc | 2 + ortools/sat/cp_model_solver_helpers.h | 2 +- ortools/sat/cp_model_symmetries.h | 1 - ortools/sat/cp_model_symmetries_test.cc | 1 - ortools/sat/cp_model_table.h | 1 + ortools/sat/cumulative.cc | 1 + ortools/sat/cumulative.h | 2 +- ortools/sat/cumulative_energy.h | 2 +- ortools/sat/cumulative_test.cc | 2 +- ortools/sat/cuts.cc | 1 + ortools/sat/cuts.h | 4 +- ortools/sat/cuts_test.cc | 1 + ortools/sat/diffn.cc | 3 + ortools/sat/diffn.h | 2 - ortools/sat/diffn_cuts.cc | 1 + ortools/sat/diffn_cuts.h | 1 + ortools/sat/diffn_test.cc | 1 + ortools/sat/diffn_util.cc | 510 ++++++++++-------- ortools/sat/diffn_util.h | 17 +- ortools/sat/diffn_util_test.cc | 96 +++- ortools/sat/disjunctive.cc | 1 + ortools/sat/disjunctive.h | 9 +- ortools/sat/disjunctive_test.cc | 1 + ortools/sat/drat_checker.h | 3 +- ortools/sat/drat_proof_handler.h | 1 - ortools/sat/encoding.cc | 2 + ortools/sat/encoding.h | 6 +- ortools/sat/encoding_test.cc | 1 - ortools/sat/feasibility_jump.cc | 2 +- ortools/sat/feasibility_jump.h | 5 +- ortools/sat/feasibility_pump.cc | 1 + ortools/sat/feasibility_pump.h | 2 +- ortools/sat/feasibility_pump_test.cc | 4 +- ortools/sat/implied_bounds.cc | 2 +- ortools/sat/implied_bounds.h | 4 +- ortools/sat/implied_bounds_test.cc | 1 + ortools/sat/integer.cc | 1 + ortools/sat/integer.h | 3 - ortools/sat/integer_base.h | 6 - ortools/sat/integer_expr.cc | 6 +- ortools/sat/integer_expr.h | 3 +- ortools/sat/integer_expr_test.cc | 1 + ortools/sat/integer_search.cc | 1 + ortools/sat/integer_search.h | 2 + ortools/sat/integer_test.cc | 3 +- ortools/sat/intervals.cc | 1 + ortools/sat/intervals.h | 8 +- ortools/sat/intervals_test.cc | 3 +- ortools/sat/lb_tree_search.cc | 1 + ortools/sat/lb_tree_search.h | 5 +- ortools/sat/lb_tree_search_test.cc | 2 - ortools/sat/linear_constraint.cc | 1 + ortools/sat/linear_constraint.h | 5 + ortools/sat/linear_constraint_manager.cc | 1 + ortools/sat/linear_constraint_manager.h | 3 +- ortools/sat/linear_constraint_manager_test.cc | 2 +- ortools/sat/linear_constraint_test.cc | 2 +- ortools/sat/linear_model_test.cc | 4 - ortools/sat/linear_programming_constraint.cc | 2 +- ortools/sat/linear_programming_constraint.h | 4 +- .../sat/linear_programming_constraint_test.cc | 5 +- ortools/sat/linear_propagation.cc | 1 + ortools/sat/linear_propagation.h | 5 +- ortools/sat/linear_propagation_test.cc | 2 +- ortools/sat/linear_relaxation.cc | 1 + ortools/sat/linear_relaxation.h | 2 +- ortools/sat/linear_relaxation_test.cc | 1 + ortools/sat/lp_utils.cc | 2 +- ortools/sat/lp_utils.h | 1 - ortools/sat/max_hs.cc | 3 +- ortools/sat/max_hs.h | 2 +- ortools/sat/model.h | 2 - ortools/sat/opb_reader.h | 1 - ortools/sat/optimization.cc | 8 +- ortools/sat/optimization.h | 4 +- ortools/sat/optimization_test.cc | 9 +- ortools/sat/parameters_validation_test.cc | 1 - ortools/sat/pb_constraint.h | 1 - ortools/sat/pb_constraint_test.cc | 1 - ortools/sat/precedences.cc | 1 + ortools/sat/precedences.h | 6 +- ortools/sat/precedences_test.cc | 2 +- ortools/sat/presolve_util.cc | 1 - ortools/sat/probing.cc | 1 + ortools/sat/probing.h | 1 + ortools/sat/probing_test.cc | 3 +- ortools/sat/pseudo_costs.cc | 1 + ortools/sat/pseudo_costs.h | 3 + ortools/sat/pseudo_costs_test.cc | 3 +- ortools/sat/restart_test.cc | 2 - ortools/sat/rins.cc | 5 +- ortools/sat/rins.h | 3 - ortools/sat/routing_cuts.cc | 3 +- ortools/sat/routing_cuts.h | 3 +- ortools/sat/routing_cuts_test.cc | 5 + ortools/sat/sat_base_test.cc | 3 - ortools/sat/sat_decision.cc | 3 +- ortools/sat/sat_decision.h | 3 +- ortools/sat/sat_decision_test.cc | 1 - ortools/sat/sat_inprocessing.cc | 1 - ortools/sat/sat_inprocessing.h | 2 +- ortools/sat/sat_inprocessing_test.cc | 1 - ortools/sat/sat_solver.h | 4 - ortools/sat/scheduling_cuts.cc | 1 + ortools/sat/scheduling_cuts.h | 1 + ortools/sat/scheduling_cuts_test.cc | 1 + ortools/sat/shaving_solver.cc | 2 +- ortools/sat/shaving_solver.h | 2 +- ortools/sat/simplification.cc | 4 - ortools/sat/simplification.h | 3 - ortools/sat/stat_tables.h | 3 +- ortools/sat/subsolver.h | 2 - ortools/sat/symmetry.h | 1 + ortools/sat/synchronization.cc | 1 - ortools/sat/table.cc | 1 - ortools/sat/table.h | 3 - ortools/sat/theta_tree.cc | 2 +- ortools/sat/theta_tree.h | 4 +- ortools/sat/theta_tree_test.cc | 2 +- ortools/sat/timetable.cc | 1 + ortools/sat/timetable.h | 2 +- ortools/sat/timetable_edgefinding.cc | 1 + ortools/sat/timetable_edgefinding.h | 3 +- ortools/sat/timetable_test.cc | 1 + ortools/sat/util.cc | 5 - ortools/sat/util.h | 3 +- ortools/sat/var_domination.h | 2 +- ortools/sat/work_assignment.cc | 1 + ortools/sat/work_assignment.h | 3 +- ortools/sat/work_assignment_test.cc | 1 - ortools/sat/zero_half_cuts.cc | 2 +- ortools/sat/zero_half_cuts.h | 3 +- ortools/sat/zero_half_cuts_test.cc | 2 +- ortools/util/BUILD.bazel | 10 + ortools/util/fixed_shape_binary_tree.h | 277 ++++++++++ 177 files changed, 973 insertions(+), 582 deletions(-) create mode 100644 ortools/util/fixed_shape_binary_tree.h diff --git a/ortools/java/com/google/ortools/sat/AutomatonConstraint.java b/ortools/java/com/google/ortools/sat/AutomatonConstraint.java index 1f5d8ebb16..2eb57385eb 100644 --- a/ortools/java/com/google/ortools/sat/AutomatonConstraint.java +++ b/ortools/java/com/google/ortools/sat/AutomatonConstraint.java @@ -28,6 +28,7 @@ public class AutomatonConstraint extends Constraint { /** * Adds a transitions to the automaton. * + * @param tail the tail of the transition * @param head the head of the transition * @param label the label of the transition * @return this constraint diff --git a/ortools/sat/2d_orthogonal_packing.cc b/ortools/sat/2d_orthogonal_packing.cc index f352359832..a063fe2136 100644 --- a/ortools/sat/2d_orthogonal_packing.cc +++ b/ortools/sat/2d_orthogonal_packing.cc @@ -28,7 +28,7 @@ #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/sat/2d_packing_brute_force.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/util.h" #include "ortools/util/bitset.h" diff --git a/ortools/sat/2d_orthogonal_packing.h b/ortools/sat/2d_orthogonal_packing.h index 68bdf2a0b7..0061e7490b 100644 --- a/ortools/sat/2d_orthogonal_packing.h +++ b/ortools/sat/2d_orthogonal_packing.h @@ -14,7 +14,6 @@ #ifndef OR_TOOLS_SAT_2D_ORTHOGONAL_PACKING_H_ #define OR_TOOLS_SAT_2D_ORTHOGONAL_PACKING_H_ -#include #include #include #include @@ -23,8 +22,9 @@ #include "absl/log/check.h" #include "absl/random/bit_gen_ref.h" #include "absl/types/span.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/synchronization.h" +#include "ortools/util/bitset.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/2d_orthogonal_packing_testing.cc b/ortools/sat/2d_orthogonal_packing_testing.cc index 18b911136e..04bd9d3d20 100644 --- a/ortools/sat/2d_orthogonal_packing_testing.cc +++ b/ortools/sat/2d_orthogonal_packing_testing.cc @@ -25,7 +25,7 @@ #include "absl/random/distributions.h" #include "absl/types/span.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/2d_orthogonal_packing_testing.h b/ortools/sat/2d_orthogonal_packing_testing.h index 848e971e2f..bd47698960 100644 --- a/ortools/sat/2d_orthogonal_packing_testing.h +++ b/ortools/sat/2d_orthogonal_packing_testing.h @@ -20,7 +20,7 @@ #include "absl/random/bit_gen_ref.h" #include "absl/types/span.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/2d_packing_brute_force.cc b/ortools/sat/2d_packing_brute_force.cc index 957c8a79ca..a723679c89 100644 --- a/ortools/sat/2d_packing_brute_force.cc +++ b/ortools/sat/2d_packing_brute_force.cc @@ -26,7 +26,7 @@ #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/util/bitset.h" namespace operations_research { diff --git a/ortools/sat/2d_packing_brute_force.h b/ortools/sat/2d_packing_brute_force.h index 3a8129ca47..5a388321e3 100644 --- a/ortools/sat/2d_packing_brute_force.h +++ b/ortools/sat/2d_packing_brute_force.h @@ -19,7 +19,7 @@ #include "absl/types/span.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/2d_packing_brute_force_test.cc b/ortools/sat/2d_packing_brute_force_test.cc index 0efbbbeb27..f39f72a9f3 100644 --- a/ortools/sat/2d_packing_brute_force_test.cc +++ b/ortools/sat/2d_packing_brute_force_test.cc @@ -31,7 +31,7 @@ #include "ortools/sat/cp_model.h" #include "ortools/sat/cp_model_solver.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/2d_rectangle_presolve.cc b/ortools/sat/2d_rectangle_presolve.cc index c2246241a6..db187f5fed 100644 --- a/ortools/sat/2d_rectangle_presolve.cc +++ b/ortools/sat/2d_rectangle_presolve.cc @@ -34,7 +34,7 @@ #include "ortools/graph/max_flow.h" #include "ortools/graph/strongly_connected_components.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/2d_rectangle_presolve.h b/ortools/sat/2d_rectangle_presolve.h index a7f1c6f07e..76de6fa756 100644 --- a/ortools/sat/2d_rectangle_presolve.h +++ b/ortools/sat/2d_rectangle_presolve.h @@ -23,7 +23,7 @@ #include "absl/container/inlined_vector.h" #include "absl/types/span.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/2d_rectangle_presolve_test.cc b/ortools/sat/2d_rectangle_presolve_test.cc index 205ea18ff0..c8853644fe 100644 --- a/ortools/sat/2d_rectangle_presolve_test.cc +++ b/ortools/sat/2d_rectangle_presolve_test.cc @@ -36,7 +36,7 @@ #include "ortools/base/logging.h" #include "ortools/sat/2d_orthogonal_packing_testing.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/2d_try_edge_propagator.cc b/ortools/sat/2d_try_edge_propagator.cc index bc22209439..e0e91864b8 100644 --- a/ortools/sat/2d_try_edge_propagator.cc +++ b/ortools/sat/2d_try_edge_propagator.cc @@ -28,6 +28,7 @@ #include "ortools/base/stl_util.h" #include "ortools/sat/diffn_util.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/sat/synchronization.h" diff --git a/ortools/sat/2d_try_edge_propagator.h b/ortools/sat/2d_try_edge_propagator.h index 31bfb8d5d8..cf9f9a9070 100644 --- a/ortools/sat/2d_try_edge_propagator.h +++ b/ortools/sat/2d_try_edge_propagator.h @@ -21,6 +21,7 @@ #include "ortools/sat/diffn_util.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/sat/synchronization.h" diff --git a/ortools/sat/2d_try_edge_propagator_test.cc b/ortools/sat/2d_try_edge_propagator_test.cc index f0bf734d4b..83f8d313fc 100644 --- a/ortools/sat/2d_try_edge_propagator_test.cc +++ b/ortools/sat/2d_try_edge_propagator_test.cc @@ -28,7 +28,7 @@ #include "ortools/base/gmock.h" #include "ortools/sat/2d_orthogonal_packing_testing.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/BUILD.bazel b/ortools/sat/BUILD.bazel index 78866cd780..cf332aa889 100644 --- a/ortools/sat/BUILD.bazel +++ b/ortools/sat/BUILD.bazel @@ -193,7 +193,6 @@ cc_library( ":diffn_util", ":sat_parameters_cc_proto", "//ortools/base", - "//ortools/base:types", "//ortools/port:proto_utils", "//ortools/util:saturated_arithmetic", "//ortools/util:sorted_interval_list", @@ -271,7 +270,7 @@ cc_library( ":cp_model_cc_proto", ":cp_model_checker", ":cp_model_utils", - ":integer", + ":integer_base", ":linear_model", ":restart", ":sat_parameters_cc_proto", @@ -286,7 +285,6 @@ cc_library( "@com_google_absl//absl/functional:any_invocable", "@com_google_absl//absl/functional:bind_front", "@com_google_absl//absl/functional:function_ref", - "@com_google_absl//absl/hash", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/random:bit_gen_ref", @@ -327,15 +325,10 @@ cc_test( srcs = ["linear_model_test.cc"], deps = [ ":cp_model_cc_proto", - ":cp_model_presolve", ":linear_model", - ":model", - ":presolve_context", ":sat_parameters_cc_proto", "//ortools/base:gmock_main", "//ortools/base:parse_test_proto", - "//ortools/util:logging", - "@com_google_absl//absl/log", ], ) @@ -371,6 +364,7 @@ cc_library( ":cp_model_mapping", ":cp_model_utils", ":integer", + ":integer_base", ":integer_search", ":linear_propagation", ":model", @@ -378,11 +372,10 @@ cc_library( ":sat_parameters_cc_proto", ":util", "//ortools/base", - "//ortools/base:types", + "//ortools/base:stl_util", "//ortools/util:strong_integers", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", - "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/log:check", "@com_google_absl//absl/random:distributions", "@com_google_absl//absl/strings", @@ -396,7 +389,6 @@ cc_test( srcs = ["cp_model_search_test.cc"], deps = [ ":cp_model_cc_proto", - ":cp_model_search", ":cp_model_solver", ":model", ":sat_parameters_cc_proto", @@ -426,6 +418,7 @@ cc_library( ":feasibility_pump", ":implied_bounds", ":integer", + ":integer_base", ":integer_expr", ":integer_search", ":intervals", @@ -501,7 +494,7 @@ cc_library( ":cp_model_presolve", ":cp_model_solver_helpers", ":cp_model_utils", - ":integer", + ":integer_base", ":model", ":presolve_context", ":sat_parameters_cc_proto", @@ -544,6 +537,7 @@ cc_library( ":feasibility_pump", ":implied_bounds", ":integer", + ":integer_base", ":integer_expr", ":integer_search", ":intervals", @@ -617,16 +611,14 @@ cc_library( ":cp_model_utils", ":integer_base", ":intervals", + ":linear_constraint", ":model", ":sat_base", "//ortools/base", "//ortools/base:strong_vector", - "//ortools/base:types", "//ortools/util:strong_integers", - "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/log:check", - "@com_google_absl//absl/meta:type_traits", ], ) @@ -646,6 +638,7 @@ cc_library( ":disjunctive", ":implied_bounds", ":integer", + ":integer_base", ":integer_expr", ":intervals", ":linear_constraint", @@ -867,6 +860,7 @@ cc_library( ":diophantine", ":inclusion", ":integer", + ":integer_base", ":model", ":presolve_context", ":presolve_util", @@ -944,7 +938,6 @@ cc_library( ":cp_model_cc_proto", ":cp_model_utils", "//ortools/base", - "//ortools/base:types", "//ortools/port:proto_utils", "//ortools/util:logging", "//ortools/util:sorted_interval_list", @@ -1045,7 +1038,6 @@ cc_test( deps = [ ":sat_base", "//ortools/base:gmock_main", - "//ortools/util:strong_integers", ], ) @@ -1071,10 +1063,8 @@ cc_library( ":sat_parameters_cc_proto", ":util", "//ortools/base", - "//ortools/base:hash", "//ortools/base:stl_util", "//ortools/base:timer", - "//ortools/base:types", "//ortools/port:proto_utils", "//ortools/port:sysinfo", "//ortools/util:bitset", @@ -1083,10 +1073,10 @@ cc_library( "//ortools/util:stats", "//ortools/util:strong_integers", "//ortools/util:time_limit", - "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:btree", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/meta:type_traits", "@com_google_absl//absl/strings", @@ -1134,6 +1124,7 @@ cc_library( ":clause", ":implied_bounds", ":integer", + ":integer_base", ":model", ":sat_base", ":sat_parameters_cc_proto", @@ -1162,6 +1153,7 @@ cc_test( srcs = ["probing_test.cc"], deps = [ ":integer", + ":integer_base", ":model", ":probing", ":sat_base", @@ -1198,9 +1190,8 @@ cc_library( "//ortools/util:time_limit", "@com_google_absl//absl/cleanup", "@com_google_absl//absl/container:inlined_vector", + "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", - "@com_google_absl//absl/random:distributions", - "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", ], ) @@ -1228,18 +1219,17 @@ cc_library( hdrs = ["sat_decision.h"], deps = [ ":model", - ":pb_constraint", ":sat_base", ":sat_parameters_cc_proto", ":synchronization", ":util", "//ortools/base", "//ortools/base:strong_vector", - "//ortools/base:types", "//ortools/util:bitset", "//ortools/util:integer_pq", "//ortools/util:strong_integers", "@com_google_absl//absl/log:check", + "@com_google_absl//absl/types:span", ], ) @@ -1254,7 +1244,6 @@ cc_test( ":sat_parameters_cc_proto", ":sat_solver", "//ortools/base:gmock_main", - "//ortools/util:strong_integers", "@com_google_absl//absl/random", ], ) @@ -1316,10 +1305,7 @@ cc_library( hdrs = ["simplification.h"], deps = [ ":drat_proof_handler", - ":model", - ":probing", ":sat_base", - ":sat_inprocessing", ":sat_parameters_cc_proto", ":sat_solver", "//ortools/algorithms:dynamic_partition", @@ -1328,12 +1314,12 @@ cc_library( "//ortools/base:stl_util", "//ortools/base:strong_vector", "//ortools/base:timer", - "//ortools/base:types", "//ortools/graph:strongly_connected_components", "//ortools/util:logging", "//ortools/util:strong_integers", "//ortools/util:time_limit", "@com_google_absl//absl/container:btree", + "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/types:span", ], @@ -1349,7 +1335,6 @@ cc_library( ":sat_parameters_cc_proto", "//ortools/base", "//ortools/base:strong_vector", - "//ortools/base:types", "//ortools/util:bitset", "//ortools/util:saturated_arithmetic", "//ortools/util:stats", @@ -1443,7 +1428,6 @@ cc_library( deps = [ ":cp_model_cc_proto", ":cp_model_utils", - ":integer", ":integer_base", ":presolve_context", ":presolve_util", @@ -1486,20 +1470,13 @@ cc_library( name = "integer_base", hdrs = ["integer_base.h"], deps = [ - ":model", ":sat_base", "//ortools/base", "//ortools/base:strong_vector", "//ortools/util:saturated_arithmetic", "//ortools/util:sorted_interval_list", "//ortools/util:strong_integers", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/cleanup", - "@com_google_absl//absl/container:btree", - "@com_google_absl//absl/container:flat_hash_map", - "@com_google_absl//absl/container:inlined_vector", "@com_google_absl//absl/log:check", - "@com_google_absl//absl/meta:type_traits", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", ], @@ -1545,6 +1522,7 @@ cc_library( ":cp_model_mapping", ":implied_bounds", ":integer", + ":integer_base", ":intervals", ":linear_constraint_manager", ":linear_programming_constraint", @@ -1564,6 +1542,7 @@ cc_library( "//ortools/util:strong_integers", "//ortools/util:time_limit", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/meta:type_traits", "@com_google_absl//absl/random:distributions", @@ -1579,6 +1558,7 @@ cc_library( deps = [ ":cp_model_mapping", ":integer", + ":integer_base", ":integer_expr", ":integer_search", ":linear_programming_constraint", @@ -1592,13 +1572,13 @@ cc_library( ":util", "//ortools/base", "//ortools/base:strong_vector", + "//ortools/glop:variables_info", "//ortools/util:strong_integers", "//ortools/util:time_limit", "@com_google_absl//absl/cleanup", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", - "@com_google_absl//absl/time", "@com_google_absl//absl/types:span", ], ) @@ -1611,7 +1591,6 @@ cc_test( ":cp_model_cc_proto", ":cp_model_solver", ":cp_model_test_utils", - ":lb_tree_search", ":sat_parameters_cc_proto", "//ortools/base:gmock_main", ], @@ -1624,6 +1603,7 @@ cc_library( deps = [ ":cp_model_mapping", ":integer", + ":integer_base", ":linear_constraint_manager", ":linear_programming_constraint", ":model", @@ -1644,7 +1624,9 @@ cc_test( size = "small", srcs = ["pseudo_costs_test.cc"], deps = [ + ":cp_model_mapping", ":integer", + ":integer_base", ":model", ":pseudo_costs", ":sat_base", @@ -1660,19 +1642,19 @@ cc_library( srcs = ["intervals.cc"], hdrs = ["intervals.h"], deps = [ - ":cp_constraints", + ":clause", ":implied_bounds", ":integer", + ":integer_base", ":integer_expr", ":linear_constraint", ":model", - ":pb_constraint", ":precedences", ":sat_base", ":sat_solver", "//ortools/base", "//ortools/base:strong_vector", - "//ortools/util:rev", + "//ortools/util:bitset", "//ortools/util:sort", "//ortools/util:strong_integers", "@com_google_absl//absl/base:core_headers", @@ -1690,13 +1672,13 @@ cc_test( srcs = ["intervals_test.cc"], deps = [ ":integer", + ":integer_base", ":intervals", ":linear_constraint", ":model", ":sat_base", ":sat_solver", "//ortools/base:gmock_main", - "//ortools/util:strong_integers", ], ) @@ -1708,6 +1690,7 @@ cc_library( ":clause", ":cp_constraints", ":integer", + ":integer_base", ":model", ":sat_base", ":sat_solver", @@ -1716,11 +1699,11 @@ cc_library( "//ortools/base", "//ortools/base:stl_util", "//ortools/base:strong_vector", - "//ortools/base:types", "//ortools/graph", "//ortools/graph:topologicalsorter", "//ortools/util:bitset", "//ortools/util:logging", + "//ortools/util:rev", "//ortools/util:strong_integers", "//ortools/util:time_limit", "@com_google_absl//absl/cleanup", @@ -1728,9 +1711,9 @@ cc_library( "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/container:inlined_vector", + "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/meta:type_traits", - "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", ], ) @@ -1741,15 +1724,14 @@ cc_test( srcs = ["precedences_test.cc"], deps = [ ":integer", + ":integer_base", ":integer_search", ":model", ":precedences", ":sat_base", ":sat_solver", "//ortools/base:gmock_main", - "//ortools/base:types", "//ortools/util:sorted_interval_list", - "//ortools/util:strong_integers", "@com_google_absl//absl/types:span", ], ) @@ -1760,13 +1742,13 @@ cc_test( srcs = ["integer_test.cc"], deps = [ ":integer", + ":integer_base", ":integer_search", ":model", ":sat_base", ":sat_solver", "//ortools/base", "//ortools/base:gmock_main", - "//ortools/base:types", "//ortools/util:sorted_interval_list", "//ortools/util:strong_integers", "@com_google_absl//absl/log:check", @@ -1781,6 +1763,7 @@ cc_library( hdrs = ["integer_expr.h"], deps = [ ":integer", + ":integer_base", ":linear_constraint", ":linear_propagation", ":model", @@ -1791,11 +1774,9 @@ cc_library( ":util", "//ortools/base", "//ortools/base:mathutil", - "//ortools/base:stl_util", - "//ortools/util:sorted_interval_list", "//ortools/util:strong_integers", "//ortools/util:time_limit", - "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/numeric:int128", "@com_google_absl//absl/types:span", @@ -1812,6 +1793,7 @@ cc_test( ":cp_model_cc_proto", ":cp_model_utils", ":integer", + ":integer_base", ":integer_expr", ":linear_constraint", ":model", @@ -1840,6 +1822,7 @@ cc_library( hdrs = ["linear_propagation.h"], deps = [ ":integer", + ":integer_base", ":model", ":precedences", ":sat_base", @@ -1872,6 +1855,7 @@ cc_test( srcs = ["linear_propagation_test.cc"], deps = [ ":integer", + ":integer_base", ":linear_propagation", ":model", ":sat_base", @@ -1889,16 +1873,15 @@ cc_library( hdrs = ["all_different.h"], deps = [ ":integer", + ":integer_base", ":model", ":sat_base", ":sat_solver", "//ortools/base", - "//ortools/base:types", "//ortools/graph:strongly_connected_components", "//ortools/util:sort", "//ortools/util:strong_integers", "@com_google_absl//absl/container:btree", - "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log:check", "@com_google_absl//absl/types:span", ], @@ -1910,12 +1893,12 @@ cc_test( deps = [ ":all_different", ":integer", + ":integer_base", ":integer_search", ":model", ":sat_solver", "//ortools/base", "//ortools/base:gmock_main", - "//ortools/base:types", "//ortools/util:sorted_interval_list", ], ) @@ -1925,8 +1908,7 @@ cc_library( srcs = ["theta_tree.cc"], hdrs = ["theta_tree.h"], deps = [ - ":integer", - "//ortools/base", + ":integer_base", "@com_google_absl//absl/log:check", ], ) @@ -1936,7 +1918,7 @@ cc_test( size = "small", srcs = ["theta_tree_test.cc"], deps = [ - ":integer", + ":integer_base", ":theta_tree", "//ortools/base:gmock_main", "//ortools/util:random_engine", @@ -1952,21 +1934,22 @@ cc_library( deps = [ ":all_different", ":integer", - ":integer_expr", + ":integer_base", ":intervals", ":model", ":precedences", ":sat_base", ":sat_parameters_cc_proto", - ":sat_solver", + ":synchronization", ":theta_tree", ":timetable", - "//ortools/base", + ":util", "//ortools/util:sort", "//ortools/util:strong_integers", "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", + "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", ], ) @@ -1978,6 +1961,7 @@ cc_test( deps = [ ":disjunctive", ":integer", + ":integer_base", ":integer_search", ":intervals", ":model", @@ -2001,10 +1985,10 @@ cc_library( hdrs = ["timetable.h"], deps = [ ":integer", + ":integer_base", ":intervals", ":model", ":sat_base", - "//ortools/util:rev", "//ortools/util:strong_integers", "@com_google_absl//absl/log:check", "@com_google_absl//absl/types:span", @@ -2019,6 +2003,7 @@ cc_test( ":all_different", ":cumulative", ":integer", + ":integer_base", ":integer_search", ":intervals", ":model", @@ -2041,9 +2026,9 @@ cc_library( hdrs = ["timetable_edgefinding.h"], deps = [ ":integer", + ":integer_base", ":intervals", ":model", - ":sat_base", "//ortools/base:iterator_adaptors", "//ortools/util:strong_integers", "@com_google_absl//absl/log:check", @@ -2058,6 +2043,7 @@ cc_library( ":cumulative_energy", ":disjunctive", ":integer", + ":integer_base", ":integer_expr", ":intervals", ":linear_constraint", @@ -2085,6 +2071,7 @@ cc_test( deps = [ ":cumulative", ":integer", + ":integer_base", ":integer_search", ":intervals", ":model", @@ -2093,7 +2080,6 @@ cc_test( ":sat_solver", "//ortools/base", "//ortools/base:gmock_main", - "//ortools/util:strong_integers", "@com_google_absl//absl/log:check", "@com_google_absl//absl/random", "@com_google_absl//absl/strings", @@ -2224,6 +2210,7 @@ cc_library( ":diffn_cuts", ":implied_bounds", ":integer", + ":integer_base", ":integer_expr", ":intervals", ":linear_constraint", @@ -2263,6 +2250,7 @@ cc_test( ":cp_model_loader", ":cp_model_mapping", ":integer", + ":integer_base", ":intervals", ":linear_constraint", ":linear_relaxation", @@ -2282,6 +2270,7 @@ cc_library( hdrs = ["linear_constraint.h"], deps = [ ":integer", + ":integer_base", ":model", ":sat_base", "//ortools/base:mathutil", @@ -2301,6 +2290,7 @@ cc_test( srcs = ["linear_constraint_test.cc"], deps = [ ":integer", + ":integer_base", ":linear_constraint", ":model", ":sat_base", @@ -2321,6 +2311,7 @@ cc_library( ":cuts", ":implied_bounds", ":integer", + ":integer_base", ":integer_expr", ":linear_constraint", ":linear_constraint_manager", @@ -2340,7 +2331,6 @@ cc_library( "//ortools/glop:revised_simplex", "//ortools/glop:status", "//ortools/glop:variables_info", - "//ortools/lp_data", "//ortools/lp_data:base", "//ortools/lp_data:lp_data_utils", "//ortools/lp_data:scattered_vector", @@ -2367,6 +2357,7 @@ cc_test( deps = [ ":cp_model_solver", ":integer", + ":integer_base", ":integer_search", ":linear_constraint", ":linear_constraint_manager", @@ -2375,11 +2366,9 @@ cc_test( ":sat_parameters_cc_proto", ":sat_solver", "//ortools/base:gmock_main", - "//ortools/base:mathutil", "//ortools/lp_data:base", "//ortools/util:strong_integers", "@com_google_absl//absl/log:check", - "@com_google_absl//absl/random", "@com_google_absl//absl/types:span", ], ) @@ -2390,6 +2379,7 @@ cc_library( hdrs = ["linear_constraint_manager.h"], deps = [ ":integer", + ":integer_base", ":linear_constraint", ":model", ":sat_parameters_cc_proto", @@ -2400,7 +2390,6 @@ cc_library( "//ortools/base:strong_vector", "//ortools/glop:variables_info", "//ortools/lp_data:base", - "//ortools/util:logging", "//ortools/util:saturated_arithmetic", "//ortools/util:strong_integers", "//ortools/util:time_limit", @@ -2419,10 +2408,10 @@ cc_test( srcs = ["linear_constraint_manager_test.cc"], deps = [ ":integer", + ":integer_base", ":linear_constraint", ":linear_constraint_manager", ":model", - ":sat_base", ":sat_parameters_cc_proto", "//ortools/base:gmock_main", "//ortools/base:strong_vector", @@ -2440,6 +2429,7 @@ cc_library( ":clause", ":implied_bounds", ":integer", + ":integer_base", ":linear_constraint", ":linear_constraint_manager", ":model", @@ -2472,6 +2462,7 @@ cc_test( ":cuts", ":implied_bounds", ":integer", + ":integer_base", ":linear_constraint", ":linear_constraint_manager", ":model", @@ -2496,6 +2487,7 @@ cc_library( ":cp_model_cc_proto", ":cuts", ":integer", + ":integer_base", ":linear_constraint", ":linear_constraint_manager", ":model", @@ -2507,7 +2499,7 @@ cc_library( "//ortools/graph:max_flow", "//ortools/util:strong_integers", "@com_google_absl//absl/cleanup", - "@com_google_absl//absl/container:inlined_vector", + "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", @@ -2520,6 +2512,7 @@ cc_test( deps = [ ":cuts", ":integer", + ":integer_base", ":linear_constraint", ":linear_constraint_manager", ":model", @@ -2529,6 +2522,9 @@ cc_test( "//ortools/base:strong_vector", "//ortools/graph:max_flow", "//ortools/util:strong_integers", + "@com_google_absl//absl/log", + "@com_google_absl//absl/random", + "@com_google_absl//absl/random:distributions", "@com_google_absl//absl/types:span", ], ) @@ -2539,8 +2535,8 @@ cc_library( hdrs = ["scheduling_cuts.h"], deps = [ ":cuts", - ":implied_bounds", ":integer", + ":integer_base", ":intervals", ":linear_constraint", ":linear_constraint_manager", @@ -2550,7 +2546,6 @@ cc_library( "//ortools/base", "//ortools/base:stl_util", "//ortools/base:strong_vector", - "//ortools/util:saturated_arithmetic", "//ortools/util:sorted_interval_list", "//ortools/util:strong_integers", "//ortools/util:time_limit", @@ -2572,6 +2567,7 @@ cc_test( ":cp_model_solver", ":cuts", ":integer", + ":integer_base", ":intervals", ":linear_constraint", ":linear_constraint_manager", @@ -2596,6 +2592,7 @@ cc_library( ":diffn_util", ":implied_bounds", ":integer", + ":integer_base", ":intervals", ":linear_constraint", ":linear_constraint_manager", @@ -2617,7 +2614,7 @@ cc_library( srcs = ["zero_half_cuts.cc"], hdrs = ["zero_half_cuts.h"], deps = [ - ":integer", + ":integer_base", ":util", "//ortools/base", "//ortools/lp_data:base", @@ -2631,7 +2628,7 @@ cc_test( name = "zero_half_cuts_test", srcs = ["zero_half_cuts_test.cc"], deps = [ - ":integer", + ":integer_base", ":zero_half_cuts", "//ortools/base:gmock_main", "//ortools/lp_data:base", @@ -2647,9 +2644,8 @@ cc_library( ":boolean_problem_cc_proto", ":cp_model_cc_proto", ":cp_model_utils", - ":integer", + ":integer_base", ":sat_parameters_cc_proto", - ":sat_solver", "//ortools/base", "//ortools/base:strong_vector", "//ortools/glop:lp_solver", @@ -2673,12 +2669,11 @@ cc_library( srcs = ["optimization.cc"], hdrs = ["optimization.h"], deps = [ - ":boolean_problem", ":boolean_problem_cc_proto", ":clause", - ":cp_model_mapping", ":encoding", ":integer", + ":integer_base", ":integer_expr", ":integer_search", ":model", @@ -2691,16 +2686,14 @@ cc_library( "//ortools/base", "//ortools/base:stl_util", "//ortools/base:strong_vector", - "//ortools/port:proto_utils", "//ortools/util:sorted_interval_list", "//ortools/util:strong_integers", "//ortools/util:time_limit", "@com_google_absl//absl/cleanup", "@com_google_absl//absl/container:btree", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", - "@com_google_absl//absl/random", - "@com_google_absl//absl/random:bit_gen_ref", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:span", @@ -2718,6 +2711,7 @@ cc_library( ":cp_model_utils", ":encoding", ":integer", + ":integer_base", ":integer_expr", ":integer_search", ":linear_constraint", @@ -2757,9 +2751,9 @@ cc_test( name = "optimization_test", srcs = ["optimization_test.cc"], deps = [ - ":boolean_problem", ":boolean_problem_cc_proto", ":integer", + ":integer_base", ":integer_search", ":model", ":optimization", @@ -2768,11 +2762,6 @@ cc_test( ":sat_parameters_cc_proto", ":sat_solver", "//ortools/base:gmock_main", - "//ortools/util:strong_integers", - "@com_google_absl//absl/log:check", - "@com_google_absl//absl/random:bit_gen_ref", - "@com_google_absl//absl/random:distributions", - "@com_google_absl//absl/strings:str_format", ], ) @@ -2848,6 +2837,7 @@ cc_library( ":util", "//ortools/lp_data:base", "//ortools/util:logging", + "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:btree", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", @@ -2860,12 +2850,9 @@ cc_library( srcs = ["table.cc"], hdrs = ["table.h"], deps = [ - ":integer", ":model", ":sat_base", ":sat_solver", - "//ortools/base:types", - "//ortools/util:strong_integers", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log:check", "@com_google_absl//absl/types:span", @@ -2900,11 +2887,10 @@ cc_library( hdrs = ["cp_constraints.h"], deps = [ ":integer", + ":integer_base", ":model", ":sat_base", "//ortools/base", - "//ortools/base:types", - "//ortools/util:rev", "//ortools/util:strong_integers", "@com_google_absl//absl/log:check", "@com_google_absl//absl/types:span", @@ -2917,6 +2903,7 @@ cc_test( deps = [ ":cp_constraints", ":integer", + ":integer_base", ":integer_search", ":model", ":precedences", @@ -2933,25 +2920,28 @@ cc_library( srcs = ["diffn_util.cc"], hdrs = ["diffn_util.h"], deps = [ - ":integer", + ":integer_base", ":intervals", ":util", "//ortools/base", "//ortools/base:stl_util", + "//ortools/base:strong_vector", "//ortools/graph", + "//ortools/graph:connected_components", "//ortools/graph:minimum_spanning_tree", "//ortools/graph:strongly_connected_components", + "//ortools/util:fixed_shape_binary_tree", "//ortools/util:integer_pq", "//ortools/util:strong_integers", - "@com_google_absl//absl/container:btree", + "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/container:inlined_vector", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/random:bit_gen_ref", - "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", + "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", ], ) @@ -2962,7 +2952,7 @@ cc_library( hdrs = ["2d_orthogonal_packing.h"], deps = [ ":2d_packing_brute_force", - ":integer", + ":integer_base", ":synchronization", ":util", "//ortools/util:bitset", @@ -2981,7 +2971,7 @@ cc_library( hdrs = ["2d_packing_brute_force.h"], deps = [ ":diffn_util", - ":integer", + ":integer_base", "//ortools/util:bitset", "@com_google_absl//absl/container:inlined_vector", "@com_google_absl//absl/log", @@ -2999,7 +2989,7 @@ cc_test( ":cp_model", ":cp_model_solver", ":diffn_util", - ":integer", + ":integer_base", "//ortools/base:gmock_main", "@com_google_absl//absl/log:check", "@com_google_absl//absl/random", @@ -3016,7 +3006,7 @@ cc_library( hdrs = ["2d_rectangle_presolve.h"], deps = [ ":diffn_util", - ":integer", + ":integer_base", "//ortools/base:stl_util", "//ortools/graph:max_flow", "//ortools/graph:strongly_connected_components", @@ -3039,7 +3029,7 @@ cc_test( ":2d_orthogonal_packing_testing", ":2d_rectangle_presolve", ":diffn_util", - ":integer", + ":integer_base", "//ortools/base:gmock_main", "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/container:flat_hash_map", @@ -3060,7 +3050,7 @@ cc_library( hdrs = ["2d_orthogonal_packing_testing.h"], deps = [ ":diffn_util", - ":integer", + ":integer_base", "@com_google_absl//absl/log:check", "@com_google_absl//absl/random:bit_gen_ref", "@com_google_absl//absl/random:distributions", @@ -3075,6 +3065,7 @@ cc_library( deps = [ ":diffn_util", ":integer", + ":integer_base", ":intervals", ":model", ":synchronization", @@ -3097,7 +3088,7 @@ cc_test( ":2d_orthogonal_packing_testing", ":2d_try_edge_propagator", ":diffn_util", - ":integer", + ":integer_base", ":intervals", ":model", "//ortools/base:gmock_main", @@ -3115,7 +3106,8 @@ cc_test( deps = [ ":2d_orthogonal_packing_testing", ":diffn_util", - ":integer", + ":integer_base", + ":util", "//ortools/base", "//ortools/base:gmock_main", "//ortools/graph:connected_components", @@ -3144,6 +3136,7 @@ cc_library( ":diffn_util", ":disjunctive", ":integer", + ":integer_base", ":integer_expr", ":intervals", ":linear_constraint", @@ -3160,6 +3153,7 @@ cc_library( "@com_google_absl//absl/container:inlined_vector", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", + "@com_google_absl//absl/numeric:bits", "@com_google_absl//absl/types:span", ], ) @@ -3174,6 +3168,7 @@ cc_test( ":cp_model_solver", ":diffn", ":integer", + ":integer_base", ":integer_search", ":intervals", ":model", @@ -3191,12 +3186,13 @@ cc_library( srcs = ["circuit.cc"], hdrs = ["circuit.h"], deps = [ + ":clause", ":integer", ":model", ":sat_base", ":sat_solver", + ":util", "//ortools/base", - "//ortools/base:types", "//ortools/graph:strongly_connected_components", "//ortools/util:rev", "//ortools/util:strong_integers", @@ -3232,14 +3228,17 @@ cc_library( hdrs = ["encoding.h"], deps = [ ":boolean_problem_cc_proto", + ":clause", + ":model", ":pb_constraint", ":sat_base", ":sat_parameters_cc_proto", ":sat_solver", + ":util", "//ortools/base", "//ortools/base:stl_util", - "//ortools/base:types", "//ortools/util:strong_integers", + "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", @@ -3270,7 +3269,7 @@ cc_library( ":cp_model_solver_helpers", ":cp_model_utils", ":diffn_util", - ":integer", + ":integer_base", ":linear_constraint_manager", ":model", ":presolve_context", @@ -3311,6 +3310,7 @@ cc_library( deps = [ ":cp_model_mapping", ":integer", + ":integer_base", ":linear_constraint", ":model", ":sat_base", @@ -3347,9 +3347,9 @@ cc_test( ":cp_model_mapping", ":feasibility_pump", ":integer", + ":integer_base", ":linear_constraint", ":model", - ":sat_base", ":sat_parameters_cc_proto", ":sat_solver", "//ortools/base:gmock_main", @@ -3362,14 +3362,14 @@ cc_library( hdrs = ["rins.h"], deps = [ ":cp_model_mapping", - ":integer", - ":linear_programming_constraint", + ":integer_base", + ":linear_constraint_manager", ":model", ":synchronization", - "//ortools/util:strong_integers", "@com_google_absl//absl/log:check", "@com_google_absl//absl/random:bit_gen_ref", "@com_google_absl//absl/random:distributions", + "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", ], ) @@ -3627,6 +3627,7 @@ cc_library( "linear_constraint", ":clause", ":integer", + ":integer_base", ":model", ":sat_base", ":sat_parameters_cc_proto", @@ -3634,7 +3635,6 @@ cc_library( ":synchronization", "//ortools/base", "//ortools/base:strong_vector", - "//ortools/base:types", "//ortools/lp_data:base", "//ortools/util:bitset", "//ortools/util:sorted_interval_list", @@ -3642,9 +3642,9 @@ cc_library( "@com_google_absl//absl/container:btree", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/meta:type_traits", - "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", ], ) @@ -3656,6 +3656,7 @@ cc_test( deps = [ ":implied_bounds", ":integer", + ":integer_base", ":linear_constraint", ":model", ":sat_base", @@ -3704,6 +3705,7 @@ cc_library( ":cp_model_mapping", ":cp_model_utils", ":integer", + ":integer_base", ":integer_search", ":model", ":restart", @@ -3737,7 +3739,6 @@ cc_test( ":cp_model_checker", ":cp_model_loader", ":cp_model_solver", - ":integer", ":model", ":sat_parameters_cc_proto", ":synchronization", diff --git a/ortools/sat/all_different.cc b/ortools/sat/all_different.cc index 739b8870f6..f6e69476fd 100644 --- a/ortools/sat/all_different.cc +++ b/ortools/sat/all_different.cc @@ -26,6 +26,7 @@ #include "ortools/base/logging.h" #include "ortools/graph/strongly_connected_components.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/all_different.h b/ortools/sat/all_different.h index 094eea1667..88fa8a185f 100644 --- a/ortools/sat/all_different.h +++ b/ortools/sat/all_different.h @@ -16,15 +16,13 @@ #include #include -#include #include -#include "absl/container/flat_hash_map.h" #include "absl/log/check.h" #include "absl/types/span.h" #include "ortools/base/logging.h" -#include "ortools/base/types.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/all_different_test.cc b/ortools/sat/all_different_test.cc index bdc91b6090..3bdc4212ef 100644 --- a/ortools/sat/all_different_test.cc +++ b/ortools/sat/all_different_test.cc @@ -22,8 +22,8 @@ #include "gtest/gtest.h" #include "ortools/base/logging.h" -#include "ortools/base/types.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/circuit.cc b/ortools/sat/circuit.cc index b28ab8e41b..5208f52c39 100644 --- a/ortools/sat/circuit.cc +++ b/ortools/sat/circuit.cc @@ -24,6 +24,7 @@ #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/graph/strongly_connected_components.h" +#include "ortools/sat/clause.h" #include "ortools/sat/integer.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/circuit.h b/ortools/sat/circuit.h index 1935007f19..74f49c9961 100644 --- a/ortools/sat/circuit.h +++ b/ortools/sat/circuit.h @@ -15,21 +15,18 @@ #define OR_TOOLS_SAT_CIRCUIT_H_ #include -#include #include #include #include "absl/container/btree_set.h" #include "absl/container/flat_hash_map.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" -#include "ortools/base/types.h" #include "ortools/graph/strongly_connected_components.h" #include "ortools/sat/integer.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" +#include "ortools/sat/util.h" #include "ortools/util/rev.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/circuit_test.cc b/ortools/sat/circuit_test.cc index d6d3cf98f4..1e20af506c 100644 --- a/ortools/sat/circuit_test.cc +++ b/ortools/sat/circuit_test.cc @@ -17,7 +17,6 @@ #include #include #include -#include #include #include diff --git a/ortools/sat/clause.cc b/ortools/sat/clause.cc index 0ba2f8b205..305821ff6a 100644 --- a/ortools/sat/clause.cc +++ b/ortools/sat/clause.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/ortools/sat/clause.h b/ortools/sat/clause.h index ad45541443..8bbac1afe3 100644 --- a/ortools/sat/clause.h +++ b/ortools/sat/clause.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/ortools/sat/clause_test.cc b/ortools/sat/clause_test.cc index 23d084c0df..c950e6bb92 100644 --- a/ortools/sat/clause_test.cc +++ b/ortools/sat/clause_test.cc @@ -16,7 +16,6 @@ #include #include #include -#include #include #include "absl/container/flat_hash_set.h" diff --git a/ortools/sat/constraint_violation_test.cc b/ortools/sat/constraint_violation_test.cc index 6b9e468c45..62796f6a25 100644 --- a/ortools/sat/constraint_violation_test.cc +++ b/ortools/sat/constraint_violation_test.cc @@ -14,7 +14,6 @@ #include "ortools/sat/constraint_violation.h" #include -#include #include #include "absl/types/span.h" diff --git a/ortools/sat/cp_constraints.cc b/ortools/sat/cp_constraints.cc index 918a771ea0..6664e2ee4d 100644 --- a/ortools/sat/cp_constraints.cc +++ b/ortools/sat/cp_constraints.cc @@ -18,6 +18,7 @@ #include "absl/types/span.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/cp_constraints.h b/ortools/sat/cp_constraints.h index 7e07c4d83f..9af0c9f185 100644 --- a/ortools/sat/cp_constraints.h +++ b/ortools/sat/cp_constraints.h @@ -16,18 +16,15 @@ #include #include -#include #include #include "absl/log/check.h" #include "absl/types/span.h" #include "ortools/base/logging.h" -#include "ortools/base/types.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" -#include "ortools/util/rev.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/cp_constraints_test.cc b/ortools/sat/cp_constraints_test.cc index bceee075ad..c88ebc279b 100644 --- a/ortools/sat/cp_constraints_test.cc +++ b/ortools/sat/cp_constraints_test.cc @@ -15,13 +15,13 @@ #include -#include #include #include "absl/types/span.h" #include "gtest/gtest.h" #include "ortools/base/logging.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" #include "ortools/sat/precedences.h" diff --git a/ortools/sat/cp_model.h b/ortools/sat/cp_model.h index eab648c105..8dd8fb1160 100644 --- a/ortools/sat/cp_model.h +++ b/ortools/sat/cp_model.h @@ -51,9 +51,9 @@ #include "absl/strings/string_view.h" #include "absl/types/span.h" #include "ortools/sat/cp_model.pb.h" -#include "ortools/sat/cp_model_solver.h" +#include "ortools/sat/cp_model_solver.h" // IWYU pragma: export. #include "ortools/sat/cp_model_utils.h" -#include "ortools/sat/model.h" +#include "ortools/sat/model.h" // IWYU pragma: export. #include "ortools/sat/sat_parameters.pb.h" #include "ortools/util/sorted_interval_list.h" diff --git a/ortools/sat/cp_model_checker.h b/ortools/sat/cp_model_checker.h index d435cc42fa..16814cb10d 100644 --- a/ortools/sat/cp_model_checker.h +++ b/ortools/sat/cp_model_checker.h @@ -19,7 +19,6 @@ #include #include "absl/types/span.h" -#include "ortools/base/types.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/cp_model_expand.h b/ortools/sat/cp_model_expand.h index c63ea63748..8f207f04cc 100644 --- a/ortools/sat/cp_model_expand.h +++ b/ortools/sat/cp_model_expand.h @@ -16,9 +16,6 @@ #include -#include - -#include "absl/container/flat_hash_set.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/presolve_context.h" diff --git a/ortools/sat/cp_model_lns.cc b/ortools/sat/cp_model_lns.cc index 8169661da0..d44140f6df 100644 --- a/ortools/sat/cp_model_lns.cc +++ b/ortools/sat/cp_model_lns.cc @@ -48,7 +48,7 @@ #include "ortools/sat/cp_model_solver_helpers.h" #include "ortools/sat/cp_model_utils.h" #include "ortools/sat/diffn_util.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/model.h" #include "ortools/sat/presolve_context.h" diff --git a/ortools/sat/cp_model_lns.h b/ortools/sat/cp_model_lns.h index 8dd0645000..d72e6a034e 100644 --- a/ortools/sat/cp_model_lns.h +++ b/ortools/sat/cp_model_lns.h @@ -32,8 +32,7 @@ #include "google/protobuf/arena.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_solver_helpers.h" -#include "ortools/sat/integer.h" -#include "ortools/sat/model.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/subsolver.h" #include "ortools/sat/synchronization.h" diff --git a/ortools/sat/cp_model_loader.cc b/ortools/sat/cp_model_loader.cc index 63902f1a09..8dc2480bec 100644 --- a/ortools/sat/cp_model_loader.cc +++ b/ortools/sat/cp_model_loader.cc @@ -46,6 +46,7 @@ #include "ortools/sat/disjunctive.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" diff --git a/ortools/sat/cp_model_loader.h b/ortools/sat/cp_model_loader.h index 48237e3287..161e6c146e 100644 --- a/ortools/sat/cp_model_loader.h +++ b/ortools/sat/cp_model_loader.h @@ -15,22 +15,11 @@ #define OR_TOOLS_SAT_CP_MODEL_LOADER_H_ #include -#include #include -#include "absl/container/flat_hash_set.h" -#include "ortools/base/logging.h" -#include "ortools/base/strong_vector.h" -#include "ortools/base/types.h" #include "ortools/sat/cp_model.pb.h" -#include "ortools/sat/cp_model_mapping.h" -#include "ortools/sat/cp_model_utils.h" -#include "ortools/sat/integer.h" -#include "ortools/sat/intervals.h" -#include "ortools/sat/linear_relaxation.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" -#include "ortools/sat/sat_base.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/cp_model_mapping.h b/ortools/sat/cp_model_mapping.h index 6b32c1c688..1861e8a501 100644 --- a/ortools/sat/cp_model_mapping.h +++ b/ortools/sat/cp_model_mapping.h @@ -14,21 +14,17 @@ #ifndef OR_TOOLS_SAT_CP_MODEL_MAPPING_H_ #define OR_TOOLS_SAT_CP_MODEL_MAPPING_H_ -#include -#include #include -#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/log/check.h" -#include "absl/meta/type_traits.h" #include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" -#include "ortools/base/types.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_utils.h" #include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" +#include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/cp_model_postsolve.h b/ortools/sat/cp_model_postsolve.h index e49661340c..57da83341c 100644 --- a/ortools/sat/cp_model_postsolve.h +++ b/ortools/sat/cp_model_postsolve.h @@ -18,7 +18,6 @@ #include #include "absl/types/span.h" -#include "ortools/base/types.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/util/logging.h" #include "ortools/util/sorted_interval_list.h" diff --git a/ortools/sat/cp_model_presolve.cc b/ortools/sat/cp_model_presolve.cc index bfee9b5110..286439f0b3 100644 --- a/ortools/sat/cp_model_presolve.cc +++ b/ortools/sat/cp_model_presolve.cc @@ -66,6 +66,7 @@ #include "ortools/sat/diophantine.h" #include "ortools/sat/inclusion.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/presolve_context.h" #include "ortools/sat/presolve_util.h" diff --git a/ortools/sat/cp_model_search.cc b/ortools/sat/cp_model_search.cc index 7c1e05eb12..ba580e810b 100644 --- a/ortools/sat/cp_model_search.cc +++ b/ortools/sat/cp_model_search.cc @@ -24,7 +24,6 @@ #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "absl/flags/flag.h" #include "absl/log/check.h" #include "absl/random/distributions.h" #include "absl/strings/str_cat.h" @@ -35,6 +34,7 @@ #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/cp_model_utils.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/linear_propagation.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/cp_model_search.h b/ortools/sat/cp_model_search.h index 7aae943e43..3892e97ac9 100644 --- a/ortools/sat/cp_model_search.h +++ b/ortools/sat/cp_model_search.h @@ -20,11 +20,13 @@ #include #include "absl/container/flat_hash_map.h" +#include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "ortools/base/types.h" +#include "ortools/base/stl_util.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/cp_model_search_test.cc b/ortools/sat/cp_model_search_test.cc index 4207708282..1666a56ba9 100644 --- a/ortools/sat/cp_model_search_test.cc +++ b/ortools/sat/cp_model_search_test.cc @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "ortools/sat/cp_model_search.h" - #include #include diff --git a/ortools/sat/cp_model_solver.cc b/ortools/sat/cp_model_solver.cc index 1c3856e6ac..7803c64a5a 100644 --- a/ortools/sat/cp_model_solver.cc +++ b/ortools/sat/cp_model_solver.cc @@ -64,7 +64,9 @@ #include "ortools/sat/feasibility_jump.h" #include "ortools/sat/feasibility_pump.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_model.h" +#include "ortools/sat/linear_programming_constraint.h" #include "ortools/sat/lp_utils.h" #include "ortools/sat/model.h" #include "ortools/sat/parameters_validation.h" @@ -72,6 +74,7 @@ #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_inprocessing.h" #include "ortools/sat/sat_parameters.pb.h" +#include "ortools/sat/sat_solver.h" #include "ortools/sat/shaving_solver.h" #include "ortools/sat/stat_tables.h" #include "ortools/sat/subsolver.h" diff --git a/ortools/sat/cp_model_solver_helpers.cc b/ortools/sat/cp_model_solver_helpers.cc index 8784bda39d..5ad19abe82 100644 --- a/ortools/sat/cp_model_solver_helpers.cc +++ b/ortools/sat/cp_model_solver_helpers.cc @@ -57,6 +57,7 @@ #include "ortools/sat/feasibility_pump.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/intervals.h" @@ -73,6 +74,7 @@ #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" +#include "ortools/sat/stat_tables.h" #include "ortools/sat/symmetry_util.h" #include "ortools/sat/synchronization.h" #include "ortools/sat/util.h" diff --git a/ortools/sat/cp_model_solver_helpers.h b/ortools/sat/cp_model_solver_helpers.h index ff4403b2fb..55403be916 100644 --- a/ortools/sat/cp_model_solver_helpers.h +++ b/ortools/sat/cp_model_solver_helpers.h @@ -24,7 +24,7 @@ #include "absl/flags/declare.h" #include "ortools/base/timer.h" #include "ortools/sat/cp_model.pb.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/stat_tables.h" diff --git a/ortools/sat/cp_model_symmetries.h b/ortools/sat/cp_model_symmetries.h index 11376f9ad8..83cd17bd49 100644 --- a/ortools/sat/cp_model_symmetries.h +++ b/ortools/sat/cp_model_symmetries.h @@ -14,7 +14,6 @@ #ifndef OR_TOOLS_SAT_CP_MODEL_SYMMETRIES_H_ #define OR_TOOLS_SAT_CP_MODEL_SYMMETRIES_H_ -#include #include #include diff --git a/ortools/sat/cp_model_symmetries_test.cc b/ortools/sat/cp_model_symmetries_test.cc index 0974788701..cf04290b4d 100644 --- a/ortools/sat/cp_model_symmetries_test.cc +++ b/ortools/sat/cp_model_symmetries_test.cc @@ -16,7 +16,6 @@ #include #include #include -#include #include #include "absl/log/check.h" diff --git a/ortools/sat/cp_model_table.h b/ortools/sat/cp_model_table.h index 1090cfd4d8..e603ce16d6 100644 --- a/ortools/sat/cp_model_table.h +++ b/ortools/sat/cp_model_table.h @@ -18,6 +18,7 @@ #include #include +#include "absl/container/flat_hash_set.h" #include "absl/container/inlined_vector.h" #include "absl/types/span.h" #include "ortools/sat/cp_model.pb.h" diff --git a/ortools/sat/cumulative.cc b/ortools/sat/cumulative.cc index 87de487590..7ddd2f5a22 100644 --- a/ortools/sat/cumulative.cc +++ b/ortools/sat/cumulative.cc @@ -24,6 +24,7 @@ #include "ortools/sat/cumulative_energy.h" #include "ortools/sat/disjunctive.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" diff --git a/ortools/sat/cumulative.h b/ortools/sat/cumulative.h index 07fb381811..d7a0f59500 100644 --- a/ortools/sat/cumulative.h +++ b/ortools/sat/cumulative.h @@ -18,7 +18,7 @@ #include #include "absl/types/span.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/cumulative_energy.h b/ortools/sat/cumulative_energy.h index 36bc92d72f..3d0bce1599 100644 --- a/ortools/sat/cumulative_energy.h +++ b/ortools/sat/cumulative_energy.h @@ -15,13 +15,13 @@ #define OR_TOOLS_SAT_CUMULATIVE_ENERGY_H_ #include -#include #include #include #include "absl/types/span.h" #include "ortools/sat/2d_orthogonal_packing.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/sat/synchronization.h" diff --git a/ortools/sat/cumulative_test.cc b/ortools/sat/cumulative_test.cc index e14f2c63ce..f691cc6ea6 100644 --- a/ortools/sat/cumulative_test.cc +++ b/ortools/sat/cumulative_test.cc @@ -26,13 +26,13 @@ #include "gtest/gtest.h" #include "ortools/base/logging.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/cuts.cc b/ortools/sat/cuts.cc index 6e32dda570..31e1d3cbf4 100644 --- a/ortools/sat/cuts.cc +++ b/ortools/sat/cuts.cc @@ -42,6 +42,7 @@ #include "ortools/sat/clause.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/cuts.h b/ortools/sat/cuts.h index cc0ec7dbfb..c13957886b 100644 --- a/ortools/sat/cuts.h +++ b/ortools/sat/cuts.h @@ -16,12 +16,10 @@ #include -#include #include #include #include #include -#include #include #include #include @@ -35,8 +33,10 @@ #include "absl/strings/str_cat.h" #include "absl/types/span.h" #include "ortools/base/strong_vector.h" +#include "ortools/lp_data/lp_types.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/cuts_test.cc b/ortools/sat/cuts_test.cc index d8d78d153c..f8e06d9348 100644 --- a/ortools/sat/cuts_test.cc +++ b/ortools/sat/cuts_test.cc @@ -29,6 +29,7 @@ #include "ortools/base/strong_vector.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/diffn.cc b/ortools/sat/diffn.cc index 5c0fb2456a..06b01cca4a 100644 --- a/ortools/sat/diffn.cc +++ b/ortools/sat/diffn.cc @@ -28,6 +28,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/container/inlined_vector.h" #include "absl/log/check.h" +#include "absl/numeric/bits.h" #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/sat/2d_orthogonal_packing.h" @@ -36,6 +37,7 @@ #include "ortools/sat/diffn_util.h" #include "ortools/sat/disjunctive.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" @@ -45,6 +47,7 @@ #include "ortools/sat/timetable.h" #include "ortools/util/saturated_arithmetic.h" #include "ortools/util/strong_integers.h" +#include "ortools/util/time_limit.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/diffn.h b/ortools/sat/diffn.h index 38938f5154..e4bce580c0 100644 --- a/ortools/sat/diffn.h +++ b/ortools/sat/diffn.h @@ -15,7 +15,6 @@ #define OR_TOOLS_SAT_DIFFN_H_ #include -#include #include #include @@ -27,7 +26,6 @@ #include "ortools/sat/integer.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" -#include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/synchronization.h" #include "ortools/sat/util.h" diff --git a/ortools/sat/diffn_cuts.cc b/ortools/sat/diffn_cuts.cc index e47294af0e..2a06eb3222 100644 --- a/ortools/sat/diffn_cuts.cc +++ b/ortools/sat/diffn_cuts.cc @@ -32,6 +32,7 @@ #include "ortools/sat/diffn_util.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" diff --git a/ortools/sat/diffn_cuts.h b/ortools/sat/diffn_cuts.h index 86a8e40e6b..bd4c8ff3ec 100644 --- a/ortools/sat/diffn_cuts.h +++ b/ortools/sat/diffn_cuts.h @@ -20,6 +20,7 @@ #include "absl/types/span.h" #include "ortools/sat/cuts.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/diffn_test.cc b/ortools/sat/diffn_test.cc index d07a54cf64..692f73aab9 100644 --- a/ortools/sat/diffn_test.cc +++ b/ortools/sat/diffn_test.cc @@ -22,6 +22,7 @@ #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_solver.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/diffn_util.cc b/ortools/sat/diffn_util.cc index 944cb648af..fe14274e89 100644 --- a/ortools/sat/diffn_util.cc +++ b/ortools/sat/diffn_util.cc @@ -32,23 +32,25 @@ #include #include -#include "absl/container/btree_map.h" -#include "absl/container/btree_set.h" +#include "absl/algorithm/container.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/container/inlined_vector.h" #include "absl/log/check.h" #include "absl/random/bit_gen_ref.h" -#include "absl/strings/str_cat.h" +#include "absl/types/optional.h" #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/stl_util.h" +#include "ortools/base/strong_vector.h" +#include "ortools/graph/connected_components.h" #include "ortools/graph/graph.h" #include "ortools/graph/minimum_spanning_tree.h" #include "ortools/graph/strongly_connected_components.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/util.h" +#include "ortools/util/fixed_shape_binary_tree.h" #include "ortools/util/integer_pq.h" #include "ortools/util/strong_integers.h" @@ -107,33 +109,41 @@ absl::InlinedVector Rectangle::RegionDifference( return result; } -// TODO(user): Switch to a faster O(n log n) algo. CompactVectorVector GetOverlappingRectangleComponents( absl::Span rectangles, absl::Span active_rectangles) { if (active_rectangles.empty()) return {}; - std::vector active_rectangles_copy(active_rectangles.begin(), - active_rectangles.end()); - const int size = active_rectangles_copy.size(); - absl::Span indices = absl::MakeSpan(active_rectangles_copy); + std::vector rectangles_to_process; + std::vector rectangles_index; + rectangles_to_process.reserve(active_rectangles.size()); + rectangles_index.reserve(active_rectangles.size()); + for (const int r : active_rectangles) { + rectangles_to_process.push_back(rectangles[r]); + rectangles_index.push_back(r); + } + std::vector> intersections = + FindPartialRectangleIntersectionsAlsoEmpty(rectangles_to_process); + const int num_intersections = intersections.size(); + intersections.reserve(num_intersections * 2 + 1); + for (int i = 0; i < num_intersections; ++i) { + intersections.push_back({intersections[i].second, intersections[i].first}); + } + + CompactVectorVector view; + view.ResetFromPairs(intersections, /*minimum_num_nodes=*/rectangles.size()); + CompactVectorVector components; + FindStronglyConnectedComponents(static_cast(rectangles.size()), view, + &components); CompactVectorVector result; - for (int start = 0; start < size;) { - // Find the component of active_rectangles[start]. - int end = start + 1; - for (int i = start; i < end; i++) { - const Rectangle rect = rectangles[indices[i]]; - for (int j = end; j < size; ++j) { - if (!rect.IsDisjoint(rectangles[indices[j]])) { - std::swap(indices[end++], indices[j]); - } - } + for (int i = 0; i < components.size(); ++i) { + absl::Span component = components[i]; + if (component.size() == 1) continue; + result.Add({}); + for (const int r : component) { + result.AppendToLastVector(rectangles_index[r]); } - if (end > start + 1) { - result.Add(indices.subspan(start, end - start)); - } - start = end; } return result; } @@ -1628,209 +1638,263 @@ std::vector PavedRegionDifference( return original_region; } -std::vector> FindPartialRectangleIntersections( - absl::Span rectangles) { +// Each node in the tree will hold either a single box that is covering the +// whole interval represented by the node, or, if no such box exists, a superset +// of all the connected components of boxes that are overlapping the interval. +// It is a superset and not the exact set of connected components because we +// don't delete nodes that became stale, as explained in the class comment +// below. +struct BinaryTreeNode { + // Contains exactly one element if occupying_box_index != -1. + absl::flat_hash_set connected_components_descendants; + // Hold the x_max of the box that is currently occupying this node (if any) to + // know when it is stale. + int occupying_box_x_max; + // -1 if not occupied. + int occupying_box_index = -1; +}; + +// A data structure to store which boxes are overlapping the current sweep line. +// This uses a binary tree in a slight non-standard way: in a typical use of a +// binary tree the actual values are stored in the leaves and the intermediate +// nodes are there just to make finding the right leaf efficient. Here we do the +// opposite: the values are stored as high up in the tree as possible. +// For example, for a tree of size 8 a box that occupies the y interval [0, 7] +// will be stored as a single node at the root. In the same tree, a box that +// occupies [3, 7] will be stored with the nodes representing the [3, 4), [4, 6) +// and [6, 8) intervals. There is no difference on what is stored in the +// intermediate nodes or on the leaves. When the sweep line moves, we don't +// update the existing nodes on the tree. Thus, some nodes will become stale and +// will represent boxes that no longer overlap the sweep line. Those stale nodes +// get removed lazily. +struct SweepLineIntervalTree { + explicit SweepLineIntervalTree(int max_y, int num_boxes) + : tree(LeafIndex(max_y + 1)), tree_nodes(tree.StorageSize()) { + union_find.SetNumberOfNodes(num_boxes); + } + + // Recompute the connected components of a given node, by simply setting it to + // {self} + left.connected_components + right.connected_components. + void RecomputeConnectedComponents(TreeNodeIndex idx) { + BinaryTreeNode& node = tree_nodes[idx]; + if (node.occupying_box_index != -1) { + node.connected_components_descendants = { + union_find.FindRoot(node.occupying_box_index)}; + return; + } + node.connected_components_descendants.clear(); + if (tree.IsLeaf(idx)) return; + for (const TreeNodeIndex child_idx : + {tree.LeftChild(idx), tree.RightChild(idx)}) { + // The order is non-deterministic, but since this is doing the union of + // hash sets the result is deterministic. + for (const int c : + tree_nodes[child_idx].connected_components_descendants) { + node.connected_components_descendants.insert(union_find.FindRoot(c)); + } + } + } + + // We don't have global deletion method in this class, but this method + // checks if a single interval is fully to the left of the sweep line and + // removes it if so, also updating its connected components. + void RemoveNodeIfXMaxLowerOrEqual(TreeNodeIndex idx, int x_threshold) { + BinaryTreeNode& node = tree_nodes[idx]; + if (node.occupying_box_index == -1) { + // Node is already empty. + return; + } + if (node.occupying_box_x_max > x_threshold) { + // Node is still overlapping the sweep line. + return; + } + node.occupying_box_index = -1; + RecomputeConnectedComponents(idx); + } + + void UpdateChildrenIntersecting(TreeNodeIndex idx, int sweep_line_x_pos, + int component_index, + std::vector* new_connections) { + if (tree.IsLeaf(idx)) return; + for (const TreeNodeIndex child_idx : + {tree.LeftChild(idx), tree.RightChild(idx)}) { + RemoveNodeIfXMaxLowerOrEqual(child_idx, sweep_line_x_pos); + BinaryTreeNode& child_node = tree_nodes[child_idx]; + if (child_node.occupying_box_index != -1) { + if (union_find.AddEdge(child_node.occupying_box_index, + component_index)) { + new_connections->push_back(child_node.occupying_box_index); + } + // No need to recurse here: we already connected everything on this + // branch to the new box. + continue; + } + const bool had_different_component = + absl::c_any_of(child_node.connected_components_descendants, + [this, component_index](const int c) { + return !union_find.Connected(c, component_index); + }); + // Since everything is intersecting the current box, all descendants + // must be in one single component. + child_node.connected_components_descendants = {component_index}; + + // Only go down on the tree if we have below either: + // - a different component to connect. + // - a box to remove that is in a different component. + // In any case, we will visit O(c + d) terminals, where c is the number of + // components we are connecting and d is the number of boxes that we will + // delete. Since a box can only be deleted log N times (one per interval + // it was cut into) and we can only connect O(N) components in total, the + // amortized cost of a call to UpdateChildrenIntersecting is O((log N)^2). + if (had_different_component) { + UpdateChildrenIntersecting(child_idx, sweep_line_x_pos, component_index, + new_connections); + } + } + } + + bool UpdateParents(TreeNodeIndex node, int sweep_line_x_pos, + int component_index, std::vector* new_connections) { + if (node == tree.Root()) return false; + for (TreeNodeIndex parent = tree.Parent(node); parent != tree.Root(); + parent = tree.Parent(parent)) { + RemoveNodeIfXMaxLowerOrEqual(parent, sweep_line_x_pos); + BinaryTreeNode& parent_value = tree_nodes[parent]; + if (parent_value.occupying_box_index != -1) { + if (union_find.AddEdge(parent_value.occupying_box_index, + component_index)) { + new_connections->push_back(parent_value.occupying_box_index); + return true; + } + } + parent_value.connected_components_descendants.insert(component_index); + } + return false; + } + + // Add a new box to the sweep line. This will store it in the tree (split in + // log N intervals) check if it connects to one or more existing connected + // components, and for each case it does, add the box that it is overlapping + // to new_connections. + void AddInterval(TreeNodeIndex idx, int sweep_line_x_pos, int box_index, + int x_max, std::vector* new_connections) { + RemoveNodeIfXMaxLowerOrEqual(idx, sweep_line_x_pos); + int cur_box_component = union_find.FindRoot(box_index); + BinaryTreeNode& node = tree_nodes[idx]; + if (node.occupying_box_index == -1) { + node.connected_components_descendants = {box_index}; + node.occupying_box_index = box_index; + node.occupying_box_x_max = x_max; + const bool had_occupied_parent = UpdateParents( + idx, sweep_line_x_pos, cur_box_component, new_connections); + // We can only be connecting children if it is not already connect via + // something above on the tree. + if (!had_occupied_parent) { + UpdateChildrenIntersecting(idx, sweep_line_x_pos, cur_box_component, + new_connections); + } + } else { + // We have already something fully occupying this interval. + if (union_find.AddEdge(node.occupying_box_index, cur_box_component)) { + new_connections->push_back(node.occupying_box_index); + cur_box_component = union_find.FindRoot(cur_box_component); + } + node.connected_components_descendants = {cur_box_component}; + if (node.occupying_box_x_max < x_max) { + // Replace the existing box by the new one. + node.occupying_box_index = box_index; + node.occupying_box_x_max = x_max; + } + } + } + + FixedShapeBinaryTree tree; + util_intops::StrongVector tree_nodes; + DenseConnectedComponentsFinder union_find; +}; + +struct Rectangle32 { + int x_min; + int x_max; + int y_min; + int y_max; + int index; +}; + +std::vector> FindPartialRectangleIntersectionsImpl( + absl::Span rectangles, int y_max) { // We are going to use a sweep line algorithm to find the intersections. // First, we sort the rectangles by their x coordinates, then consider a sweep // line that goes from the left to the right. - enum class Type { - kEnd, - kBegin, - }; - struct RectangleHorizontalEdge { - IntegerValue x_coordinate; - int index; - Type type; - }; - std::vector edges; - edges.reserve(rectangles.size() * 2); + std::sort(rectangles.begin(), rectangles.end(), + [](const Rectangle32& a, const Rectangle32& b) { + return std::tuple(a.x_min, -a.x_max, a.index) < + std::tuple(b.x_min, -b.x_max, b.index); + }); + + SweepLineIntervalTree interval_tree(y_max, rectangles.size()); + + std::vector interval_pieces; + std::vector new_connections; + std::vector> arcs; + for (int rectangle_index = 0; rectangle_index < rectangles.size(); + ++rectangle_index) { + const int sweep_line_x_pos = rectangles[rectangle_index].x_min; + const Rectangle32& r = rectangles[rectangle_index]; + interval_pieces.clear(); + interval_tree.tree.PartitionIntervalIntoNodes( + LeafIndex(r.y_min), LeafIndex(r.y_max - 1), &interval_pieces); + new_connections.clear(); + for (const TreeNodeIndex& node : interval_pieces) { + interval_tree.AddInterval(node, sweep_line_x_pos, rectangle_index, + r.x_max, &new_connections); + } + for (const int new_connection : new_connections) { + arcs.push_back({rectangles[new_connection].index, r.index}); + } + } + return arcs; +} + +std::vector> FindPartialRectangleIntersections( + absl::Span rectangles) { + if (rectangles.empty()) return {}; + std::vector to_sort_x; + std::vector to_sort_y; + for (const Rectangle& r : rectangles) { + DCHECK_GT(r.SizeX(), 0); + DCHECK_GT(r.SizeY(), 0); + to_sort_x.push_back(r.x_min); + to_sort_x.push_back(r.x_max); + to_sort_y.push_back(r.y_min); + to_sort_y.push_back(r.y_max); + } + gtl::STLSortAndRemoveDuplicates(&to_sort_x); + gtl::STLSortAndRemoveDuplicates(&to_sort_y); + + absl::flat_hash_map x_map; + absl::flat_hash_map y_map; + x_map.reserve(to_sort_x.size()); + y_map.reserve(to_sort_y.size()); + for (int i = 0; i < to_sort_x.size(); ++i) { + x_map[to_sort_x[i]] = i; + } + for (int i = 0; i < to_sort_y.size(); ++i) { + y_map[to_sort_y[i]] = i; + } + + std::vector rectangles32; + rectangles32.reserve(rectangles.size()); for (int i = 0; i < rectangles.size(); ++i) { - DCHECK_GT(rectangles[i].SizeX(), 0); - DCHECK_GT(rectangles[i].SizeY(), 0); - edges.push_back({.x_coordinate = rectangles[i].x_min, - .index = i, - .type = Type::kBegin}); - edges.push_back( - {.x_coordinate = rectangles[i].x_max, .index = i, .type = Type::kEnd}); + const Rectangle& r = rectangles[i]; + rectangles32.push_back({.x_min = x_map[r.x_min], + .x_max = x_map[r.x_max], + .y_min = y_map[r.y_min], + .y_max = y_map[r.y_max], + .index = i}); } - - std::sort( - edges.begin(), edges.end(), - [](const RectangleHorizontalEdge& a, const RectangleHorizontalEdge& b) { - return std::tuple(a.x_coordinate, a.type, a.index) < - std::tuple(b.x_coordinate, b.type, b.index); - }); - - // Current y-coordinate intervals that are intersecting the sweep line. - // Note that the interval_set only contains disjoint intervals. - struct Interval { - IntegerValue start; - mutable IntegerValue end; - - // This interval will always be a "subpart" of the full y-span of the - // initial rectangle with given index. - mutable int index; - - bool operator<(const Interval& other) const { return start < other.start; } - - std::string to_string() const { - return absl::StrCat("[", start.value(), ",", end.value(), "](", index, - ")"); - } - }; - std::set interval_set; - - // The finer point of this algorithm is deciding what to keep on our interval - // list when we find two rectangles that intersect. Since we don't want to - // lose track of any rectangle that might intersect another one, we keep in - // the intervals the pieces that has the largest x_max: ie., we make sure that - // we will not remove an interval that is still intersecting some rectangles. - absl::btree_set> arcs; - int current_index = 0; - while (current_index < edges.size()) { - const IntegerValue x_pos = edges[current_index].x_coordinate; - // First check all the rectangles that end at this x_pos and remove them - // from the interval list. - for (; current_index < edges.size() && - edges[current_index].x_coordinate == x_pos && - edges[current_index].type == Type::kEnd; - ++current_index) { - const int index_to_remove = edges[current_index].index; - const Rectangle r = rectangles[index_to_remove]; - - // Loop over all intervals intersecting [r.y_min, r.y_max] and remove the - // one with the given index. - const Interval for_lookup = {r.y_min, r.y_max, index_to_remove}; - auto it = interval_set.lower_bound(for_lookup); - while (it != interval_set.end()) { - // Subtle: we need to find the next interval here because the current - // one might be invalidated by the erase. - auto current = it++; - if (current->start >= r.y_max) break; - if (current->index == index_to_remove) { - interval_set.erase(current); - } - } - } - // Now add the rectangles that start at this x_pos and potentially detect - // any overlap. - for (; current_index < edges.size() && - edges[current_index].x_coordinate == x_pos && - edges[current_index].type == Type::kBegin; - ++current_index) { - const int cur_index = edges[current_index].index; - const Rectangle r = rectangles[cur_index]; - - // We need to insert a new interval, we will split it according to the - // interval that it overlaps with. - Interval to_insert = {r.y_min, r.y_max, cur_index}; - auto it = interval_set.lower_bound(to_insert); - if (it != interval_set.begin()) --it; - while (it != interval_set.end()) { - auto current = it++; - if (to_insert.start == to_insert.end) break; - if (current->end <= to_insert.start) continue; - if (current->start >= to_insert.end) break; - - // We have an intersection. - if (to_insert.index == cur_index) { - arcs.insert({std::min(to_insert.index, current->index), - std::max(to_insert.index, current->index)}); - } - - // It can be composed of up to 3 part: - // Where part1 and/or part2 could be empty. - // current [ ] - // to_insert [ ] - // current [ ] - // to_insert [ ] - // current [ ] - // to_insert [ ] - // current [ ] - // to_insert [ ] - // | part1 | part2 | part 3 | - const int first_index = - current->start < to_insert.start ? current->index : to_insert.index; - const int middle_index = - rectangles[to_insert.index].x_max < rectangles[current->index].x_max - ? current->index - : to_insert.index; - const int last_index = - current->end > to_insert.end ? current->index : to_insert.index; - - IntegerValue points[4]; - points[0] = current->start; - points[1] = current->end; - points[2] = to_insert.start; - points[3] = to_insert.end; - std::sort(points, points + 4); - - // There is always a middle part because the intersection is not empty. - CHECK_LT(points[1], points[2]); - - if (points[0] == points[1]) { - // Rewrite current as part 2. - current->end = points[2]; - current->index = middle_index; - } else { - if (points[0] == current->start) { - // Rewrite current as part 1. - current->end = points[1]; - current->index = first_index; - - // Insert a new part2 interval. - // As an optimization, if middle_index == last_index, we just - // merge part2 and 3 in the next to_insert. - if (middle_index == last_index) { - to_insert.start = points[1]; - to_insert.end = points[3]; - to_insert.index = last_index; - continue; - } - interval_set.insert({points[1], points[2], middle_index}); - } else { - CHECK_EQ(points[1], current->start); - - // Rewrite current as part 2. - current->end = points[2]; - current->index = middle_index; - - // Insert a new part1 interval. - interval_set.insert({points[0], points[1], first_index}); - } - } - - // To_insert is the final part (it can be empty). - to_insert.start = points[2]; - to_insert.end = points[3]; - to_insert.index = last_index; - } - - if (to_insert.start < to_insert.end) { - interval_set.insert(to_insert); - } - } - } - - // At this point we have a set of arcs that doesn't contain all of the - // pairwise intersections, but is not either a minimal spanning tree either - // since it has cycles. The good property is that it does have enough arcs to - // cover all the rectangles, so we can use it to build a proper MST. - ::util::ReverseArcListGraph<> graph; - std::vector arc_indexes; - absl::flat_hash_map> pair_by_arc_index; - for (const auto& [a, b] : arcs) { - pair_by_arc_index[arc_indexes.size()] = {a, b}; - arc_indexes.push_back(graph.AddArc(a, b)); - } - const std::vector mst_arc_indices = - BuildKruskalMinimumSpanningTreeFromSortedArcs(graph, arc_indexes); - std::vector> result; - for (const int arc_index : mst_arc_indices) { - const auto& [a, b] = pair_by_arc_index[arc_index]; - result.push_back({a, b}); - } - return result; + return FindPartialRectangleIntersectionsImpl(absl::MakeSpan(rectangles32), + to_sort_y.size()); } std::vector> FindPartialRectangleIntersectionsAlsoEmpty( @@ -1847,8 +1911,8 @@ std::vector> FindPartialRectangleIntersectionsAlsoEmpty( } // Now we need to do the boring code of special-casing all the different cases - // of rectangles with zero area. We still want to use the N log N algorithm - // for the subset of the input with non-zero area. + // of rectangles with zero area. We still want to use the quasilinear + // algorithm for the subset of the input with non-zero area. std::vector rectangles_with_area, horizontal_lines, vertical_lines, points; std::vector rectangles_with_area_indexes, horizontal_lines_indexes, diff --git a/ortools/sat/diffn_util.h b/ortools/sat/diffn_util.h index 98200f6216..323f2ad89b 100644 --- a/ortools/sat/diffn_util.h +++ b/ortools/sat/diffn_util.h @@ -15,10 +15,10 @@ #define OR_TOOLS_SAT_DIFFN_UTIL_H_ #include -#include +#include +#include #include #include -#include #include #include #include @@ -30,8 +30,9 @@ #include "absl/log/check.h" #include "absl/random/bit_gen_ref.h" #include "absl/strings/str_format.h" +#include "absl/types/optional.h" #include "absl/types/span.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/util.h" #include "ortools/util/strong_integers.h" @@ -695,13 +696,9 @@ inline bool RegionIncludesOther(absl::Span region, // The returned tuples are the arcs of the spanning forest represented by their // indices in the input vector. // -// Note: This function runs in O(N log N + M) time where N is the number of -// rectangles and M is the total number of intersections. Thus, it is still -// technically quadratic. However, in practice, it will skip many intersections -// and it should be much faster than a naive N^2 implementation even when there -// are a very large number of intersections. -// -// TODO(user): Find a real O(N log N) algorithm. +// Note: This function runs in O(N (log N)^2) time on the input size, which +// would be impossible to do if we were to return all the intersections, which +// can be quadratic in number. std::vector> FindPartialRectangleIntersections( absl::Span rectangles); diff --git a/ortools/sat/diffn_util_test.cc b/ortools/sat/diffn_util_test.cc index 98ea25f57e..f4cb6692ca 100644 --- a/ortools/sat/diffn_util_test.cc +++ b/ortools/sat/diffn_util_test.cc @@ -14,6 +14,7 @@ #include "ortools/sat/diffn_util.h" #include +#include #include #include #include @@ -38,7 +39,8 @@ #include "ortools/graph/connected_components.h" #include "ortools/graph/strongly_connected_components.h" #include "ortools/sat/2d_orthogonal_packing_testing.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" +#include "ortools/sat/util.h" #include "ortools/util/strong_integers.h" namespace operations_research { @@ -1179,7 +1181,7 @@ BENCHMARK(BM_FindPairwiseRestrictions) ->ArgPair(1000, 100) ->ArgPair(10000, 100); -void BM_FindPartialIntersections(benchmark::State& state) { +void BM_FindPartialIntersectionsSparse(benchmark::State& state) { absl::BitGen random; std::vector> problems; static constexpr int kNumProblems = 10; @@ -1206,7 +1208,95 @@ void BM_FindPartialIntersections(benchmark::State& state) { } } -BENCHMARK(BM_FindPartialIntersections) +BENCHMARK(BM_FindPartialIntersectionsSparse) + ->Arg(5) + ->Arg(10) + ->Arg(20) + ->Arg(30) + ->Arg(40) + ->Arg(80) + ->Arg(100) + ->Arg(200) + ->Arg(1000) + ->Arg(10000); + +std::vector GeneratePathologicalCase(int num_rectangles) { + std::vector rectangles; + for (int i = 0; i < num_rectangles / 2; ++i) { + rectangles.push_back({.x_min = 2 * i, + .x_max = 2 * i + 1, + .y_min = 0, + .y_max = 2 * num_rectangles}); + rectangles.push_back({ + .x_min = 0, + .x_max = 2 * num_rectangles, + .y_min = 2 * i, + .y_max = 2 * i + 1, + }); + } + return rectangles; +} + +void BM_FindPartialIntersectionsPathological(benchmark::State& state) { + const std::vector rectangles = + GeneratePathologicalCase(state.range(0)); + for (auto s : state) { + const std::vector> result = + FindPartialRectangleIntersections(rectangles); + CHECK_LT(result.size(), state.range(0) * state.range(0)); + } +} + +BENCHMARK(BM_FindPartialIntersectionsPathological) + ->Arg(5) + ->Arg(10) + ->Arg(20) + ->Arg(30) + ->Arg(40) + ->Arg(80) + ->Arg(100) + ->Arg(200) + ->Arg(1000) + ->Arg(10000); + +std::vector GenerateDenseCase(int num_rectangles) { + absl::BitGen random; + std::vector rectangles; + for (int i = 0; i < num_rectangles; ++i) { + const IntegerValue x_min = absl::Uniform(random, 0, num_rectangles); + const IntegerValue y_min = absl::Uniform(random, 0, num_rectangles); + rectangles.push_back( + {.x_min = x_min, + .x_max = x_min + absl::Uniform(random, 1, num_rectangles), + .y_min = y_min, + .y_max = y_min + absl::Uniform(random, 1, num_rectangles)}); + } + return rectangles; +} + +void BM_FindPartialIntersectionsDense(benchmark::State& state) { + absl::BitGen random; + std::vector> problems; + static constexpr int kNumProblems = 10; + for (int i = 0; i < kNumProblems; i++) { + problems.push_back(GenerateDenseCase(state.range(0))); + } + int idx = 0; + for (auto s : state) { + const std::vector> result = + FindPartialRectangleIntersections(problems[idx]); + CHECK_LT(result.size(), state.range(0) * state.range(0)); + ++idx; + if (idx == kNumProblems) idx = 0; + } +} + +TEST(FindPartialIntersectionsDenseTest, Random) { + const std::vector> result = + FindPartialRectangleIntersections(GenerateDenseCase(20)); +} + +BENCHMARK(BM_FindPartialIntersectionsDense) ->Arg(5) ->Arg(10) ->Arg(20) diff --git a/ortools/sat/disjunctive.cc b/ortools/sat/disjunctive.cc index d77ce957a1..5b6c9958cf 100644 --- a/ortools/sat/disjunctive.cc +++ b/ortools/sat/disjunctive.cc @@ -23,6 +23,7 @@ #include "ortools/base/logging.h" #include "ortools/sat/all_different.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/sat/precedences.h" diff --git a/ortools/sat/disjunctive.h b/ortools/sat/disjunctive.h index 70812a4c0a..920e4098e8 100644 --- a/ortools/sat/disjunctive.h +++ b/ortools/sat/disjunctive.h @@ -15,20 +15,23 @@ #define OR_TOOLS_SAT_DISJUNCTIVE_H_ #include -#include +#include #include #include #include #include +#include "absl/strings/str_cat.h" #include "absl/types/span.h" -#include "ortools/base/macros.h" +#include "ortools/base/logging.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/sat/precedences.h" -#include "ortools/sat/sat_base.h" +#include "ortools/sat/synchronization.h" #include "ortools/sat/theta_tree.h" +#include "ortools/sat/util.h" #include "ortools/util/strong_integers.h" namespace operations_research { diff --git a/ortools/sat/disjunctive_test.cc b/ortools/sat/disjunctive_test.cc index bf58e2b915..0cfef6b416 100644 --- a/ortools/sat/disjunctive_test.cc +++ b/ortools/sat/disjunctive_test.cc @@ -30,6 +30,7 @@ #include "gtest/gtest.h" #include "ortools/base/logging.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/drat_checker.h b/ortools/sat/drat_checker.h index 903ed504fc..2bc102c7d1 100644 --- a/ortools/sat/drat_checker.h +++ b/ortools/sat/drat_checker.h @@ -16,14 +16,13 @@ #include +#include #include #include -#include #include #include #include "absl/container/flat_hash_set.h" -#include "absl/strings/string_view.h" #include "absl/types/span.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/drat_proof_handler.h b/ortools/sat/drat_proof_handler.h index 8b8d9f04f1..30f8c68218 100644 --- a/ortools/sat/drat_proof_handler.h +++ b/ortools/sat/drat_proof_handler.h @@ -15,7 +15,6 @@ #define OR_TOOLS_SAT_DRAT_PROOF_HANDLER_H_ #include -#include #include #if !defined(__PORTABLE_PLATFORM__) diff --git a/ortools/sat/encoding.cc b/ortools/sat/encoding.cc index 1523dbfcc8..edb133cb01 100644 --- a/ortools/sat/encoding.cc +++ b/ortools/sat/encoding.cc @@ -24,6 +24,7 @@ #include #include +#include "absl/container/flat_hash_map.h" #include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" @@ -33,6 +34,7 @@ #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" +#include "ortools/sat/util.h" #include "ortools/util/strong_integers.h" namespace operations_research { diff --git a/ortools/sat/encoding.h b/ortools/sat/encoding.h index 9121c05fd5..fe6eb7fa20 100644 --- a/ortools/sat/encoding.h +++ b/ortools/sat/encoding.h @@ -20,7 +20,6 @@ #ifndef OR_TOOLS_SAT_ENCODING_H_ #define OR_TOOLS_SAT_ENCODING_H_ -#include #include #include #include @@ -30,12 +29,13 @@ #include "absl/log/check.h" #include "absl/types/span.h" #include "ortools/base/logging.h" -#include "ortools/base/macros.h" -#include "ortools/base/types.h" #include "ortools/sat/boolean_problem.pb.h" +#include "ortools/sat/clause.h" +#include "ortools/sat/model.h" #include "ortools/sat/pb_constraint.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" +#include "ortools/sat/util.h" #include "ortools/util/strong_integers.h" namespace operations_research { diff --git a/ortools/sat/encoding_test.cc b/ortools/sat/encoding_test.cc index 29608b3fbb..de0440916c 100644 --- a/ortools/sat/encoding_test.cc +++ b/ortools/sat/encoding_test.cc @@ -15,7 +15,6 @@ #include #include -#include #include #include "absl/random/distributions.h" diff --git a/ortools/sat/feasibility_jump.cc b/ortools/sat/feasibility_jump.cc index ca440ba2b3..12514708ba 100644 --- a/ortools/sat/feasibility_jump.cc +++ b/ortools/sat/feasibility_jump.cc @@ -41,7 +41,7 @@ #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_checker.h" #include "ortools/sat/cp_model_utils.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_model.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/subsolver.h" diff --git a/ortools/sat/feasibility_jump.h b/ortools/sat/feasibility_jump.h index 610397f4d9..98e18d4d2d 100644 --- a/ortools/sat/feasibility_jump.h +++ b/ortools/sat/feasibility_jump.h @@ -27,17 +27,14 @@ #include "absl/container/flat_hash_map.h" #include "absl/functional/any_invocable.h" -#include "absl/functional/bind_front.h" -#include "absl/hash/hash.h" #include "absl/log/check.h" #include "absl/random/distributions.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/sat/constraint_violation.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_model.h" #include "ortools/sat/restart.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/feasibility_pump.cc b/ortools/sat/feasibility_pump.cc index c329dc9d13..7f1a4c32d0 100644 --- a/ortools/sat/feasibility_pump.cc +++ b/ortools/sat/feasibility_pump.cc @@ -34,6 +34,7 @@ #include "ortools/lp_data/sparse_column.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/feasibility_pump.h b/ortools/sat/feasibility_pump.h index 5648c89495..b570344283 100644 --- a/ortools/sat/feasibility_pump.h +++ b/ortools/sat/feasibility_pump.h @@ -27,13 +27,13 @@ #include "ortools/lp_data/lp_types.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" #include "ortools/sat/synchronization.h" -#include "ortools/sat/util.h" #include "ortools/util/time_limit.h" namespace operations_research { diff --git a/ortools/sat/feasibility_pump_test.cc b/ortools/sat/feasibility_pump_test.cc index 40563f97d6..85c791206c 100644 --- a/ortools/sat/feasibility_pump_test.cc +++ b/ortools/sat/feasibility_pump_test.cc @@ -13,16 +13,14 @@ #include "ortools/sat/feasibility_pump.h" -#include - #include "gtest/gtest.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_loader.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" -#include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/implied_bounds.cc b/ortools/sat/implied_bounds.cc index 925d6cb01b..8aaaa31a6f 100644 --- a/ortools/sat/implied_bounds.cc +++ b/ortools/sat/implied_bounds.cc @@ -28,13 +28,13 @@ #include "absl/container/flat_hash_set.h" #include "absl/log/check.h" #include "absl/meta/type_traits.h" -#include "absl/strings/str_cat.h" #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" #include "ortools/lp_data/lp_types.h" #include "ortools/sat/clause.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/implied_bounds.h b/ortools/sat/implied_bounds.h index 7446ed3775..60795df8ed 100644 --- a/ortools/sat/implied_bounds.h +++ b/ortools/sat/implied_bounds.h @@ -21,15 +21,15 @@ #include #include +#include "absl/container/btree_map.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" -#include "ortools/base/types.h" #include "ortools/lp_data/lp_types.h" #include "ortools/sat/clause.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/implied_bounds_test.cc b/ortools/sat/implied_bounds_test.cc index 935c30b33d..47aff57b5f 100644 --- a/ortools/sat/implied_bounds_test.cc +++ b/ortools/sat/implied_bounds_test.cc @@ -22,6 +22,7 @@ #include "ortools/base/strong_vector.h" #include "ortools/lp_data/lp_types.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/integer.cc b/ortools/sat/integer.cc index 5803e39202..b052366b88 100644 --- a/ortools/sat/integer.cc +++ b/ortools/sat/integer.cc @@ -34,6 +34,7 @@ #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/integer.h b/ortools/sat/integer.h index 1c624073d8..72e5c35ee7 100644 --- a/ortools/sat/integer.h +++ b/ortools/sat/integer.h @@ -21,8 +21,6 @@ #include #include #include -#include -#include #include #include #include @@ -43,7 +41,6 @@ #include "ortools/sat/sat_solver.h" #include "ortools/util/bitset.h" #include "ortools/util/rev.h" -#include "ortools/util/saturated_arithmetic.h" #include "ortools/util/sorted_interval_list.h" #include "ortools/util/strong_integers.h" #include "ortools/util/time_limit.h" diff --git a/ortools/sat/integer_base.h b/ortools/sat/integer_base.h index b579ebfb91..1e25b218e7 100644 --- a/ortools/sat/integer_base.h +++ b/ortools/sat/integer_base.h @@ -18,23 +18,17 @@ #include #include -#include #include -#include #include #include #include #include -#include "absl/base/attributes.h" -#include "absl/container/btree_map.h" -#include "absl/container/flat_hash_map.h" #include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" -#include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/util/saturated_arithmetic.h" #include "ortools/util/sorted_interval_list.h" diff --git a/ortools/sat/integer_expr.cc b/ortools/sat/integer_expr.cc index db311546d2..787276ec1f 100644 --- a/ortools/sat/integer_expr.cc +++ b/ortools/sat/integer_expr.cc @@ -17,25 +17,21 @@ #include #include #include -#include #include #include #include -#include "absl/container/flat_hash_map.h" #include "absl/log/check.h" #include "absl/numeric/int128.h" #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/mathutil.h" -#include "ortools/base/stl_util.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" -#include "ortools/sat/sat_solver.h" #include "ortools/sat/util.h" -#include "ortools/util/sorted_interval_list.h" #include "ortools/util/strong_integers.h" #include "ortools/util/time_limit.h" diff --git a/ortools/sat/integer_expr.h b/ortools/sat/integer_expr.h index 5d3c39f1cb..efbf8422a6 100644 --- a/ortools/sat/integer_expr.h +++ b/ortools/sat/integer_expr.h @@ -14,7 +14,6 @@ #ifndef OR_TOOLS_SAT_INTEGER_EXPR_H_ #define OR_TOOLS_SAT_INTEGER_EXPR_H_ -#include #include #include #include @@ -25,7 +24,9 @@ #include "absl/log/check.h" #include "absl/types/span.h" +#include "ortools/base/logging.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_propagation.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/integer_expr_test.cc b/ortools/sat/integer_expr_test.cc index c12afac4b9..fc770f7082 100644 --- a/ortools/sat/integer_expr_test.cc +++ b/ortools/sat/integer_expr_test.cc @@ -37,6 +37,7 @@ #include "ortools/sat/cp_model_solver.h" #include "ortools/sat/cp_model_utils.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/integer_search.cc b/ortools/sat/integer_search.cc index a7566c191a..3a666bcb93 100644 --- a/ortools/sat/integer_search.cc +++ b/ortools/sat/integer_search.cc @@ -33,6 +33,7 @@ #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/linear_programming_constraint.h" diff --git a/ortools/sat/integer_search.h b/ortools/sat/integer_search.h index a360df320d..f8cfb7cf88 100644 --- a/ortools/sat/integer_search.h +++ b/ortools/sat/integer_search.h @@ -32,8 +32,10 @@ #include "absl/types/span.h" #include "ortools/sat/clause.h" #include "ortools/sat/cp_model.pb.h" +#include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/probing.h" #include "ortools/sat/pseudo_costs.h" diff --git a/ortools/sat/integer_test.cc b/ortools/sat/integer_test.cc index 48fe3902f1..70da354423 100644 --- a/ortools/sat/integer_test.cc +++ b/ortools/sat/integer_test.cc @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -26,7 +25,7 @@ #include "gtest/gtest.h" #include "ortools/base/gmock.h" #include "ortools/base/logging.h" -#include "ortools/base/types.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/intervals.cc b/ortools/sat/intervals.cc index c9d33b9eef..ff80acbab5 100644 --- a/ortools/sat/intervals.cc +++ b/ortools/sat/intervals.cc @@ -29,6 +29,7 @@ #include "ortools/base/strong_vector.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/intervals.h b/ortools/sat/intervals.h index 6c4306dcc3..1e51c22da0 100644 --- a/ortools/sat/intervals.h +++ b/ortools/sat/intervals.h @@ -25,20 +25,18 @@ #include "absl/base/attributes.h" #include "absl/container/flat_hash_map.h" #include "absl/log/check.h" -#include "absl/strings/string_view.h" #include "absl/types/span.h" #include "ortools/base/strong_vector.h" -#include "ortools/sat/cp_constraints.h" +#include "ortools/sat/clause.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" -#include "ortools/sat/integer_expr.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" -#include "ortools/sat/pb_constraint.h" #include "ortools/sat/precedences.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" -#include "ortools/util/rev.h" +#include "ortools/util/bitset.h" #include "ortools/util/strong_integers.h" namespace operations_research { diff --git a/ortools/sat/intervals_test.cc b/ortools/sat/intervals_test.cc index ab2ead8f90..dd03dfb35d 100644 --- a/ortools/sat/intervals_test.cc +++ b/ortools/sat/intervals_test.cc @@ -15,16 +15,15 @@ #include -#include #include #include "gtest/gtest.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/lb_tree_search.cc b/ortools/sat/lb_tree_search.cc index d294bec6c3..dfd5195c91 100644 --- a/ortools/sat/lb_tree_search.cc +++ b/ortools/sat/lb_tree_search.cc @@ -30,6 +30,7 @@ #include "ortools/base/strong_vector.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/linear_programming_constraint.h" diff --git a/ortools/sat/lb_tree_search.h b/ortools/sat/lb_tree_search.h index f0cc53e689..ad318eae94 100644 --- a/ortools/sat/lb_tree_search.h +++ b/ortools/sat/lb_tree_search.h @@ -22,11 +22,12 @@ #include #include -#include "absl/strings/string_view.h" -#include "absl/time/time.h" +#include "absl/log/check.h" #include "absl/types/span.h" #include "ortools/base/strong_vector.h" +#include "ortools/glop/variables_info.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/linear_programming_constraint.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/lb_tree_search_test.cc b/ortools/sat/lb_tree_search_test.cc index a67d03e0a5..a695cdd781 100644 --- a/ortools/sat/lb_tree_search_test.cc +++ b/ortools/sat/lb_tree_search_test.cc @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "ortools/sat/lb_tree_search.h" - #include "gtest/gtest.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_solver.h" diff --git a/ortools/sat/linear_constraint.cc b/ortools/sat/linear_constraint.cc index f4a645f1c5..9fcf7fafac 100644 --- a/ortools/sat/linear_constraint.cc +++ b/ortools/sat/linear_constraint.cc @@ -30,6 +30,7 @@ #include "ortools/base/mathutil.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/sat_base.h" #include "ortools/util/saturated_arithmetic.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/linear_constraint.h b/ortools/sat/linear_constraint.h index 9a88f4aaf8..c95d20c3e7 100644 --- a/ortools/sat/linear_constraint.h +++ b/ortools/sat/linear_constraint.h @@ -15,6 +15,8 @@ #define OR_TOOLS_SAT_LINEAR_CONSTRAINT_H_ #include +#include +#include #include #include #include @@ -22,12 +24,15 @@ #include #include "absl/base/attributes.h" +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" +#include "ortools/util/saturated_arithmetic.h" #include "ortools/util/strong_integers.h" namespace operations_research { diff --git a/ortools/sat/linear_constraint_manager.cc b/ortools/sat/linear_constraint_manager.cc index de77a4386f..45b8231190 100644 --- a/ortools/sat/linear_constraint_manager.cc +++ b/ortools/sat/linear_constraint_manager.cc @@ -37,6 +37,7 @@ #include "ortools/glop/variables_info.h" #include "ortools/lp_data/lp_types.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/linear_constraint_manager.h b/ortools/sat/linear_constraint_manager.h index 746064ddc3..0a74843bce 100644 --- a/ortools/sat/linear_constraint_manager.h +++ b/ortools/sat/linear_constraint_manager.h @@ -22,16 +22,17 @@ #include "absl/container/btree_map.h" #include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" +#include "absl/types/span.h" #include "ortools/base/strong_vector.h" #include "ortools/glop/variables_info.h" #include "ortools/lp_data/lp_types.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/synchronization.h" #include "ortools/sat/util.h" -#include "ortools/util/logging.h" #include "ortools/util/strong_integers.h" #include "ortools/util/time_limit.h" diff --git a/ortools/sat/linear_constraint_manager_test.cc b/ortools/sat/linear_constraint_manager_test.cc index 3e1c182d1e..e52668dee2 100644 --- a/ortools/sat/linear_constraint_manager_test.cc +++ b/ortools/sat/linear_constraint_manager_test.cc @@ -23,9 +23,9 @@ #include "ortools/glop/variables_info.h" #include "ortools/lp_data/lp_types.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" -#include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/linear_constraint_test.cc b/ortools/sat/linear_constraint_test.cc index cad9ad4d9e..d8f338c19f 100644 --- a/ortools/sat/linear_constraint_test.cc +++ b/ortools/sat/linear_constraint_test.cc @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -24,6 +23,7 @@ #include "ortools/base/gmock.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/linear_model_test.cc b/ortools/sat/linear_model_test.cc index 143cbe8bc5..9abdeae6dd 100644 --- a/ortools/sat/linear_model_test.cc +++ b/ortools/sat/linear_model_test.cc @@ -19,11 +19,7 @@ #include "ortools/base/gmock.h" #include "ortools/base/parse_test_proto.h" #include "ortools/sat/cp_model.pb.h" -#include "ortools/sat/cp_model_presolve.h" -#include "ortools/sat/model.h" -#include "ortools/sat/presolve_context.h" #include "ortools/sat/sat_parameters.pb.h" -#include "ortools/util/logging.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/linear_programming_constraint.cc b/ortools/sat/linear_programming_constraint.cc index 16ba825906..b3bd50d63f 100644 --- a/ortools/sat/linear_programming_constraint.cc +++ b/ortools/sat/linear_programming_constraint.cc @@ -43,7 +43,6 @@ #include "ortools/glop/revised_simplex.h" #include "ortools/glop/status.h" #include "ortools/glop/variables_info.h" -#include "ortools/lp_data/lp_data.h" #include "ortools/lp_data/lp_data_utils.h" #include "ortools/lp_data/lp_types.h" #include "ortools/lp_data/scattered_vector.h" @@ -52,6 +51,7 @@ #include "ortools/sat/cuts.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" diff --git a/ortools/sat/linear_programming_constraint.h b/ortools/sat/linear_programming_constraint.h index e2cb160cf6..9f50ef8a69 100644 --- a/ortools/sat/linear_programming_constraint.h +++ b/ortools/sat/linear_programming_constraint.h @@ -16,7 +16,6 @@ #include #include -#include #include #include #include @@ -31,7 +30,6 @@ #include "ortools/glop/parameters.pb.h" #include "ortools/glop/revised_simplex.h" #include "ortools/glop/variables_info.h" -#include "ortools/lp_data/lp_data.h" #include "ortools/lp_data/lp_data_utils.h" #include "ortools/lp_data/lp_types.h" #include "ortools/sat/cp_model.pb.h" @@ -39,9 +37,11 @@ #include "ortools/sat/cuts.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" +#include "ortools/sat/linear_propagation.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/linear_programming_constraint_test.cc b/ortools/sat/linear_programming_constraint_test.cc index 2808ee4f3d..bf89bdc1c6 100644 --- a/ortools/sat/linear_programming_constraint_test.cc +++ b/ortools/sat/linear_programming_constraint_test.cc @@ -16,20 +16,17 @@ #include #include -#include #include #include #include #include "absl/log/check.h" -#include "absl/random/random.h" #include "absl/types/span.h" #include "gtest/gtest.h" -#include "ortools/base/gmock.h" -#include "ortools/base/mathutil.h" #include "ortools/lp_data/lp_types.h" #include "ortools/sat/cp_model_solver.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" diff --git a/ortools/sat/linear_propagation.cc b/ortools/sat/linear_propagation.cc index 99299211b4..51947c9769 100644 --- a/ortools/sat/linear_propagation.cc +++ b/ortools/sat/linear_propagation.cc @@ -36,6 +36,7 @@ #include "ortools/base/stl_util.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/precedences.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/linear_propagation.h b/ortools/sat/linear_propagation.h index ff8927ffd1..6002107dac 100644 --- a/ortools/sat/linear_propagation.h +++ b/ortools/sat/linear_propagation.h @@ -26,15 +26,16 @@ #include "absl/base/attributes.h" #include "absl/container/inlined_vector.h" -#include "absl/strings/string_view.h" +#include "absl/log/check.h" #include "absl/types/span.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/precedences.h" #include "ortools/sat/sat_base.h" -#include "ortools/sat/sat_solver.h" #include "ortools/sat/synchronization.h" +#include "ortools/sat/util.h" #include "ortools/util/bitset.h" #include "ortools/util/rev.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/linear_propagation_test.cc b/ortools/sat/linear_propagation_test.cc index aeda248a41..5a45f7dff4 100644 --- a/ortools/sat/linear_propagation_test.cc +++ b/ortools/sat/linear_propagation_test.cc @@ -15,7 +15,6 @@ #include -#include #include #include "absl/log/check.h" @@ -23,6 +22,7 @@ #include "gtest/gtest.h" #include "ortools/base/gmock.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/linear_relaxation.cc b/ortools/sat/linear_relaxation.cc index 427374e6b9..b20f1b6c59 100644 --- a/ortools/sat/linear_relaxation.cc +++ b/ortools/sat/linear_relaxation.cc @@ -42,6 +42,7 @@ #include "ortools/sat/diffn_cuts.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" diff --git a/ortools/sat/linear_relaxation.h b/ortools/sat/linear_relaxation.h index d4aa402682..ea928c88e5 100644 --- a/ortools/sat/linear_relaxation.h +++ b/ortools/sat/linear_relaxation.h @@ -20,7 +20,7 @@ #include "absl/types/span.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cuts.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/linear_relaxation_test.cc b/ortools/sat/linear_relaxation_test.cc index 14c0682f28..4b56175ad4 100644 --- a/ortools/sat/linear_relaxation_test.cc +++ b/ortools/sat/linear_relaxation_test.cc @@ -25,6 +25,7 @@ #include "ortools/sat/cp_model_loader.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/lp_utils.cc b/ortools/sat/lp_utils.cc index 952427f817..4578764ac1 100644 --- a/ortools/sat/lp_utils.cc +++ b/ortools/sat/lp_utils.cc @@ -36,7 +36,7 @@ #include "ortools/sat/boolean_problem.pb.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_utils.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/util/fp_utils.h" #include "ortools/util/logging.h" diff --git a/ortools/sat/lp_utils.h b/ortools/sat/lp_utils.h index 5f049d9621..058c3ae26b 100644 --- a/ortools/sat/lp_utils.h +++ b/ortools/sat/lp_utils.h @@ -27,7 +27,6 @@ #include "ortools/sat/boolean_problem.pb.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/sat_parameters.pb.h" -#include "ortools/sat/sat_solver.h" #include "ortools/util/logging.h" namespace operations_research { diff --git a/ortools/sat/max_hs.cc b/ortools/sat/max_hs.cc index 83bd855f52..97387effcc 100644 --- a/ortools/sat/max_hs.cc +++ b/ortools/sat/max_hs.cc @@ -32,7 +32,6 @@ #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" -#include "ortools/sat/presolve_util.h" #if !defined(__PORTABLE_PLATFORM__) && defined(USE_SCIP) #include "ortools/linear_solver/solve_mp_model.h" #endif // __PORTABLE_PLATFORM__ @@ -40,11 +39,13 @@ #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_relaxation.h" #include "ortools/sat/model.h" #include "ortools/sat/optimization.h" +#include "ortools/sat/presolve_util.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/max_hs.h b/ortools/sat/max_hs.h index 5aeb001c4b..1747390b7e 100644 --- a/ortools/sat/max_hs.h +++ b/ortools/sat/max_hs.h @@ -28,7 +28,7 @@ #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" -#include "ortools/sat/integer_search.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_relaxation.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/model.h b/ortools/sat/model.h index 8fa8f149dc..9a1305a214 100644 --- a/ortools/sat/model.h +++ b/ortools/sat/model.h @@ -18,9 +18,7 @@ #include #include #include -#include #include -#include #include #include diff --git a/ortools/sat/opb_reader.h b/ortools/sat/opb_reader.h index f5e500e6c8..68cbda4c89 100644 --- a/ortools/sat/opb_reader.h +++ b/ortools/sat/opb_reader.h @@ -16,7 +16,6 @@ #include #include -#include #include #include diff --git a/ortools/sat/optimization.cc b/ortools/sat/optimization.cc index bf9c8c6818..e7ab6dd0b7 100644 --- a/ortools/sat/optimization.cc +++ b/ortools/sat/optimization.cc @@ -16,9 +16,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -28,21 +26,17 @@ #include "absl/container/btree_set.h" #include "absl/container/flat_hash_set.h" #include "absl/log/check.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/random/random.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/stl_util.h" #include "ortools/base/strong_vector.h" -#include "ortools/port/proto_utils.h" -#include "ortools/sat/boolean_problem.h" #include "ortools/sat/boolean_problem.pb.h" #include "ortools/sat/clause.h" #include "ortools/sat/encoding.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_expr.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/optimization.h b/ortools/sat/optimization.h index 4482a3ebca..3fec5edff6 100644 --- a/ortools/sat/optimization.h +++ b/ortools/sat/optimization.h @@ -19,10 +19,10 @@ #include "absl/types/span.h" #include "ortools/sat/clause.h" -#include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" -#include "ortools/sat/integer_search.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" +#include "ortools/sat/pb_constraint.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/optimization_test.cc b/ortools/sat/optimization_test.cc index 0401dc74fa..36bad7386c 100644 --- a/ortools/sat/optimization_test.cc +++ b/ortools/sat/optimization_test.cc @@ -16,26 +16,19 @@ #include #include -#include -#include #include -#include "absl/log/check.h" -#include "absl/random/bit_gen_ref.h" -#include "absl/random/distributions.h" -#include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "ortools/base/gmock.h" -#include "ortools/sat/boolean_problem.h" #include "ortools/sat/boolean_problem.pb.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" #include "ortools/sat/pb_constraint.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/parameters_validation_test.cc b/ortools/sat/parameters_validation_test.cc index 7039a3b78e..28230a474a 100644 --- a/ortools/sat/parameters_validation_test.cc +++ b/ortools/sat/parameters_validation_test.cc @@ -14,7 +14,6 @@ #include "ortools/sat/parameters_validation.h" #include -#include #include "google/protobuf/descriptor.h" #include "google/protobuf/message.h" diff --git a/ortools/sat/pb_constraint.h b/ortools/sat/pb_constraint.h index fb093e8f66..539b5c86aa 100644 --- a/ortools/sat/pb_constraint.h +++ b/ortools/sat/pb_constraint.h @@ -28,7 +28,6 @@ #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" -#include "ortools/base/types.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/pb_constraint_test.cc b/ortools/sat/pb_constraint_test.cc index 5b3d7d91be..8c2712b95f 100644 --- a/ortools/sat/pb_constraint_test.cc +++ b/ortools/sat/pb_constraint_test.cc @@ -14,7 +14,6 @@ #include "ortools/sat/pb_constraint.h" #include -#include #include #include diff --git a/ortools/sat/precedences.cc b/ortools/sat/precedences.cc index 18b2a363d0..5b18cc6302 100644 --- a/ortools/sat/precedences.cc +++ b/ortools/sat/precedences.cc @@ -38,6 +38,7 @@ #include "ortools/sat/clause.h" #include "ortools/sat/cp_constraints.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/precedences.h b/ortools/sat/precedences.h index 2ac790a13f..3bf948edea 100644 --- a/ortools/sat/precedences.h +++ b/ortools/sat/precedences.h @@ -22,19 +22,21 @@ #include #include +#include "absl/container/flat_hash_map.h" #include "absl/container/inlined_vector.h" #include "absl/log/check.h" -#include "absl/strings/string_view.h" #include "absl/types/span.h" #include "ortools/base/strong_vector.h" -#include "ortools/base/types.h" #include "ortools/graph/graph.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" #include "ortools/sat/synchronization.h" +#include "ortools/sat/util.h" #include "ortools/util/bitset.h" +#include "ortools/util/rev.h" #include "ortools/util/strong_integers.h" namespace operations_research { diff --git a/ortools/sat/precedences_test.cc b/ortools/sat/precedences_test.cc index a18cfe2698..64d2fb5205 100644 --- a/ortools/sat/precedences_test.cc +++ b/ortools/sat/precedences_test.cc @@ -20,12 +20,12 @@ #include "gtest/gtest.h" #include "ortools/base/gmock.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" #include "ortools/util/sorted_interval_list.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/presolve_util.cc b/ortools/sat/presolve_util.cc index 6dfaa8f80d..d2b1fbc914 100644 --- a/ortools/sat/presolve_util.cc +++ b/ortools/sat/presolve_util.cc @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/ortools/sat/probing.cc b/ortools/sat/probing.cc index 37d9b7d9d3..c7dfa22db4 100644 --- a/ortools/sat/probing.cc +++ b/ortools/sat/probing.cc @@ -31,6 +31,7 @@ #include "ortools/sat/clause.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/probing.h b/ortools/sat/probing.h index 801951896b..e29d6e7898 100644 --- a/ortools/sat/probing.h +++ b/ortools/sat/probing.h @@ -27,6 +27,7 @@ #include "ortools/sat/clause.h" #include "ortools/sat/implied_bounds.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/probing_test.cc b/ortools/sat/probing_test.cc index d57e474447..3830ec5f28 100644 --- a/ortools/sat/probing_test.cc +++ b/ortools/sat/probing_test.cc @@ -13,11 +13,10 @@ #include "ortools/sat/probing.h" -#include - #include "absl/types/span.h" #include "gtest/gtest.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" diff --git a/ortools/sat/pseudo_costs.cc b/ortools/sat/pseudo_costs.cc index 75e424d3a5..5dd1537072 100644 --- a/ortools/sat/pseudo_costs.cc +++ b/ortools/sat/pseudo_costs.cc @@ -29,6 +29,7 @@ #include "ortools/base/strong_vector.h" #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/linear_programming_constraint.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/pseudo_costs.h b/ortools/sat/pseudo_costs.h index 84486f19af..5cd1e9e964 100644 --- a/ortools/sat/pseudo_costs.h +++ b/ortools/sat/pseudo_costs.h @@ -19,9 +19,12 @@ #include #include "absl/log/check.h" +#include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" +#include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/linear_programming_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/pseudo_costs_test.cc b/ortools/sat/pseudo_costs_test.cc index fc0b98ad9d..8e01f26e0d 100644 --- a/ortools/sat/pseudo_costs_test.cc +++ b/ortools/sat/pseudo_costs_test.cc @@ -13,11 +13,12 @@ #include "ortools/sat/pseudo_costs.h" -#include #include #include "gtest/gtest.h" +#include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/restart_test.cc b/ortools/sat/restart_test.cc index fd319ed33d..f31c77ae71 100644 --- a/ortools/sat/restart_test.cc +++ b/ortools/sat/restart_test.cc @@ -13,8 +13,6 @@ #include "ortools/sat/restart.h" -#include - #include "absl/base/macros.h" #include "gtest/gtest.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/rins.cc b/ortools/sat/rins.cc index edff8f5048..a85f00b1dd 100644 --- a/ortools/sat/rins.cc +++ b/ortools/sat/rins.cc @@ -25,10 +25,11 @@ #include "absl/log/check.h" #include "absl/random/bit_gen_ref.h" #include "absl/random/distributions.h" +#include "absl/strings/str_cat.h" #include "absl/types/span.h" #include "ortools/sat/cp_model_mapping.h" -#include "ortools/sat/integer.h" -#include "ortools/sat/linear_programming_constraint.h" +#include "ortools/sat/integer_base.h" +#include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/model.h" #include "ortools/sat/synchronization.h" diff --git a/ortools/sat/rins.h b/ortools/sat/rins.h index 29513bfec5..4ecd611dd2 100644 --- a/ortools/sat/rins.h +++ b/ortools/sat/rins.h @@ -20,11 +20,8 @@ #include #include "absl/random/bit_gen_ref.h" -#include "ortools/sat/integer.h" -#include "ortools/sat/linear_programming_constraint.h" #include "ortools/sat/model.h" #include "ortools/sat/synchronization.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/routing_cuts.cc b/ortools/sat/routing_cuts.cc index 541752a9c7..5469788776 100644 --- a/ortools/sat/routing_cuts.cc +++ b/ortools/sat/routing_cuts.cc @@ -24,7 +24,7 @@ #include #include "absl/cleanup/cleanup.h" -#include "absl/container/inlined_vector.h" +#include "absl/container/flat_hash_set.h" #include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" @@ -35,6 +35,7 @@ #include "ortools/graph/max_flow.h" #include "ortools/sat/cuts.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/routing_cuts.h b/ortools/sat/routing_cuts.h index c3d28b1150..5df9b09179 100644 --- a/ortools/sat/routing_cuts.h +++ b/ortools/sat/routing_cuts.h @@ -18,14 +18,13 @@ #include #include -#include #include #include #include "absl/types/span.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cuts.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/routing_cuts_test.cc b/ortools/sat/routing_cuts_test.cc index e2adb9da48..3f675b0ded 100644 --- a/ortools/sat/routing_cuts_test.cc +++ b/ortools/sat/routing_cuts_test.cc @@ -15,17 +15,22 @@ #include #include +#include #include #include #include +#include "absl/random/distributions.h" +#include "absl/random/random.h" #include "absl/types/span.h" #include "gtest/gtest.h" #include "ortools/base/gmock.h" +#include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" #include "ortools/graph/max_flow.h" #include "ortools/sat/cuts.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/sat_base_test.cc b/ortools/sat/sat_base_test.cc index 391efb1d09..76b6543947 100644 --- a/ortools/sat/sat_base_test.cc +++ b/ortools/sat/sat_base_test.cc @@ -13,10 +13,7 @@ #include "ortools/sat/sat_base.h" -#include - #include "gtest/gtest.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/sat_decision.cc b/ortools/sat/sat_decision.cc index 46e9b4ed6f..ce0d940a0a 100644 --- a/ortools/sat/sat_decision.cc +++ b/ortools/sat/sat_decision.cc @@ -20,12 +20,13 @@ #include #include "absl/log/check.h" +#include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/model.h" -#include "ortools/sat/pb_constraint.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" +#include "ortools/sat/synchronization.h" #include "ortools/sat/util.h" #include "ortools/util/bitset.h" #include "ortools/util/integer_pq.h" diff --git a/ortools/sat/sat_decision.h b/ortools/sat/sat_decision.h index dc5491748b..cfee3b8b3b 100644 --- a/ortools/sat/sat_decision.h +++ b/ortools/sat/sat_decision.h @@ -18,10 +18,9 @@ #include #include +#include "absl/types/span.h" #include "ortools/base/strong_vector.h" -#include "ortools/base/types.h" #include "ortools/sat/model.h" -#include "ortools/sat/pb_constraint.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/synchronization.h" diff --git a/ortools/sat/sat_decision_test.cc b/ortools/sat/sat_decision_test.cc index 2491fc17bd..ce0988dc13 100644 --- a/ortools/sat/sat_decision_test.cc +++ b/ortools/sat/sat_decision_test.cc @@ -23,7 +23,6 @@ #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/sat_inprocessing.cc b/ortools/sat/sat_inprocessing.cc index 24a7de25b8..101a404e21 100644 --- a/ortools/sat/sat_inprocessing.cc +++ b/ortools/sat/sat_inprocessing.cc @@ -24,7 +24,6 @@ #include "absl/cleanup/cleanup.h" #include "absl/container/inlined_vector.h" #include "absl/log/check.h" -#include "absl/random/distributions.h" #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/base/stl_util.h" diff --git a/ortools/sat/sat_inprocessing.h b/ortools/sat/sat_inprocessing.h index f7eadca3a7..db4b11d892 100644 --- a/ortools/sat/sat_inprocessing.h +++ b/ortools/sat/sat_inprocessing.h @@ -25,7 +25,6 @@ #include #include -#include "absl/strings/string_view.h" #include "absl/types/span.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/clause.h" @@ -38,6 +37,7 @@ #include "ortools/sat/sat_solver.h" #include "ortools/sat/util.h" #include "ortools/util/integer_pq.h" +#include "ortools/util/logging.h" #include "ortools/util/strong_integers.h" #include "ortools/util/time_limit.h" diff --git a/ortools/sat/sat_inprocessing_test.cc b/ortools/sat/sat_inprocessing_test.cc index 291ca0aff9..1f9164c620 100644 --- a/ortools/sat/sat_inprocessing_test.cc +++ b/ortools/sat/sat_inprocessing_test.cc @@ -13,7 +13,6 @@ #include "ortools/sat/sat_inprocessing.h" -#include #include #include "absl/container/inlined_vector.h" diff --git a/ortools/sat/sat_solver.h b/ortools/sat/sat_solver.h index 074050519e..3bd16ace19 100644 --- a/ortools/sat/sat_solver.h +++ b/ortools/sat/sat_solver.h @@ -29,14 +29,10 @@ #include #include "absl/base/attributes.h" -#include "absl/container/flat_hash_map.h" #include "absl/log/check.h" -#include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "ortools/base/hash.h" #include "ortools/base/logging.h" #include "ortools/base/timer.h" -#include "ortools/base/types.h" #include "ortools/sat/clause.h" #include "ortools/sat/drat_proof_handler.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/scheduling_cuts.cc b/ortools/sat/scheduling_cuts.cc index b6cded7eb5..ff61542625 100644 --- a/ortools/sat/scheduling_cuts.cc +++ b/ortools/sat/scheduling_cuts.cc @@ -37,6 +37,7 @@ #include "ortools/base/strong_vector.h" #include "ortools/sat/cuts.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" diff --git a/ortools/sat/scheduling_cuts.h b/ortools/sat/scheduling_cuts.h index 8e4e130ad6..1e51371922 100644 --- a/ortools/sat/scheduling_cuts.h +++ b/ortools/sat/scheduling_cuts.h @@ -20,6 +20,7 @@ #include "ortools/sat/cuts.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/scheduling_cuts_test.cc b/ortools/sat/scheduling_cuts_test.cc index da3741ef55..191c656e3a 100644 --- a/ortools/sat/scheduling_cuts_test.cc +++ b/ortools/sat/scheduling_cuts_test.cc @@ -31,6 +31,7 @@ #include "ortools/sat/cp_model_solver.h" #include "ortools/sat/cuts.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/linear_constraint.h" #include "ortools/sat/linear_constraint_manager.h" diff --git a/ortools/sat/shaving_solver.cc b/ortools/sat/shaving_solver.cc index 30ca5613d6..0ea4044f14 100644 --- a/ortools/sat/shaving_solver.cc +++ b/ortools/sat/shaving_solver.cc @@ -32,7 +32,7 @@ #include "ortools/sat/cp_model_presolve.h" #include "ortools/sat/cp_model_solver_helpers.h" #include "ortools/sat/cp_model_utils.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/presolve_context.h" #include "ortools/sat/subsolver.h" diff --git a/ortools/sat/shaving_solver.h b/ortools/sat/shaving_solver.h index 0f33b3672b..766b83083d 100644 --- a/ortools/sat/shaving_solver.h +++ b/ortools/sat/shaving_solver.h @@ -26,7 +26,7 @@ #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_lns.h" #include "ortools/sat/cp_model_solver_helpers.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/subsolver.h" diff --git a/ortools/sat/simplification.cc b/ortools/sat/simplification.cc index a7f755add4..2babe8efd4 100644 --- a/ortools/sat/simplification.cc +++ b/ortools/sat/simplification.cc @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -33,10 +32,7 @@ #include "ortools/base/timer.h" #include "ortools/graph/strongly_connected_components.h" #include "ortools/sat/drat_proof_handler.h" -#include "ortools/sat/model.h" -#include "ortools/sat/probing.h" #include "ortools/sat/sat_base.h" -#include "ortools/sat/sat_inprocessing.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" #include "ortools/util/logging.h" diff --git a/ortools/sat/simplification.h b/ortools/sat/simplification.h index 0e1663ea5a..ea2199a1c9 100644 --- a/ortools/sat/simplification.h +++ b/ortools/sat/simplification.h @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -29,13 +28,11 @@ #include "absl/types/span.h" #include "ortools/base/adjustable_priority_queue.h" #include "ortools/base/strong_vector.h" -#include "ortools/base/types.h" #include "ortools/sat/drat_proof_handler.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/sat_solver.h" #include "ortools/util/logging.h" -#include "ortools/util/strong_integers.h" #include "ortools/util/time_limit.h" namespace operations_research { diff --git a/ortools/sat/stat_tables.h b/ortools/sat/stat_tables.h index f3b233909e..c696db0f69 100644 --- a/ortools/sat/stat_tables.h +++ b/ortools/sat/stat_tables.h @@ -14,16 +14,17 @@ #ifndef OR_TOOLS_SAT_STAT_TABLES_H_ #define OR_TOOLS_SAT_STAT_TABLES_H_ +#include #include #include #include +#include "absl/base/thread_annotations.h" #include "absl/container/btree_map.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" #include "ortools/sat/model.h" #include "ortools/sat/subsolver.h" -#include "ortools/sat/util.h" #include "ortools/util/logging.h" namespace operations_research::sat { diff --git a/ortools/sat/subsolver.h b/ortools/sat/subsolver.h index 1a0886d66d..6dc08177c8 100644 --- a/ortools/sat/subsolver.h +++ b/ortools/sat/subsolver.h @@ -27,12 +27,10 @@ #include #include "absl/strings/string_view.h" -#include "ortools/base/types.h" #include "ortools/sat/util.h" #include "ortools/util/stats.h" #if !defined(__PORTABLE_PLATFORM__) -#include "ortools/base/threadpool.h" #endif // __PORTABLE_PLATFORM__ namespace operations_research { diff --git a/ortools/sat/symmetry.h b/ortools/sat/symmetry.h index 3e94bfd639..cfbf0fdcd1 100644 --- a/ortools/sat/symmetry.h +++ b/ortools/sat/symmetry.h @@ -14,6 +14,7 @@ #ifndef OR_TOOLS_SAT_SYMMETRY_H_ #define OR_TOOLS_SAT_SYMMETRY_H_ +#include #include #include diff --git a/ortools/sat/synchronization.cc b/ortools/sat/synchronization.cc index e116822809..6676aff803 100644 --- a/ortools/sat/synchronization.cc +++ b/ortools/sat/synchronization.cc @@ -54,7 +54,6 @@ #include "ortools/sat/cp_model_utils.h" #include "ortools/sat/integer_base.h" #include "ortools/sat/model.h" -#include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/symmetry_util.h" #include "ortools/sat/util.h" diff --git a/ortools/sat/table.cc b/ortools/sat/table.cc index 4131f3c2e5..711ef3a0ec 100644 --- a/ortools/sat/table.cc +++ b/ortools/sat/table.cc @@ -23,7 +23,6 @@ #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_solver.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/table.h b/ortools/sat/table.h index 476a77e15c..1850d9f421 100644 --- a/ortools/sat/table.h +++ b/ortools/sat/table.h @@ -14,13 +14,10 @@ #ifndef OR_TOOLS_SAT_TABLE_H_ #define OR_TOOLS_SAT_TABLE_H_ -#include #include #include #include "absl/types/span.h" -#include "ortools/base/types.h" -#include "ortools/sat/integer.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/theta_tree.cc b/ortools/sat/theta_tree.cc index 18a983f33c..a8a87559d0 100644 --- a/ortools/sat/theta_tree.cc +++ b/ortools/sat/theta_tree.cc @@ -17,7 +17,7 @@ #include #include "absl/log/check.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/theta_tree.h b/ortools/sat/theta_tree.h index d817a328b0..c9c3221f00 100644 --- a/ortools/sat/theta_tree.h +++ b/ortools/sat/theta_tree.h @@ -15,10 +15,10 @@ #define OR_TOOLS_SAT_THETA_TREE_H_ #include +#include #include -#include "ortools/base/logging.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/theta_tree_test.cc b/ortools/sat/theta_tree_test.cc index 3e3ebb8964..08dfe5002c 100644 --- a/ortools/sat/theta_tree_test.cc +++ b/ortools/sat/theta_tree_test.cc @@ -20,7 +20,7 @@ #include "benchmark/benchmark.h" #include "gtest/gtest.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/util/random_engine.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/timetable.cc b/ortools/sat/timetable.cc index 66e7c6e491..039dc6e190 100644 --- a/ortools/sat/timetable.cc +++ b/ortools/sat/timetable.cc @@ -20,6 +20,7 @@ #include "absl/log/check.h" #include "absl/types/span.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" diff --git a/ortools/sat/timetable.h b/ortools/sat/timetable.h index 51436762df..6f5e832248 100644 --- a/ortools/sat/timetable.h +++ b/ortools/sat/timetable.h @@ -18,10 +18,10 @@ #include #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" -#include "ortools/util/rev.h" #include "ortools/util/strong_integers.h" namespace operations_research { diff --git a/ortools/sat/timetable_edgefinding.cc b/ortools/sat/timetable_edgefinding.cc index fe28644821..5d4b4dfde6 100644 --- a/ortools/sat/timetable_edgefinding.cc +++ b/ortools/sat/timetable_edgefinding.cc @@ -19,6 +19,7 @@ #include "absl/log/check.h" #include "ortools/base/iterator_adaptors.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/timetable_edgefinding.h b/ortools/sat/timetable_edgefinding.h index 74269c2b67..ec37fa4e62 100644 --- a/ortools/sat/timetable_edgefinding.h +++ b/ortools/sat/timetable_edgefinding.h @@ -17,10 +17,9 @@ #include #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" -#include "ortools/sat/sat_base.h" -#include "ortools/util/strong_integers.h" namespace operations_research { namespace sat { diff --git a/ortools/sat/timetable_test.cc b/ortools/sat/timetable_test.cc index c8999baedd..b7b40b36a0 100644 --- a/ortools/sat/timetable_test.cc +++ b/ortools/sat/timetable_test.cc @@ -28,6 +28,7 @@ #include "ortools/sat/all_different.h" #include "ortools/sat/cumulative.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/intervals.h" #include "ortools/sat/model.h" diff --git a/ortools/sat/util.cc b/ortools/sat/util.cc index adef1c0cff..ab9163bafb 100644 --- a/ortools/sat/util.cc +++ b/ortools/sat/util.cc @@ -17,17 +17,13 @@ #include #include #include -#include #include #include #include -#include #include #include "absl/algorithm/container.h" #include "absl/container/btree_set.h" -#include "absl/container/flat_hash_map.h" -#include "absl/container/inlined_vector.h" #include "absl/log/check.h" #include "absl/numeric/int128.h" #include "absl/random/bit_gen_ref.h" @@ -37,7 +33,6 @@ #include "google/protobuf/descriptor.h" #include "ortools/base/logging.h" #include "ortools/base/mathutil.h" -#include "ortools/base/stl_util.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/util/saturated_arithmetic.h" diff --git a/ortools/sat/util.h b/ortools/sat/util.h index 4715f3e412..25c2bab400 100644 --- a/ortools/sat/util.h +++ b/ortools/sat/util.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -25,7 +26,6 @@ #include #include -#include "absl/base/macros.h" #include "absl/container/btree_set.h" #include "absl/log/check.h" #include "absl/log/log_streamer.h" @@ -36,7 +36,6 @@ #include "absl/strings/string_view.h" #include "absl/types/span.h" #include "ortools/base/logging.h" -#include "ortools/base/mathutil.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/var_domination.h b/ortools/sat/var_domination.h index 36428743be..97a9d44b32 100644 --- a/ortools/sat/var_domination.h +++ b/ortools/sat/var_domination.h @@ -23,7 +23,7 @@ #include "ortools/algorithms/dynamic_partition.h" #include "ortools/base/strong_vector.h" #include "ortools/sat/cp_model_utils.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/presolve_context.h" namespace operations_research { diff --git a/ortools/sat/work_assignment.cc b/ortools/sat/work_assignment.cc index dea3480f71..ce3518f11f 100644 --- a/ortools/sat/work_assignment.cc +++ b/ortools/sat/work_assignment.cc @@ -35,6 +35,7 @@ #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/cp_model_utils.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" #include "ortools/sat/restart.h" diff --git a/ortools/sat/work_assignment.h b/ortools/sat/work_assignment.h index dab12d7165..e4ce63772d 100644 --- a/ortools/sat/work_assignment.h +++ b/ortools/sat/work_assignment.h @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -38,8 +37,10 @@ #include "ortools/sat/cp_model_mapping.h" #include "ortools/sat/cp_model_utils.h" #include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/integer_search.h" #include "ortools/sat/model.h" +#include "ortools/sat/restart.h" #include "ortools/sat/sat_base.h" #include "ortools/sat/sat_decision.h" #include "ortools/sat/sat_parameters.pb.h" diff --git a/ortools/sat/work_assignment_test.cc b/ortools/sat/work_assignment_test.cc index cda049d48c..4242e46eba 100644 --- a/ortools/sat/work_assignment_test.cc +++ b/ortools/sat/work_assignment_test.cc @@ -24,7 +24,6 @@ #include "ortools/sat/cp_model_checker.h" #include "ortools/sat/cp_model_loader.h" #include "ortools/sat/cp_model_solver.h" -#include "ortools/sat/integer.h" #include "ortools/sat/model.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/sat/synchronization.h" diff --git a/ortools/sat/zero_half_cuts.cc b/ortools/sat/zero_half_cuts.cc index ffe51981bd..0c2abbf50b 100644 --- a/ortools/sat/zero_half_cuts.cc +++ b/ortools/sat/zero_half_cuts.cc @@ -21,7 +21,7 @@ #include "absl/types/span.h" #include "ortools/base/logging.h" #include "ortools/lp_data/lp_types.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/util.h" #include "ortools/util/strong_integers.h" diff --git a/ortools/sat/zero_half_cuts.h b/ortools/sat/zero_half_cuts.h index 0d307a845e..50dad24617 100644 --- a/ortools/sat/zero_half_cuts.h +++ b/ortools/sat/zero_half_cuts.h @@ -14,13 +14,12 @@ #ifndef OR_TOOLS_SAT_ZERO_HALF_CUTS_H_ #define OR_TOOLS_SAT_ZERO_HALF_CUTS_H_ -#include #include #include #include "absl/types/span.h" #include "ortools/lp_data/lp_types.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" #include "ortools/sat/util.h" namespace operations_research { diff --git a/ortools/sat/zero_half_cuts_test.cc b/ortools/sat/zero_half_cuts_test.cc index 6aea31cdcd..99b1e21389 100644 --- a/ortools/sat/zero_half_cuts_test.cc +++ b/ortools/sat/zero_half_cuts_test.cc @@ -19,7 +19,7 @@ #include "gtest/gtest.h" #include "ortools/base/gmock.h" #include "ortools/lp_data/lp_types.h" -#include "ortools/sat/integer.h" +#include "ortools/sat/integer_base.h" namespace operations_research { namespace sat { diff --git a/ortools/util/BUILD.bazel b/ortools/util/BUILD.bazel index 2baac1d127..015c70dde2 100644 --- a/ortools/util/BUILD.bazel +++ b/ortools/util/BUILD.bazel @@ -522,6 +522,16 @@ cc_library( ], ) +cc_library( + name = "fixed_shape_binary_tree", + hdrs = ["fixed_shape_binary_tree.h"], + deps = [ + ":strong_integers", + "@com_google_absl//absl/log:check", + "@com_google_absl//absl/numeric:bits", + ], +) + cc_library( name = "solve_interrupter", srcs = ["solve_interrupter.cc"], diff --git a/ortools/util/fixed_shape_binary_tree.h b/ortools/util/fixed_shape_binary_tree.h new file mode 100644 index 0000000000..d326c8e727 --- /dev/null +++ b/ortools/util/fixed_shape_binary_tree.h @@ -0,0 +1,277 @@ +// Copyright 2010-2024 Google LLC +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OR_TOOLS_UTIL_FIXED_SHAPE_BINARY_TREE_H_ +#define OR_TOOLS_UTIL_FIXED_SHAPE_BINARY_TREE_H_ + +#include +#include + +#include "absl/log/check.h" +#include "absl/numeric/bits.h" +#include "ortools/util/strong_integers.h" + +namespace operations_research { + +DEFINE_STRONG_INDEX_TYPE(TreeNodeIndex); +DEFINE_STRONG_INDEX_TYPE(LeafIndex); + +// An abstract representation of a binary tree that can hold integers in the +// range [0, num_leaves - 1] and has a depth of exactly +// 1+ceil(log2(num_leaves)). For example, a FixedShapeBinaryTree(5) +// can be represented by: +// [0, 4] +// / \ +// / \ +// / \ +// [0, 3] [4, 4] +// / \ / \ +// / \ / \ +// [0, 1] [2, 3] [4, 4] [-1, -1] +// / \ / \ / \ / \ +// 0 1 2 3 4 -1 -1 -1 +// +// The most common use of this class is to have a concrete binary tree by +// defining its storage like: +// StrongVector tree(abstract_tree.StorageSize()); +// +// Besides the classical binary tree structure of left and right children, this +// class provides an API to inspect and search the intermediate nodes by their +// interval values. +class FixedShapeBinaryTree { + public: + explicit FixedShapeBinaryTree(LeafIndex num_leaves) + : largest_leaf_index_(num_leaves - 1) { + max_depth_ = absl::bit_width( + static_cast(2 * largest_leaf_index_.value() + 1)); + leave_start_index_ = 1 << (max_depth_ - 1); + } + + int StorageSize() const { return HighestNodeIndex().value() + 1; } + + // If you want to use a different storage for intermediate nodes and leaves. + TreeNodeIndex HighestIntermediateNodeIndex() const { + return leave_start_index_ - 1; + } + + TreeNodeIndex HighestNodeIndex() const { return LastLeafNode(); } + + bool IsLeaf(TreeNodeIndex node) const { return node >= leave_start_index_; } + + TreeNodeIndex Root() const { return TreeNodeIndex(1); } + + TreeNodeIndex FirstLeafNode() const { + return TreeNodeIndex(leave_start_index_); + } + + TreeNodeIndex LastLeafNode() const { + return leave_start_index_ + largest_leaf_index_.value(); + } + + TreeNodeIndex LeftChild(TreeNodeIndex node) const { + DCHECK(!IsLeaf(node)); + return TreeNodeIndex(node.value() << 1); + } + + TreeNodeIndex RightChild(TreeNodeIndex node) const { + DCHECK(!IsLeaf(node)); + return TreeNodeIndex(node.value() << 1) + TreeNodeIndex(1); + } + + TreeNodeIndex Parent(TreeNodeIndex node) const { + DCHECK_NE(node, Root()); + return TreeNodeIndex(node.value() >> 1); + } + + TreeNodeIndex Sibling(TreeNodeIndex node) const { + DCHECK_NE(node, Root()); + return TreeNodeIndex(node.value() ^ 1); + } + + LeafIndex LeafValue(TreeNodeIndex node) const { + const LeafIndex ret = LeafIndex((node - leave_start_index_).value()); + if (ret > largest_leaf_index_) { + return LeafIndex(-1); + } + return ret; + } + + // Zero for the root. + int Depth(TreeNodeIndex node) const { + return absl::bit_width(static_cast(node.value())) - 1; + } + + // Will return [0, num_leaves - 1] for the root, [x, x] for a leaf with x + // and the range of all the descendants of a node for intermediate nodes. + std::pair GetInterval(TreeNodeIndex node) const { + if (IsLeaf(node)) { + const LeafIndex leaf_value = LeafValue(node); + return {leaf_value, leaf_value}; + } + const int depth = Depth(node); + const int pos = node.value() - (1 << depth); + const int min = pos << (max_depth_ - depth - 1); + if (min > largest_leaf_index_) { + return {LeafIndex(-1), LeafIndex(-1)}; + } + const int max = ((pos + 1) << (max_depth_ - depth - 1)) - 1; + return {LeafIndex(min), + LeafIndex(std::min(max, largest_leaf_index_.value()))}; + } + + // Given a range of leaf indexes [first_leaf, last_leaf], return the largest + // node in the tree associated to an interval [int_begin, int_end] that + // satisfies: + // - int_begin == first_leaf + // - int_end <= last_leaf. + // For example, GetNodeStartOfRange(0, num_leaves - 1) = Root(). + // + // This corresponds to a starting node to do a DFS traversal (including all + // its children) to cover all intervals fully contained in the range [begin, + // end]. + TreeNodeIndex GetNodeStartOfRange(LeafIndex first_leaf, + LeafIndex last_leaf) const { + DCHECK_LE(first_leaf, last_leaf); + DCHECK_GE(first_leaf, 0); + DCHECK_LE(last_leaf, largest_leaf_index_); + + if (last_leaf == largest_leaf_index_) { + // Since we truncate the intervals to the largest_leaf_index_, this is + // equivalent on the full binary tree to look for the largest possible + // value. + last_leaf = (1 << (max_depth_ - 1)) - 1; + } + if (first_leaf == last_leaf) { + return GetLeaf(first_leaf); + } + + // To see how high we can go on the tree we need to check the two rules: + // - we need to start at `first_leaf`, so we need to know which power of two + // divides `first_leaf` (odd are leaves, divisible by 2 but not by 4 are + // right above the leaves, etc). + // - the interval needs to be not greater than `last_leaf - first_leaf`. If + // `last_leaf - first_leaf` is zero it must be a leaf, if it is one it can + // be one step above, etc). + const int power_of_two_div = + absl::countr_zero(static_cast(first_leaf.value())); + const int log2_size = absl::bit_width(static_cast( + last_leaf.value() - first_leaf.value() + 1)) - + 1; + const int height = std::min(log2_size, power_of_two_div); + const int pos = first_leaf.value() >> height; + const int depth = max_depth_ - height - 1; + TreeNodeIndex start; + start = (1 << depth) + pos; + return start; + } + + // Given a range of values, return the largest node in the tree associated to + // an interval [int_begin, int_end] that satisfies: + // - int_end == first_leaf + // - int_begin >= last_leaf. + // For example, GetNodeEndOfRange(0, largest_leaf_index) = Root(). + // + // This corresponds to a last node (including all its descendants) to do a DFS + // traversal to cover all intervals fully contained in the range [begin, end]. + TreeNodeIndex GetNodeEndOfRange(LeafIndex first_leaf, + LeafIndex last_leaf) const { + DCHECK_LT(first_leaf, last_leaf); + DCHECK_GE(first_leaf, 0); + DCHECK_LE(last_leaf, largest_leaf_index_); + + if (first_leaf == last_leaf) { + return GetLeaf(first_leaf); + } + + // To see how high we can go on the tree we need to check the two rules: + // - we need to end at `last_leaf`, so we need to know which power of two + // divides `last_leaf+1`. + // - the interval needs to be not greater than `last_leaf - first_leaf`. If + // `last_leaf - first_leaf` is zero it must be a leaf, if it is one it can + // be one step + // above, etc). + const int log2_size = absl::bit_width(static_cast( + last_leaf.value() - first_leaf.value() + 1)) - + 1; + const int power_of_two_div = + absl::countr_zero(static_cast(last_leaf.value() + 1)); + const int height = std::min(log2_size, power_of_two_div); + const int pos = last_leaf.value() >> height; + const int depth = max_depth_ - height - 1; + TreeNodeIndex int_end; + int_end = (1 << depth) + pos; + return int_end; + } + + // Given an interval [first_leaf, last_leaf], return O(log n) ordered disjoint + // nodes of the tree that cover the interval. The time complexity is O(log n). + template + void PartitionIntervalIntoNodes(LeafIndex first_leaf, LeafIndex last_leaf, + TypeWithPushBack* result) const { + TreeNodeIndex prev(0); + TreeNodeIndex current = GetNodeStartOfRange(first_leaf, last_leaf); + if (current == Root()) { + result->push_back(current); + return; + } + while (true) { + const auto& [min, max] = GetInterval(current); + if (min >= first_leaf && max <= last_leaf) { + result->push_back(current); + if (max == last_leaf) { + return; + } + prev = current; + current = Parent(current); + continue; + } + if (prev == TreeNodeIndex(0)) { + prev = current; + current = Parent(current); + } else if (prev != Root() && current == Parent(prev)) { + // We just moved up. + if (prev == LeftChild(current)) { + prev = current; + current = RightChild(current); + } else { + DCHECK_EQ(prev, RightChild(current)); + prev = current; + current = Parent(current); + } + } else { + // We just moved down. + if (IsLeaf(current)) { + prev = current; + current = Parent(current); + } else { + DCHECK_EQ(prev, Parent(current)); + prev = current; + current = LeftChild(current); + } + } + } + } + + TreeNodeIndex GetLeaf(LeafIndex value) const { + return leave_start_index_ + value.value(); + } + + private: + TreeNodeIndex leave_start_index_; + LeafIndex largest_leaf_index_; + int max_depth_; +}; + +} // namespace operations_research + +#endif // OR_TOOLS_UTIL_FIXED_SHAPE_BINARY_TREE_H_