C++ Reference: class SchedulingConstraintHelper

Note: This documentation is automatically generated.

Helper class shared by the propagators that manage a given list of tasks.

One of the main advantage of this class is that it allows to share the vectors of tasks sorted by various criteria between propagator for a faster code.
Method
AddAbsenceReason

Return type: void

Arguments: int t

AddEndMaxReason

Return type: void

Arguments: int t, IntegerValue upper_bound

AddEndMinReason

Return type: void

Arguments: int t, IntegerValue lower_bound

AddEnergyAfterReason

Return type: void

Arguments: int t, IntegerValue energy_min, IntegerValue time

AddEnergyMinInIntervalReason

Return type: void

Arguments: int t, IntegerValue min, IntegerValue max

AddPresenceReason

Return type: void

Arguments: int t

AddReasonForBeingBefore

Return type: void

Arguments: int before, int after

Adds the reason why task "before" must be before task "after". That is StartMax(before) < EndMin(after).

AddSizeMaxReason

Return type: void

Arguments: int t, IntegerValue upper_bound

AddSizeMinReason

Return type: void

Arguments: int t

AddSizeMinReason

Return type: void

Arguments: int t, IntegerValue lower_bound

AddStartMaxReason

Return type: void

Arguments: int t, IntegerValue upper_bound

AddStartMinReason

Return type: void

Arguments: int t, IntegerValue lower_bound

ClearOtherHelper

Return type: void

ClearReason

Return type: void

Functions to clear and then set the current reason.

DecreaseEndMax

Return type: ABSL_MUST_USE_RESULT bool

Arguments: int t, IntegerValue value

EndIsFixed

Return type: bool

Arguments: int t

EndMax

Return type: IntegerValue

Arguments: int t

EndMin

Return type: IntegerValue

Arguments: int t

Ends

Return type: const std::vector<AffineExpression>&

GetEnergyProfile

Return type: const std::vector<ProfileEvent>&

GetMinOverlap

Return type: IntegerValue

Arguments: int t, IntegerValue start, IntegerValue end

Return the minimum overlap of interval i with the time window [start..end]. Note: this is different from the mandatory part of an interval.

ImportOtherReasons

Return type: void

Arguments: const SchedulingConstraintHelper& other_helper

Adds to this helper reason all the explanation of the other helper. This checks that other_helper_ is null. This is used in the 2D energetic reasoning in the diffn constraint.

IncreaseEndMin

Return type: ABSL_MUST_USE_RESULT bool

Arguments: int t, IntegerValue value

IncreaseStartMin

Return type: ABSL_MUST_USE_RESULT bool

Arguments: int t, IntegerValue value

Push something using the current reason. Note that IncreaseStartMin() will also increase the end-min, and DecreaseEndMax() will also decrease the start-max. Important: IncreaseStartMin() and DecreaseEndMax() can be called on an optional interval whose presence is still unknown and push a bound conditionned on its presence. The functions will do the correct thing depending on whether or not the start_min/end_max are optional variables whose presence implies the interval presence.

IncrementalPropagate

Return type: bool

Arguments: const std::vector<int>& watch_indices

InPropagationLoop

Return type: bool

TODO(user): Change the propagation loop code so that we don't stop pushing in the middle of the propagation as more advanced propagator do not handle this correctly.

IsAbsent

Return type: bool

Arguments: int t

IsOptional

Return type: bool

Arguments: int t

Returns true if the corresponding fact is known for sure. A normal task is always present. For optional task for which the presence is still unknown, both of these function will return false.

IsPresent

Return type: bool

Arguments: int t

MutableIntegerReason

Return type: std::vector<IntegerLiteral>*

MutableLiteralReason

Return type: std::vector<Literal>*

It is also possible to directly manipulates the underlying reason vectors that will be used when pushing something.

NumTasks

Return type: int

Returns the number of task.

PresenceLiteral

Return type: Literal

Arguments: int index

Propagate

Return type: bool

This is a propagator so we can "cache" all the intervals relevant information. This gives good speedup. Note however that the info is stale except if a bound was pushed by this helper or if this was called. We run it at the highest priority, so that will mostly be the case at the beginning of each Propagate() call of the classes using this.

PushIntegerLiteral

Return type: ABSL_MUST_USE_RESULT bool

Arguments: IntegerLiteral lit

PushIntegerLiteralIfTaskPresent

Return type: ABSL_MUST_USE_RESULT bool

Arguments: int t, IntegerLiteral lit

PushLiteral

Return type: ABSL_MUST_USE_RESULT bool

Arguments: Literal l

PushTaskAbsence

Return type: ABSL_MUST_USE_RESULT bool

Arguments: int t

PushTaskPresence

Return type: ABSL_MUST_USE_RESULT bool

Arguments: int t

RegisterWith

Return type: void

Arguments: GenericLiteralWatcher* watcher

ReportConflict

Return type: ABSL_MUST_USE_RESULT bool

ResetFromSubset

Return type: ABSL_MUST_USE_RESULT bool

Arguments: const SchedulingConstraintHelper& other, absl::Span<const int> tasks

Resets the class to the same state as if it was constructed with the given subset of tasks from other.

SchedulingConstraintHelper

Arguments: const std::vector<IntervalVariable>& tasks, Model* model

All the functions below refer to a task by its index t in the tasks vector given at construction.

SchedulingConstraintHelper

Arguments: int num_tasks, Model* model

Temporary constructor. The class will not be usable until ResetFromSubset() is called. TODO(user): Remove this. It is a hack because the disjunctive class needs to fetch the maximum possible number of task at construction.

SetLevel

Return type: void

Arguments: int level

SetOtherHelper

Return type: void

Arguments: SchedulingConstraintHelper* other_helper, absl::Span<const int> map_to_other_helper, IntegerValue event

Manages the other helper (used by the diffn constraint). For each interval appearing in a reason on this helper, another reason will be added. This other reason specifies that on the other helper, the corresponding interval overlaps 'event'.

SetTimeDirection

Return type: void

Arguments: bool is_forward

Make sure the cached values are up to date. Also sets the time direction to either forward/backward. This will impact all the functions below. This MUST be called at the beginning of all Propagate() call that uses this helper.

ShiftedEndMax

Return type: IntegerValue

Arguments: int t

As with ShiftedStartMin(), we can compute the shifted end max (that is start_max + size_min.

ShiftedStartMin

Return type: IntegerValue

Arguments: int t

In the presence of tasks with a variable size, we do not necessarily have start_min + size_min = end_min, we can instead have a situation like: | |<--- size-min --->| ^ ^ ^ start-min | end-min | We define the "shifted start min" to be the right most time such that we known that we must have min-size "energy" to the right of it if the task is present. Using it in our scheduling propagators allows to propagate more in the presence of tasks with variable size (or optional task where we also do not necessarily have start_min + size_min = end_min. To explain this shifted start min, one must use the AddEnergyAfterReason().

SizeIsFixed

Return type: bool

Arguments: int t

SizeMax

Return type: IntegerValue

Arguments: int t

SizeMin

Return type: IntegerValue

Arguments: int t

Helpers for the current bounds on the current task time window. [ (size-min) ... (size-min) ] ^ ^ ^ ^ start-min end-min start-max end-max Note that for tasks with variable durations, we don't necessarily have duration-min between the XXX-min and XXX-max value. Remark: We use cached values for most of these function as this is faster. In practice, the cache will almost always be up to date, but not in corner cases where pushing the start of one task will change values for many others. This is fine as the new values will be picked up as we reach the propagation fixed point.

Sizes

Return type: const std::vector<AffineExpression>&

StartIsFixed

Return type: bool

Arguments: int t

StartMax

Return type: IntegerValue

Arguments: int t

StartMin

Return type: IntegerValue

Arguments: int t

Starts

Return type: const std::vector<AffineExpression>&

Returns the underlying affine expressions.

SynchronizeAndSetTimeDirection

Return type: ABSL_MUST_USE_RESULT bool

Arguments: bool is_forward

TaskByDecreasingEndMax

Return type: const std::vector<TaskTime>&

TaskByDecreasingStartMax

Return type: const std::vector<TaskTime>&

TaskByIncreasingEndMin

Return type: const std::vector<TaskTime>&

TaskByIncreasingShiftedStartMin

Return type: const std::vector<TaskTime>&

TaskByIncreasingStartMin

Return type: const std::vector<TaskTime>&

Sorts and returns the tasks in corresponding order at the time of the call. Note that we do not mean strictly-increasing/strictly-decreasing, there will be duplicate time values in these vectors. TODO(user): we could merge the first loop of IncrementalSort() with the loop that fill TaskTime.time at each call.

TaskDebugString

Return type: std::string

Arguments: int t

Returns a string with the current task bounds.

WatchAllTasks

Return type: void

Arguments: int id, GenericLiteralWatcher* watcher, bool watch_start_max = true, bool watch_end_max = true

Registers the given propagator id to be called if any of the tasks in this class change. Note that we do not watch size max though.