Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <circuit.h>
Public Member Functions | |
CircuitCoveringPropagator (std::vector< std::vector< Literal > > graph, const std::vector< int > &distinguished_nodes, Model *model) | |
void | SetLevel (int level) final |
bool | Propagate () final |
bool | IncrementalPropagate (const std::vector< int > &watch_indices) final |
void | RegisterWith (GenericLiteralWatcher *watcher) |
This constraint ensures that the graph is a covering of all nodes by circuits and loops, such that all circuits contain exactly one distinguished node. Those distinguished nodes are meant to be depots.
This constraint does not need ExactlyOnePerRowAndPerColumn() to be correct, but it does not propagate degree deductions (only fails if a node has more than one outgoing arc or more than one incoming arc), so that adding ExactlyOnePerRowAndPerColumn() should work better.
operations_research::sat::CircuitCoveringPropagator::CircuitCoveringPropagator | ( | std::vector< std::vector< Literal > > | graph, |
const std::vector< int > & | distinguished_nodes, | ||
Model * | model ) |
Definition at line 484 of file circuit.cc.
|
finalvirtual |
This will only be called on a non-empty vector, otherwise Propagate() will be called. The passed vector will contain the "watch index" of all the literals that were given one at registration and that changed since the last call to Propagate(). This is only true when going down in the search tree, on backjump this list will be cleared.
Notes:
Reimplemented from operations_research::sat::PropagatorInterface.
Definition at line 529 of file circuit.cc.
|
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.
Gather next_ and prev_ from fixed arcs.
Two arcs go out of arc.first, forbidden.
Two arcs come into arc.second, forbidden.
For every node, find partial path/circuit in which the node is. Use visited_ to visit each path/circuit only once.
Skip if already visited, isolated or loop.
Find start of path/circuit.
Find distinguished node of path. Fail if there are several, fail if this is a non loop circuit and there are none.
Circuit with no distinguished nodes, forbidden.
Path with no distinguished node: forbid to close it.
Implements operations_research::sat::PropagatorInterface.
Definition at line 550 of file circuit.cc.
void operations_research::sat::CircuitCoveringPropagator::RegisterWith | ( | GenericLiteralWatcher * | watcher | ) |
Fill fixed_arcs_ with arcs that are initially fixed to true, assign arcs to watch indices.
Definition at line 496 of file circuit.cc.
|
finalvirtual |
Initially a reversible class starts at level zero. Increasing the level saves the state of the current old level. Decreasing the level restores the state to what it was at this level and all higher levels are forgotten. Everything done at level zero cannot be backtracked over.
The level is assumed to be non-negative.
Backtrack.
Implements operations_research::ReversibleInterface.
Definition at line 516 of file circuit.cc.