14#ifndef OR_TOOLS_SAT_DISJUNCTIVE_H_
15#define OR_TOOLS_SAT_DISJUNCTIVE_H_
24#include "absl/log/log.h"
25#include "absl/log/vlog_is_on.h"
26#include "absl/strings/str_cat.h"
27#include "absl/types/span.h"
54 absl::Span<const IntervalVariable> intervals,
Model* model);
62 explicit TaskSet(
int num_tasks) { sorted_tasks_.ClearAndReserve(num_tasks); }
75 sorted_tasks_.clear();
76 optimized_restart_ = 0;
93 void Sort() { std::sort(sorted_tasks_.begin(), sorted_tasks_.end()); }
114 IntegerValue
ComputeEndMin(
int task_to_ignore,
int* critical_index)
const;
122 absl::Span<const Entry>
SortedTasks()
const {
return sorted_tasks_; }
126 mutable int optimized_restart_ = 0;
139 if (!VLOG_IS_ON(1))
return;
140 std::vector<std::pair<std::string, int64_t>> stats;
141 stats.push_back({absl::StrCat(
name,
"/num_calls"),
num_calls});
142 stats.push_back({absl::StrCat(
name,
"/num_calls_with_propagation"),
185 Model* model =
nullptr)
187 window_(new
TaskTime[helper->NumTasks()]),
188 task_to_event_(new int[helper->NumTasks()]),
189 stats_(
"DisjunctiveOverloadChecker", model) {
190 task_by_increasing_end_max_.ClearAndReserve(helper->
NumTasks());
197 bool PropagateSubwindow(
int relevant_size, IntegerValue global_window_end);
203 std::unique_ptr<
int[]> task_to_event_;
221 Model* model =
nullptr)
222 : helper_(helper), stats_(
"DisjunctiveSimplePrecedences", model) {}
227 bool PropagateOneDirection();
239 : time_direction_(time_direction),
241 task_set_(helper->NumTasks()),
242 stats_(
"DisjunctiveDetectablePrecedences", model) {
244 to_add_.ClearAndReserve(helper->
NumTasks());
250 bool PropagateWithRanks();
251 bool Push(IntegerValue task_set_end_min,
int t);
254 std::vector<
int> ranks_;
256 const
bool time_direction_;
265template <
bool time_direction>
272 void AddNoOverlap(absl::Span<const IntervalVariable> var);
278 std::vector<
std::vector<
int>> task_to_disjunctives_;
279 std::vector<
bool> task_is_added_;
281 std::vector<IntegerValue> end_mins_;
287 Model* model =
nullptr)
288 : time_direction_(time_direction),
290 task_set_(helper->NumTasks()),
291 stats_(
"DisjunctiveNotLast", model) {
292 start_min_window_.ClearAndReserve(helper->
NumTasks());
293 start_max_window_.ClearAndReserve(helper->
NumTasks());
299 bool PropagateSubwindow();
304 const
bool time_direction_;
315 : time_direction_(time_direction),
317 stats_(
"DisjunctiveEdgeFinding", model) {
318 task_by_increasing_end_max_.ClearAndReserve(helper->
NumTasks());
319 window_.ClearAndReserve(helper->
NumTasks());
320 event_size_.ClearAndReserve(helper->
NumTasks());
326 bool PropagateSubwindow(IntegerValue window_end_min);
328 const
bool time_direction_;
340 std::vector<
int> non_gray_task_to_event_;
341 std::vector<
bool> is_gray_;
353 : time_direction_(time_direction),
357 stats_(
"DisjunctivePrecedences", model) {
358 window_.ClearAndReserve(helper->
NumTasks());
359 index_to_end_vars_.ClearAndReserve(helper->
NumTasks());
360 indices_before_.ClearAndReserve(helper->
NumTasks());
367 bool PropagateSubwindow();
369 const
bool time_direction_;
378 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