14#ifndef OR_TOOLS_SAT_DIFFN_H_
15#define OR_TOOLS_SAT_DIFFN_H_
20#include "absl/container/flat_hash_set.h"
21#include "absl/types/span.h"
53 void SortBoxesIntoNeighbors(
int box,
absl::Span<const
int> local_boxes,
54 IntegerValue total_sum_of_areas);
55 bool FailWhenEnergyIsTooLarge(
int box,
absl::Span<const
int> local_boxes,
56 IntegerValue total_sum_of_areas);
64 IntegerValue threshold_x_;
65 IntegerValue threshold_y_;
67 std::vector<
int> active_boxes_;
68 std::vector<IntegerValue> cached_energies_;
73 IntegerValue distance_to_bounding_box;
74 bool operator<(
const Neighbor& o)
const {
75 return distance_to_bounding_box < o.distance_to_bounding_box;
78 std::vector<Neighbor> neighbors_;
101 void Register(
int fast_priority,
int slow_priority);
104 bool PropagateTwoBoxes();
105 bool FindBoxesThatMustOverlapAHorizontalLineAndPropagate(
117 std::vector<IndexedInterval> indexed_intervals_;
118 std::vector<std::vector<int>> events_overlapping_boxes_;
120 absl::flat_hash_set<absl::Span<int>> reduced_overlapping_boxes_;
121 std::vector<absl::Span<int>> boxes_to_propagate_;
122 std::vector<absl::Span<int>> disjoint_boxes_;
141 const std::vector<IntervalVariable>& x_intervals,
149 const std::vector<IntervalVariable>& x,
150 const std::vector<IntervalVariable>& y,
bool is_strict,
151 bool add_cumulative_relaxation =
true) {
157 model->TakeOwnership(x_helper);
158 model->TakeOwnership(y_helper);
165 model->TakeOwnership(energy_constraint);
171 model->TakeOwnership(constraint);
173 if (add_cumulative_relaxation) {
175 bool some_boxes_are_only_optional_on_x =
false;
176 bool some_boxes_are_only_optional_on_y =
false;
177 for (
int i = 0; i < x.size(); ++i) {
186 some_boxes_are_only_optional_on_x =
true;
191 some_boxes_are_only_optional_on_y =
true;
194 if (!some_boxes_are_only_optional_on_y) {
197 if (!some_boxes_are_only_optional_on_x) {
void SetPropagatorPriority(int id, int priority)
Class that owns everything related to a particular optimization model.
void Register(int fast_priority, int slow_priority)
~NonOverlappingRectanglesDisjunctivePropagator() override
NonOverlappingRectanglesDisjunctivePropagator(bool strict, SchedulingConstraintHelper *x, SchedulingConstraintHelper *y, Model *model)
NonOverlappingRectanglesEnergyPropagator(SchedulingConstraintHelper *x, SchedulingConstraintHelper *y, Model *model)
int RegisterWith(GenericLiteralWatcher *watcher)
~NonOverlappingRectanglesEnergyPropagator() override
bool IsOptional(int t) const
Literal PresenceLiteral(int index) const
void AddDiffnCumulativeRelationOnX(const std::vector< IntervalVariable > &x_intervals, SchedulingConstraintHelper *x, SchedulingConstraintHelper *y, Model *model)
std::function< void(Model *)> NonOverlappingRectangles(const std::vector< IntervalVariable > &x, const std::vector< IntervalVariable > &y, bool is_strict, bool add_cumulative_relaxation=true)
Collection of objects used to extend the Constraint Solver library.