C++ Reference
C++ Reference: Routing
Detailed Description
Simple PathOperator wrapper that also stores the current previous nodes, and is thus able to provide the "Prev" and "IsPathStart" functions.
Definition at line 1499 of file constraint_solveri.h.
Public Member Functions | |
| PathWithPreviousNodesOperator (const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, int number_of_base_nodes, std::function< int(int64)> start_empty_path_class) | |
| ~PathWithPreviousNodesOperator () override | |
| bool | IsPathStart (int64 node) const |
| int64 | Prev (int64 node) const |
| std::string | DebugString () const override |
| virtual bool | MakeNeighbor ()=0 |
| void | Reset () override |
| bool | SkipUnchanged (int index) const override |
| int64 | Next (int64 node) const |
| Returns the node after node in the current delta. More... | |
| int64 | Path (int64 node) const |
| Returns the index of the path to which node belongs in the current delta. More... | |
| int | number_of_nexts () const |
| Number of next variables. More... | |
| bool | MakeNextNeighbor (Assignment *delta, Assignment *deltadelta) override |
| Redefines MakeNextNeighbor to export a simpler interface. More... | |
| bool | HoldsDelta () const override |
| void | Start (const Assignment *assignment) override |
| This method should not be overridden. More... | |
| virtual bool | IsIncremental () const |
| int | Size () const |
| const int64 & | Value (int64 index) const |
| Returns the value in the current assignment of the variable of given index. More... | |
| IntVar * | Var (int64 index) const |
| Returns the variable of given index. More... | |
| const int64 & | OldValue (int64 index) const |
| void | SetValue (int64 index, const int64 &value) |
| bool | Activated (int64 index) const |
| void | Activate (int64 index) |
| void | Deactivate (int64 index) |
| bool | ApplyChanges (Assignment *delta, Assignment *deltadelta) const |
| void | RevertChanges (bool incremental) |
| void | AddVars (const std::vector< IntVar * > &vars) |
| virtual const LocalSearchOperator * | Self () const |
| virtual bool | HasFragments () const |
Protected Member Functions | |
| void | OnNodeInitialization () override |
| Called by OnStart() after initializing node information. More... | |
| bool | MakeOneNeighbor () override |
| This method should not be overridden. Override MakeNeighbor() instead. More... | |
| int64 | BaseNode (int i) const |
| Returns the ith base node of the operator. More... | |
| int64 | StartNode (int i) const |
| Returns the start node of the ith base node. More... | |
| const std::vector< int64 > & | path_starts () const |
| Returns the vector of path start nodes. More... | |
| int | PathClass (int i) const |
| Returns the class of the path of the ith base node. More... | |
| virtual bool | RestartAtPathStartOnSynchronize () |
| When the operator is being synchronized with a new solution (when Start() is called), returns true to restart the exploration of the neighborhood from the start of the last paths explored; returns false to restart the exploration at the last nodes visited. More... | |
| virtual bool | OnSamePathAsPreviousBase (int64 base_index) |
| Returns true if a base node has to be on the same path as the "previous" base node (base node of index base_index - 1). More... | |
| virtual int64 | GetBaseNodeRestartPosition (int base_index) |
| Returns the index of the node to which the base node of index base_index must be set to when it reaches the end of a path. More... | |
| virtual void | SetNextBaseToIncrement (int64 base_index) |
| Set the next base to increment on next iteration. More... | |
| int64 | OldNext (int64 node) const |
| int64 | OldPath (int64 node) const |
| bool | MoveChain (int64 before_chain, int64 chain_end, int64 destination) |
| Moves the chain starting after the node before_chain and ending at the node chain_end after the node destination. More... | |
| bool | ReverseChain (int64 before_chain, int64 after_chain, int64 *chain_last) |
| Reverses the chain starting after before_chain and ending before after_chain. More... | |
| bool | MakeActive (int64 node, int64 destination) |
| Insert the inactive node after destination. More... | |
| bool | MakeChainInactive (int64 before_chain, int64 chain_end) |
| Makes the nodes on the chain starting after before_chain and ending at chain_end inactive. More... | |
| void | SetNext (int64 from, int64 to, int64 path) |
| Sets 'to' to be the node after 'from' on the given path. More... | |
| bool | IsPathEnd (int64 node) const |
| Returns true if node is the last node on the path; defined by the fact that node is outside the range of the variable array. More... | |
| bool | IsInactive (int64 node) const |
| Returns true if node is inactive. More... | |
| virtual bool | InitPosition () const |
| Returns true if the operator needs to restart its initial position at each call to Start() More... | |
| void | ResetPosition () |
| Reset the position of the operator to its position when Start() was last called; this can be used to let an operator iterate more than once over the paths. More... | |
| int | AddAlternativeSet (const std::vector< int64 > &alternative_set) |
| Handling node alternatives. More... | |
| void | AddPairAlternativeSets (const std::vector< std::pair< std::vector< int64 >, std::vector< int64 >>> &pair_alternative_sets) |
| Adds all sets of node alternatives of a vector of alternative pairs. More... | |
| int64 | GetActiveInAlternativeSet (int alternative_index) const |
| Returns the active node in the given alternative set. More... | |
| int64 | GetActiveAlternativeNode (int node) const |
| Returns the active node in the alternative set of the given node. More... | |
| int64 | GetActiveAlternativeSibling (int node) const |
| Returns the active node in the alternative set of the sibling of the given node. More... | |
| void | MarkChange (int64 index) |
| OnStart() should really be protected, but then SWIG doesn't see it. More... | |
Protected Attributes | |
| const int | number_of_nexts_ |
| const bool | ignore_path_vars_ |
| int | next_base_to_increment_ |
| int | num_paths_ = 0 |
| std::vector< int64 > | start_to_path_ |
| std::vector< IntVar * > | vars_ |
| std::vector< int64 > | values_ |
| std::vector< int64 > | old_values_ |
| std::vector< int64 > | prev_values_ |
| std::vector< int > | assignment_indices_ |
| Bitset64 | activated_ |
| Bitset64 | was_activated_ |
| SparseBitset | changes_ |
| SparseBitset | delta_changes_ |
| bool | cleared_ |
| IntVarLocalSearchHandler | var_handler_ |
Constructor & Destructor Documentation
◆ PathWithPreviousNodesOperator()
| PathWithPreviousNodesOperator | ( | const std::vector< IntVar * > & | vars, |
| const std::vector< IntVar * > & | secondary_vars, | ||
| int | number_of_base_nodes, | ||
| std::function< int(int64)> | start_empty_path_class | ||
| ) |
◆ ~PathWithPreviousNodesOperator()
|
inlineoverride |
Definition at line 1505 of file constraint_solveri.h.
Member Function Documentation
◆ Activate()
|
inlineinherited |
Definition at line 863 of file constraint_solveri.h.
◆ Activated()
|
inlineinherited |
Definition at line 862 of file constraint_solveri.h.
◆ AddAlternativeSet()
|
inlineprotectedinherited |
Handling node alternatives.
Adds a set of node alternatives to the neighborhood. No node can be in two altrnatives.
Definition at line 1400 of file constraint_solveri.h.
◆ AddPairAlternativeSets()
|
inlineprotectedinherited |
Adds all sets of node alternatives of a vector of alternative pairs.
No node can be in two altrnatives.
Definition at line 1413 of file constraint_solveri.h.
◆ AddVars()
|
inlineinherited |
Definition at line 908 of file constraint_solveri.h.
◆ ApplyChanges()
|
inlineinherited |
Definition at line 871 of file constraint_solveri.h.
◆ BaseNode()
|
inlineprotectedinherited |
Returns the ith base node of the operator.
Definition at line 1307 of file constraint_solveri.h.
◆ Deactivate()
|
inlineinherited |
Definition at line 867 of file constraint_solveri.h.
◆ DebugString()
|
inlineoverridevirtual |
Reimplemented from BaseObject.
Reimplemented in ExchangeSubtrip, RelocateSubtrip, IndexPairSwapActiveOperator, PairExchangeRelocateOperator, PairExchangeOperator, LightPairRelocateOperator, PairRelocateOperator, MakePairInactiveOperator, and MakeRelocateNeighborsOperator.
Definition at line 1514 of file constraint_solveri.h.
◆ GetActiveAlternativeNode()
|
inlineprotectedinherited |
Returns the active node in the alternative set of the given node.
Definition at line 1430 of file constraint_solveri.h.
◆ GetActiveAlternativeSibling()
|
inlineprotectedinherited |
Returns the active node in the alternative set of the sibling of the given node.
Definition at line 1435 of file constraint_solveri.h.
◆ GetActiveInAlternativeSet()
|
inlineprotectedinherited |
Returns the active node in the given alternative set.
Definition at line 1424 of file constraint_solveri.h.
◆ GetBaseNodeRestartPosition()
|
inlineprotectedvirtualinherited |
Returns the index of the node to which the base node of index base_index must be set to when it reaches the end of a path.
By default, it is set to the start of the current path. When this method is called, one can only assume that base nodes with indices < base_index have their final position.
Reimplemented in PairNodeSwapActiveOperator< swap_first >, PairExchangeRelocateOperator, PairRelocateOperator, and MakePairActiveOperator.
Definition at line 1338 of file constraint_solveri.h.
◆ HasFragments()
|
inlinevirtualinherited |
Reimplemented in BaseLns.
Definition at line 815 of file constraint_solveri.h.
◆ HoldsDelta()
|
inlineoverridevirtualinherited |
Reimplemented from LocalSearchOperator.
Definition at line 830 of file constraint_solveri.h.
◆ InitPosition()
|
inlineprotectedvirtualinherited |
Returns true if the operator needs to restart its initial position at each call to Start()
Definition at line 1391 of file constraint_solveri.h.
◆ IsInactive()
|
inlineprotectedinherited |
Returns true if node is inactive.
Definition at line 1385 of file constraint_solveri.h.
◆ IsIncremental()
|
inlinevirtualinherited |
Definition at line 846 of file constraint_solveri.h.
◆ IsPathEnd()
|
inlineprotectedinherited |
Returns true if node is the last node on the path; defined by the fact that node is outside the range of the variable array.
Definition at line 1382 of file constraint_solveri.h.
◆ IsPathStart()
|
inline |
Definition at line 1507 of file constraint_solveri.h.
◆ MakeActive()
|
protectedinherited |
Insert the inactive node after destination.
◆ MakeChainInactive()
|
protectedinherited |
Makes the nodes on the chain starting after before_chain and ending at chain_end inactive.
◆ MakeNeighbor()
|
pure virtualinherited |
Implemented in ExchangeSubtrip, RelocateSubtrip, PairNodeSwapActiveOperator< swap_first >, RelocateExpensiveChain, IndexPairSwapActiveOperator, PairExchangeRelocateOperator, PairExchangeOperator, LightPairRelocateOperator, PairRelocateOperator, MakePairInactiveOperator, MakePairActiveOperator, and MakeRelocateNeighborsOperator.
◆ MakeNextNeighbor()
|
overridevirtualinherited |
Redefines MakeNextNeighbor to export a simpler interface.
The calls to ApplyChanges() and RevertChanges() are factored in this method, hiding both delta and deltadelta from subclasses which only need to override MakeOneNeighbor(). Therefore this method should not be overridden. Override MakeOneNeighbor() instead.
Implements LocalSearchOperator.
Reimplemented in PairNodeSwapActiveOperator< swap_first >, IndexPairSwapActiveOperator, and SwapIndexPairOperator.
◆ MakeOneNeighbor()
|
overrideprotectedvirtualinherited |
This method should not be overridden. Override MakeNeighbor() instead.
Reimplemented from IntVarLocalSearchOperator.
Reimplemented in RelocateExpensiveChain, and MakePairActiveOperator.
◆ MarkChange()
|
inlineprotectedinherited |
OnStart() should really be protected, but then SWIG doesn't see it.
So we make it public, but only subclasses should access to it (to override it).
Definition at line 932 of file constraint_solveri.h.
◆ MoveChain()
|
protectedinherited |
Moves the chain starting after the node before_chain and ending at the node chain_end after the node destination.
◆ Next()
|
inlineinherited |
Returns the node after node in the current delta.
Definition at line 1288 of file constraint_solveri.h.
◆ number_of_nexts()
|
inlineinherited |
Number of next variables.
Definition at line 1300 of file constraint_solveri.h.
◆ OldNext()
|
inlineprotectedinherited |
Definition at line 1347 of file constraint_solveri.h.
◆ OldPath()
|
inlineprotectedinherited |
Definition at line 1352 of file constraint_solveri.h.
◆ OldValue()
|
inlineinherited |
Definition at line 857 of file constraint_solveri.h.
◆ OnNodeInitialization()
|
overrideprotectedvirtual |
Called by OnStart() after initializing node information.
Should be overridden instead of OnStart() to avoid calling PathOperator::OnStart explicitly.
Reimplemented from PathOperator.
◆ OnSamePathAsPreviousBase()
|
inlineprotectedvirtualinherited |
Returns true if a base node has to be on the same path as the "previous" base node (base node of index base_index - 1).
Useful to limit neighborhood exploration to nodes on the same path. it's currently way more complicated to implement.
Reimplemented in PairNodeSwapActiveOperator< swap_first >, PairExchangeRelocateOperator, PairRelocateOperator, and MakePairActiveOperator.
Definition at line 1332 of file constraint_solveri.h.
◆ Path()
|
inlineinherited |
Returns the index of the path to which node belongs in the current delta.
Only returns a valid value if path variables are taken into account.
Definition at line 1295 of file constraint_solveri.h.
◆ path_starts()
|
inlineprotectedinherited |
Returns the vector of path start nodes.
Definition at line 1311 of file constraint_solveri.h.
◆ PathClass()
|
inlineprotectedinherited |
Returns the class of the path of the ith base node.
Definition at line 1313 of file constraint_solveri.h.
◆ Prev()
|
inline |
Definition at line 1509 of file constraint_solveri.h.
◆ Reset()
|
overridevirtualinherited |
Reimplemented from LocalSearchOperator.
◆ ResetPosition()
|
inlineprotectedinherited |
Reset the position of the operator to its position when Start() was last called; this can be used to let an operator iterate more than once over the paths.
Definition at line 1395 of file constraint_solveri.h.
◆ RestartAtPathStartOnSynchronize()
|
inlineprotectedvirtualinherited |
When the operator is being synchronized with a new solution (when Start() is called), returns true to restart the exploration of the neighborhood from the start of the last paths explored; returns false to restart the exploration at the last nodes visited.
This is used to avoid restarting on base nodes which have changed paths, leading to potentially skipping neighbors.
Reimplemented in PairNodeSwapActiveOperator< swap_first >, and MakePairActiveOperator.
Definition at line 1326 of file constraint_solveri.h.
◆ ReverseChain()
|
protectedinherited |
Reverses the chain starting after before_chain and ending before after_chain.
◆ RevertChanges()
|
inlineinherited |
Definition at line 895 of file constraint_solveri.h.
◆ Self()
|
inlinevirtualinherited |
Definition at line 813 of file constraint_solveri.h.
◆ SetNext()
|
inlineprotectedinherited |
Sets 'to' to be the node after 'from' on the given path.
Definition at line 1371 of file constraint_solveri.h.
◆ SetNextBaseToIncrement()
|
inlineprotectedvirtualinherited |
Set the next base to increment on next iteration.
All base > base_index will be reset to their start value.
Definition at line 1343 of file constraint_solveri.h.
◆ SetValue()
|
inlineinherited |
Definition at line 858 of file constraint_solveri.h.
◆ Size()
|
inlineinherited |
Definition at line 847 of file constraint_solveri.h.
◆ SkipUnchanged()
|
overridevirtualinherited |
Reimplemented from VarLocalSearchOperator< IntVar, int64, IntVarLocalSearchHandler >.
◆ Start()
|
inlineoverridevirtualinherited |
This method should not be overridden.
Override OnStart() instead which is called before exiting this method.
Implements LocalSearchOperator.
Definition at line 833 of file constraint_solveri.h.
◆ StartNode()
|
inlineprotectedinherited |
Returns the start node of the ith base node.
Definition at line 1309 of file constraint_solveri.h.
◆ Value()
|
inlineinherited |
Returns the value in the current assignment of the variable of given index.
Definition at line 850 of file constraint_solveri.h.
◆ Var()
|
inlineinherited |
Returns the variable of given index.
Definition at line 855 of file constraint_solveri.h.
Member Data Documentation
◆ activated_
|
protectedinherited |
Definition at line 942 of file constraint_solveri.h.
◆ assignment_indices_
|
mutableprotectedinherited |
Definition at line 941 of file constraint_solveri.h.
◆ changes_
|
protectedinherited |
Definition at line 944 of file constraint_solveri.h.
◆ cleared_
|
protectedinherited |
Definition at line 946 of file constraint_solveri.h.
◆ delta_changes_
|
protectedinherited |
Definition at line 945 of file constraint_solveri.h.
◆ ignore_path_vars_
|
protectedinherited |
Definition at line 1444 of file constraint_solveri.h.
◆ next_base_to_increment_
|
protectedinherited |
Definition at line 1445 of file constraint_solveri.h.
◆ num_paths_
|
protectedinherited |
Definition at line 1446 of file constraint_solveri.h.
◆ number_of_nexts_
|
protectedinherited |
Definition at line 1443 of file constraint_solveri.h.
◆ old_values_
|
protectedinherited |
Definition at line 939 of file constraint_solveri.h.
◆ prev_values_
|
protectedinherited |
Definition at line 940 of file constraint_solveri.h.
◆ start_to_path_
|
protectedinherited |
Definition at line 1447 of file constraint_solveri.h.
◆ values_
|
protectedinherited |
Definition at line 938 of file constraint_solveri.h.
◆ var_handler_
|
protectedinherited |
Definition at line 947 of file constraint_solveri.h.
◆ vars_
|
protectedinherited |
Definition at line 937 of file constraint_solveri.h.
◆ was_activated_
|
protectedinherited |
Definition at line 943 of file constraint_solveri.h.
The documentation for this class was generated from the following file: