14 #ifndef OR_TOOLS_SAT_DIFFN_H_ 15 #define OR_TOOLS_SAT_DIFFN_H_ 50 void SortBoxesIntoNeighbors(
int box,
absl::Span<const
int> local_boxes,
51 IntegerValue total_sum_of_areas);
52 bool FailWhenEnergyIsTooLarge(
int box,
absl::Span<const
int> local_boxes,
53 IntegerValue total_sum_of_areas);
61 IntegerValue threshold_x_;
62 IntegerValue threshold_y_;
64 std::vector<
int> active_boxes_;
65 std::vector<IntegerValue> cached_energies_;
66 std::vector<
Rectangle> cached_rectangles_;
70 IntegerValue distance_to_bounding_box;
71 bool operator<(
const Neighbor& o)
const {
72 return distance_to_bounding_box < o.distance_to_bounding_box;
75 std::vector<Neighbor> neighbors_;
98 void Register(
int fast_priority,
int slow_priority);
101 bool PropagateTwoBoxes();
102 bool FindBoxesThatMustOverlapAHorizontalLineAndPropagate(
114 std::vector<IndexedInterval> indexed_intervals_;
115 std::vector<std::vector<int>> events_overlapping_boxes_;
117 absl::flat_hash_set<absl::Span<int>> reduced_overlapping_boxes_;
118 std::vector<absl::Span<int>> boxes_to_propagate_;
119 std::vector<absl::Span<int>> disjoint_boxes_;
146 const std::vector<IntervalVariable>& x,
147 const std::vector<IntervalVariable>& y,
bool is_strict,
148 bool add_cumulative_relaxation =
true) {
154 model->TakeOwnership(x_helper);
155 model->TakeOwnership(y_helper);
162 model->TakeOwnership(energy_constraint);
168 model->TakeOwnership(constraint);
170 if (add_cumulative_relaxation) {
172 bool some_boxes_are_only_optional_on_x =
false;
173 bool some_boxes_are_only_optional_on_y =
false;
174 for (
int i = 0; i < x.size(); ++i) {
183 some_boxes_are_only_optional_on_x =
true;
188 some_boxes_are_only_optional_on_y =
true;
191 if (!some_boxes_are_only_optional_on_y) {
194 if (!some_boxes_are_only_optional_on_x) {
204 #endif // OR_TOOLS_SAT_DIFFN_H_
Class that owns everything related to a particular optimization model.
void AddCumulativeRelaxation(const std::vector< IntervalVariable > &x_intervals, SchedulingConstraintHelper *x, SchedulingConstraintHelper *y, Model *model)
void Register(int fast_priority, int slow_priority)
void SetPropagatorPriority(int id, int priority)
~NonOverlappingRectanglesEnergyPropagator() override
int RegisterWith(GenericLiteralWatcher *watcher)
bool IsOptional(int t) const
NonOverlappingRectanglesDisjunctivePropagator(bool strict, SchedulingConstraintHelper *x, SchedulingConstraintHelper *y, Model *model)
Collection of objects used to extend the Constraint Solver library.
~NonOverlappingRectanglesDisjunctivePropagator() override
std::function< void(Model *)> NonOverlappingRectangles(const std::vector< IntervalVariable > &x, const std::vector< IntervalVariable > &y, bool is_strict, bool add_cumulative_relaxation=true)
NonOverlappingRectanglesEnergyPropagator(SchedulingConstraintHelper *x, SchedulingConstraintHelper *y, Model *model)
Literal PresenceLiteral(int index) const