Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <precedences.h>
Public Member Functions | |
PrecedencesPropagator (Model *model) | |
PrecedencesPropagator (const PrecedencesPropagator &)=delete | |
This type is neither copyable nor movable. | |
PrecedencesPropagator & | operator= (const PrecedencesPropagator &)=delete |
~PrecedencesPropagator () override | |
bool | Propagate () final |
bool | Propagate (Trail *trail) final |
void | Untrail (const Trail &trail, int trail_index) final |
bool | PropagateOutgoingArcs (IntegerVariable var) |
void | AddPrecedence (IntegerVariable i1, IntegerVariable i2) |
void | AddPrecedenceWithOffset (IntegerVariable i1, IntegerVariable i2, IntegerValue offset) |
void | AddPrecedenceWithVariableOffset (IntegerVariable i1, IntegerVariable i2, IntegerVariable offset_var) |
void | AddConditionalPrecedence (IntegerVariable i1, IntegerVariable i2, Literal l) |
Same as above, but the relation is only true when the given literal is. | |
void | AddConditionalPrecedenceWithOffset (IntegerVariable i1, IntegerVariable i2, IntegerValue offset, Literal l) |
void | AddPrecedenceWithAllOptions (IntegerVariable i1, IntegerVariable i2, IntegerValue offset, IntegerVariable offset_var, absl::Span< const Literal > presence_literals) |
Generic function that cover all of the above case and more. | |
bool | AddPrecedenceWithOffsetIfNew (IntegerVariable i1, IntegerVariable i2, IntegerValue offset) |
This version check current precedence. It is however "slow". | |
Public Member Functions inherited from operations_research::sat::SatPropagator | |
SatPropagator (const std::string &name) | |
SatPropagator (const SatPropagator &)=delete | |
This type is neither copyable nor movable. | |
SatPropagator & | operator= (const SatPropagator &)=delete |
virtual | ~SatPropagator ()=default |
void | SetPropagatorId (int id) |
Sets/Gets this propagator unique id. | |
int | PropagatorId () const |
virtual absl::Span< const Literal > | Reason (const Trail &, int, int64_t) const |
bool | PropagatePreconditionsAreSatisfied (const Trail &trail) const |
######################## Implementations below ######################## | |
bool | PropagationIsDone (const Trail &trail) const |
Returns true iff all the trail was inspected by this propagator. | |
virtual bool | IsEmpty () const |
Additional Inherited Members | |
Protected Attributes inherited from operations_research::sat::SatPropagator | |
const std::string | name_ |
int | propagator_id_ |
int | propagation_trail_index_ |
This class implement a propagator on simple inequalities between integer variables of the form (i1 + offset <= i2). The offset can be constant or given by the value of a third integer variable. Offsets can also be negative.
The algorithm works by mapping the problem onto a graph where the edges carry the offset and the nodes correspond to one of the two bounds of an integer variable (lower_bound or -upper_bound). It then find the fixed point using an incremental variant of the Bellman-Ford(-Tarjan) algorithm.
This is also known as an "integer difference logic theory" in the SMT world. Another word is "separation logic".
Definition at line 264 of file precedences.h.
|
inlineexplicit |
Definition at line 266 of file precedences.h.
|
delete |
This type is neither copyable nor movable.
|
override |
Definition at line 493 of file precedences.cc.
|
inline |
Same as above, but the relation is only true when the given literal is.
Definition at line 539 of file precedences.h.
|
inline |
Definition at line 546 of file precedences.h.
|
inline |
Add a precedence relation (i1 + offset <= i2) between integer variables.
Important: The optionality of the variable should be marked BEFORE this is called.
Implementation of the small API functions below.
Definition at line 528 of file precedences.h.
|
inline |
Generic function that cover all of the above case and more.
Definition at line 556 of file precedences.h.
|
inline |
Definition at line 534 of file precedences.h.
bool operations_research::sat::PrecedencesPropagator::AddPrecedenceWithOffsetIfNew | ( | IntegerVariable | i1, |
IntegerVariable | i2, | ||
IntegerValue | offset ) |
This version check current precedence. It is however "slow".
Definition at line 749 of file precedences.cc.
|
inline |
Definition at line 551 of file precedences.h.
|
delete |
|
finalvirtual |
This will be called after one or more literals that are watched by this propagator changed. It will also always be called on the first propagation cycle after registration.
IMPORTANT: Because of the way Untrail() work, we need to add all the potential arcs before we can abort. It is why we iterate twice here.
Iterate again to check for a propagation and indirectly update modified_vars_.
Do the actual propagation of the IntegerVariable bounds.
We can only test that no propagation is left if we didn't enqueue new literal in the presence of optional variables.
Propagate the presence literals of the arcs that can't be added.
Clean-up modified_vars_ to do as little as possible on the next call.
Implements operations_research::sat::PropagatorInterface.
Definition at line 506 of file precedences.cc.
|
finalvirtual |
Inspects the trail from propagation_trail_index_ until at least one literal is propagated. Returns false iff a conflict is detected (in which case trail->SetFailingClause() must be called).
This must update propagation_trail_index_ so that all the literals before it have been propagated. In particular, if nothing was propagated, then PropagationIsDone() must return true.
Implements operations_research::sat::SatPropagator.
Definition at line 504 of file precedences.cc.
bool operations_research::sat::PrecedencesPropagator::PropagateOutgoingArcs | ( | IntegerVariable | var | ) |
Propagates all the outgoing arcs of the given variable (and only those). It is more efficient to do all these propagation in one go by calling Propagate(), but for scheduling problem, we wants to propagate right away the end of an interval when its start moved.
Definition at line 559 of file precedences.cc.
|
finalvirtual |
Reverts the state so that all the literals with a trail index greater or equal to the given one are not processed for propagation. Note that the trail current decision level is already reverted before this is called.
This means that we already propagated all there is to propagate at the level trail_index, so we can safely clear modified_vars_ in case it wasn't already done.
Reimplemented from operations_research::sat::SatPropagator.
Definition at line 584 of file precedences.cc.