14#ifndef OR_TOOLS_SAT_DISJUNCTIVE_H_
15#define OR_TOOLS_SAT_DISJUNCTIVE_H_
24#include "absl/strings/str_cat.h"
25#include "absl/types/span.h"
53 absl::Span<const IntervalVariable> intervals,
Model* model);
61 explicit TaskSet(
int num_tasks) { sorted_tasks_.ClearAndReserve(num_tasks); }
74 sorted_tasks_.clear();
75 optimized_restart_ = 0;
92 void Sort() { std::sort(sorted_tasks_.begin(), sorted_tasks_.end()); }
113 IntegerValue
ComputeEndMin(
int task_to_ignore,
int* critical_index)
const;
121 absl::Span<const Entry>
SortedTasks()
const {
return sorted_tasks_; }
125 mutable int optimized_restart_ = 0;
138 if (!VLOG_IS_ON(1))
return;
139 std::vector<std::pair<std::string, int64_t>> stats;
140 stats.push_back({absl::StrCat(
name,
"/num_calls"),
num_calls});
141 stats.push_back({absl::StrCat(
name,
"/num_calls_with_propagation"),
184 Model* model =
nullptr)
186 window_(new
TaskTime[helper->NumTasks()]),
187 task_to_event_(new int[helper->NumTasks()]),
188 stats_(
"DisjunctiveOverloadChecker", model) {
189 task_by_increasing_end_max_.ClearAndReserve(helper->
NumTasks());
196 bool PropagateSubwindow(
int relevant_size, IntegerValue global_window_end);
202 std::unique_ptr<
int[]> task_to_event_;
220 Model* model =
nullptr)
221 : helper_(helper), stats_(
"DisjunctiveSimplePrecedences", model) {}
226 bool PropagateOneDirection();
238 : time_direction_(time_direction),
240 task_set_(helper->NumTasks()),
241 stats_(
"DisjunctiveDetectablePrecedences", model) {
243 to_add_.ClearAndReserve(helper->
NumTasks());
249 bool PropagateWithRanks();
250 bool Push(IntegerValue task_set_end_min,
int t);
253 std::vector<
int> ranks_;
255 const
bool time_direction_;
264template <
bool time_direction>
271 void AddNoOverlap(absl::Span<const IntervalVariable> var);
277 std::vector<
std::vector<
int>> task_to_disjunctives_;
278 std::vector<
bool> task_is_added_;
280 std::vector<IntegerValue> end_mins_;
286 Model* model =
nullptr)
287 : time_direction_(time_direction),
289 task_set_(helper->NumTasks()),
290 stats_(
"DisjunctiveNotLast", model) {
291 start_min_window_.ClearAndReserve(helper->
NumTasks());
292 start_max_window_.ClearAndReserve(helper->
NumTasks());
298 bool PropagateSubwindow();
303 const
bool time_direction_;
314 : time_direction_(time_direction),
316 stats_(
"DisjunctiveEdgeFinding", model) {
317 task_by_increasing_end_max_.ClearAndReserve(helper->
NumTasks());
318 window_.ClearAndReserve(helper->
NumTasks());
319 event_size_.ClearAndReserve(helper->
NumTasks());
325 bool PropagateSubwindow(IntegerValue window_end_min);
327 const
bool time_direction_;
339 std::vector<
int> non_gray_task_to_event_;
340 std::vector<
bool> is_gray_;
352 : time_direction_(time_direction),
356 stats_(
"DisjunctivePrecedences", model) {
357 window_.ClearAndReserve(helper->
NumTasks());
358 index_to_end_vars_.ClearAndReserve(helper->
NumTasks());
359 indices_before_.ClearAndReserve(helper->
NumTasks());
366 bool PropagateSubwindow();
368 const
bool time_direction_;
377 std::vector<
bool> skip_;
void AddNoOverlap(absl::Span< const IntervalVariable > var)
CombinedDisjunctive(Model *model)
DisjunctiveDetectablePrecedences(bool time_direction, SchedulingConstraintHelper *helper, Model *model=nullptr)
DisjunctiveEdgeFinding(bool time_direction, SchedulingConstraintHelper *helper, Model *model=nullptr)
DisjunctiveNotLast(bool time_direction, SchedulingConstraintHelper *helper, Model *model=nullptr)
int RegisterWith(GenericLiteralWatcher *watcher)
DisjunctiveOverloadChecker(SchedulingConstraintHelper *helper, Model *model=nullptr)
DisjunctivePrecedences(bool time_direction, SchedulingConstraintHelper *helper, Model *model)
DisjunctiveSimplePrecedences(SchedulingConstraintHelper *helper, Model *model=nullptr)
DisjunctiveWithTwoItems(SchedulingConstraintHelper *helper)
int RegisterWith(GenericLiteralWatcher *watcher)
Base class for CP like propagators.
PropagatorInterface()=default
int NumTasks() const
Returns the number of task.
Simple class to add statistics by name and print them at the end.
void NotifyEntryIsNowLastIfPresent(const Entry &e)
int GetCriticalIndex() const
void AddEntry(const Entry &e)
void AddUnsortedEntry(const Entry &e)
IntegerValue ComputeEndMin() const
absl::Span< const Entry > SortedTasks() const
void AddShiftedStartMinEntry(const SchedulingConstraintHelper &helper, int t)
void Clear()
Insertion and modification. These leave sorted_tasks_ sorted.
void AddDisjunctive(const std::vector< IntervalVariable > &intervals, Model *model)
void AddDisjunctiveWithBooleanPrecedencesOnly(absl::Span< const IntervalVariable > intervals, Model *model)
In SWIG mode, we don't want anything besides these top-level includes.
Simple class to display statistics at the end if –v=1.
int64_t num_calls_with_propagation
SharedStatistics * shared_stats
PropagationStatistics(std::string _name, Model *model=nullptr)
void EndWithoutConflicts()
bool operator<(Entry other) const