14#ifndef ORTOOLS_SAT_DISJUNCTIVE_H_
15#define ORTOOLS_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"
49void AddDisjunctive(
const std::vector<Literal>& enforcement_literals,
50 const std::vector<IntervalVariable>& intervals,
57 absl::Span<const IntervalVariable> intervals,
Model* model);
67 : sorted_tasks_(storage) {}
71 sorted_tasks_.clear();
72 optimized_restart_ = 0;
89 void Sort() { std::sort(sorted_tasks_.begin(), sorted_tasks_.end()); }
110 IntegerValue
ComputeEndMin(
int task_to_ignore,
int* critical_index)
const;
118 absl::Span<const Entry>
SortedTasks()
const {
return sorted_tasks_; }
122 mutable int optimized_restart_ = 0;
135 if (!VLOG_IS_ON(1))
return;
136 std::vector<std::pair<std::string, int64_t>> stats;
137 stats.push_back({absl::StrCat(
name,
"/num_calls"),
num_calls});
138 stats.push_back({absl::StrCat(
name,
"/num_calls_with_propagation"),
181 Model* model =
nullptr)
183 task_to_event_(new int[helper->NumTasks()]),
184 stats_(
"DisjunctiveOverloadChecker", model) {
186 std::fill(task_to_event_.get(), task_to_event_.get() + helper->
NumTasks(),
194 bool PropagateSubwindow(
absl::Span<
TaskTime> sub_window,
195 IntegerValue global_window_end,
197 task_by_increasing_negated_shifted_end_max);
202 std::unique_ptr<
int[]> task_to_event_;
218 Model* model =
nullptr)
219 : helper_(helper), stats_(
"DisjunctiveSimplePrecedences", model) {}
224 bool PropagateOneDirection();
236 : time_direction_(time_direction),
238 stats_(
"DisjunctiveDetectablePrecedences", model) {
240 to_add_.ClearAndReserve(helper->
NumTasks());
246 bool PropagateWithRanks();
247 bool Push(IntegerValue task_set_end_min,
int t,
TaskSet& task_set);
250 std::vector<
int> ranks_;
252 const
bool time_direction_;
260template <
bool time_direction>
267 void AddNoOverlap(absl::Span<const IntervalVariable> var);
273 std::vector<
std::vector<
int>> task_to_disjunctives_;
274 std::vector<
bool> task_is_added_;
277 std::vector<IntegerValue> end_mins_;
283 Model* model =
nullptr)
284 : time_direction_(time_direction),
286 stats_(
"DisjunctiveNotLast", model) {}
291 bool PropagateSubwindow(
TaskSet& task_set,
295 const
bool time_direction_;
305 : time_direction_(time_direction),
307 stats_(
"DisjunctiveEdgeFinding", model) {
308 event_size_.ClearAndReserve(helper->
NumTasks());
314 bool PropagateSubwindow(
315 IntegerValue window_end_min,
absl::Span<const
TaskTime> window,
318 const
bool time_direction_;
326 std::vector<
int> non_gray_task_to_event_;
327 std::vector<
bool> is_gray_;
339 : time_direction_(time_direction),
344 time_limit_(model->GetOrCreate<
TimeLimit>()),
345 stats_(
"DisjunctivePrecedences", model) {
346 index_to_end_vars_.ClearAndReserve(helper->
NumTasks());
347 indices_before_.ClearAndReserve(helper->
NumTasks());
356 const
bool time_direction_;
366 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)
PropagatorInterface()=default
void NotifyEntryIsNowLastIfPresent(const Entry &e)
SchedulingConstraintHelper::TaskInfo Entry
int GetCriticalIndex() const
void AddEntry(const Entry &e)
TaskSet(FixedCapacityVector< Entry > &storage)
void AddUnsortedEntry(const Entry &e)
IntegerValue ComputeEndMin() const
absl::Span< const Entry > SortedTasks() const
void AddShiftedStartMinEntry(const SchedulingConstraintHelper &helper, int t)
void AddDisjunctive(const std::vector< Literal > &enforcement_literals, const std::vector< IntervalVariable > &intervals, Model *model)
void AddDisjunctiveWithBooleanPrecedencesOnly(absl::Span< const IntervalVariable > intervals, Model *model)
int64_t num_calls_with_propagation
SharedStatistics * shared_stats
PropagationStatistics(std::string _name, Model *model=nullptr)
void EndWithoutConflicts()