14#ifndef OR_TOOLS_SAT_DISJUNCTIVE_H_
15#define OR_TOOLS_SAT_DISJUNCTIVE_H_
22#include "absl/types/span.h"
48 const std::vector<IntervalVariable>& intervals, Model*
model);
56 explicit TaskSet(
int num_tasks) { sorted_tasks_.ClearAndReserve(num_tasks); }
69 sorted_tasks_.clear();
70 optimized_restart_ = 0;
87 void Sort() { std::sort(sorted_tasks_.begin(), sorted_tasks_.end()); }
108 IntegerValue
ComputeEndMin(
int task_to_ignore,
int* critical_index)
const;
116 absl::Span<const Entry>
SortedTasks()
const {
return sorted_tasks_; }
120 mutable int optimized_restart_ = 0;
133 if (!VLOG_IS_ON(1))
return;
134 std::vector<std::pair<std::string, int64_t>> stats;
135 stats.push_back({absl::StrCat(
name,
"/num_calls"),
num_calls});
136 stats.push_back({absl::StrCat(
name,
"/num_calls_with_propagation"),
181 window_(new
TaskTime[helper->NumTasks()]),
182 task_to_event_(new int[helper->NumTasks()]),
183 stats_(
"DisjunctiveOverloadChecker",
model) {
184 task_by_increasing_end_max_.ClearAndReserve(helper->
NumTasks());
191 bool PropagateSubwindow(
int relevant_size, IntegerValue global_window_end);
197 std::unique_ptr<
int[]> task_to_event_;
216 : helper_(helper), stats_(
"DisjunctiveSimplePrecedences",
model) {}
221 bool PropagateOneDirection();
233 : time_direction_(time_direction),
235 task_set_(helper->NumTasks()),
236 stats_(
"DisjunctiveDetectablePrecedences",
model) {
238 to_add_.ClearAndReserve(helper->
NumTasks());
244 bool PropagateWithRanks();
245 bool Push(IntegerValue task_set_end_min,
int t);
248 std::vector<
int> ranks_;
250 const
bool time_direction_;
268template <
bool time_direction>
275 void AddNoOverlap(absl::Span<const IntervalVariable>
var);
277 bool Propagate() final;
281 std::vector<
std::vector<
int>> task_to_disjunctives_;
282 std::vector<
bool> task_is_added_;
284 std::vector<IntegerValue> end_mins_;
291 : time_direction_(time_direction),
293 task_set_(helper->NumTasks()),
294 stats_(
"DisjunctiveNotLast",
model) {
295 start_min_window_.ClearAndReserve(helper->
NumTasks());
296 start_max_window_.ClearAndReserve(helper->
NumTasks());
298 bool Propagate() final;
302 bool PropagateSubwindow();
307 const
bool time_direction_;
318 : time_direction_(time_direction),
320 stats_(
"DisjunctiveEdgeFinding",
model) {
321 task_by_increasing_end_max_.ClearAndReserve(helper->
NumTasks());
322 window_.ClearAndReserve(helper->
NumTasks());
323 event_size_.ClearAndReserve(helper->
NumTasks());
325 bool Propagate() final;
329 bool PropagateSubwindow(IntegerValue window_end_min);
331 const
bool time_direction_;
343 std::vector<
int> non_gray_task_to_event_;
344 std::vector<
bool> is_gray_;
356 : time_direction_(time_direction),
360 stats_(
"DisjunctivePrecedences",
model) {
361 window_.ClearAndReserve(helper->
NumTasks());
362 index_to_end_vars_.ClearAndReserve(helper->
NumTasks());
363 indices_before_.ClearAndReserve(helper->
NumTasks());
366 bool Propagate() final;
370 bool PropagateSubwindow();
372 const
bool time_direction_;
381 std::vector<
bool> skip_;
395 bool Propagate() final;
int RegisterWith(GenericLiteralWatcher *watcher)
DisjunctiveOverloadChecker(SchedulingConstraintHelper *helper, Model *model=nullptr)
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 AddStats(absl::Span< const std::pair< std::string, int64_t > > stats)
Adds a bunch of stats, adding count for the same key together.
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 AddDisjunctiveWithBooleanPrecedencesOnly(const std::vector< IntervalVariable > &intervals, Model *model)
void AddDisjunctive(const std::vector< 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