Java Reference

Java Reference

PathOperator

Detailed Description

Base class of the local search operators dedicated to path modifications (a path is a set of nodes linked together by arcs).

This family of neighborhoods supposes they are handling next variables representing the arcs (var[i] represents the node immediately after i on a path). Several services are provided: - arc manipulators (SetNext(), ReverseChain(), MoveChain()) - path inspectors (Next(), Prev(), IsPathEnd()) - path iterators: operators need a given number of nodes to define a neighbor; this class provides the iteration on a given number of (base) nodes which can be used to define a neighbor (through the BaseNode method) Subclasses only need to override MakeNeighbor to create neighbors using the services above (no direct manipulation of assignments).

Definition at line 18 of file PathOperator.java.

Public Member Functions

synchronized void delete ()
 
void swigReleaseOwnership ()
 
void swigTakeOwnership ()
 
 PathOperator (IntVar[] next_vars, IntVar[] path_vars, int number_of_base_nodes, boolean skip_locally_optimal_paths, boolean accept_path_end_base, LongToIntFunction start_empty_path_class)
 Builds an instance of PathOperator from next and path variables. More...
 
boolean neighbor ()
 
void reset ()
 
long Prev (long node)
 Returns the node before node in the current delta. More...
 
boolean HoldsDelta ()
 
boolean isIncremental ()
 
int size ()
 
long value (long index)
 Returns the value in the current assignment of the variable of given index. More...
 
IntVar var (long index)
 Returns the variable of given index. More...
 
long oldValue (long index)
 
void setValue (long index, long value)
 
boolean activated (long index)
 
void activate (long index)
 
void deactivate (long index)
 
void addVars (IntVar[] vars)
 
void onStart ()
 Called by Start() after synchronizing the operator with the current assignment. More...
 
boolean nextNeighbor (Assignment delta, Assignment deltadelta)
 
void start (Assignment assignment)
 
boolean HasFragments ()
 
String toString ()
 

Protected Member Functions

 PathOperator (long cPtr, boolean cMemoryOwn)
 
void swigDirectorDisconnect ()
 
boolean oneNeighbor ()
 This method should not be overridden. More...
 
void OnNodeInitialization ()
 Called by OnStart() after initializing node information. More...
 
boolean 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...
 
boolean onSamePathAsPreviousBase (long 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...
 
long 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...
 
void setNextBaseToIncrement (long base_index)
 Set the next base to increment on next iteration. More...
 
boolean ConsiderAlternatives (long base_index)
 Indicates if alternatives should be considered when iterating over base nodes. More...
 
boolean initPosition ()
 Returns true if the operator needs to restart its initial position at each call to Start() More...
 

Constructor & Destructor Documentation

◆ PathOperator() [1/2]

PathOperator ( long  cPtr,
boolean  cMemoryOwn 
)
inlineprotected

Definition at line 21 of file PathOperator.java.

◆ PathOperator() [2/2]

PathOperator ( IntVar[]  next_vars,
IntVar[]  path_vars,
int  number_of_base_nodes,
boolean  skip_locally_optimal_paths,
boolean  accept_path_end_base,
LongToIntFunction  start_empty_path_class 
)
inline

Builds an instance of PathOperator from next and path variables.

'number_of_base_nodes' is the number of nodes needed to define a neighbor. 'start_empty_path_class' is a callback returning an index such that if c1 = start_empty_path_class(StartNode(p1)), c2 = start_empty_path_class(StartNode(p2)), p1 and p2 are path indices, then if c1 == c2, p1 and p2 are equivalent if they are empty. This is used to remove neighborhood symmetries on equivalent empty paths; for instance if a node cannot be moved to an empty path, then all moves moving the same node to equivalent empty paths will be skipped. 'start_empty_path_class' can be nullptr in which case no symmetries will be removed.

Definition at line 64 of file PathOperator.java.

Member Function Documentation

◆ activate()

void activate ( long  index)
inlineinherited

Definition at line 81 of file IntVarLocalSearchOperatorTemplate.java.

◆ activated()

boolean activated ( long  index)
inlineinherited

Definition at line 77 of file IntVarLocalSearchOperatorTemplate.java.

◆ addVars()

void addVars ( IntVar[]  vars)
inlineinherited

Definition at line 89 of file IntVarLocalSearchOperatorTemplate.java.

◆ ConsiderAlternatives()

boolean ConsiderAlternatives ( long  base_index)
inlineprotected

Indicates if alternatives should be considered when iterating over base nodes.

Definition at line 129 of file PathOperator.java.

◆ deactivate()

void deactivate ( long  index)
inlineinherited

Definition at line 85 of file IntVarLocalSearchOperatorTemplate.java.

◆ delete()

synchronized void delete ( )
inline

Reimplemented from IntVarLocalSearchOperator.

Definition at line 35 of file PathOperator.java.

◆ getBaseNodeRestartPosition()

long getBaseNodeRestartPosition ( int  base_index)
inlineprotected

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.

Definition at line 115 of file PathOperator.java.

◆ HasFragments()

boolean HasFragments ( )
inlineinherited

Reimplemented in BaseLns.

Definition at line 74 of file LocalSearchOperator.java.

◆ HoldsDelta()

boolean HoldsDelta ( )
inlineinherited

Reimplemented from LocalSearchOperator.

Definition at line 42 of file IntVarLocalSearchOperatorTemplate.java.

◆ initPosition()

boolean initPosition ( )
inlineprotected

Returns true if the operator needs to restart its initial position at each call to Start()

Definition at line 136 of file PathOperator.java.

◆ isIncremental()

boolean isIncremental ( )
inlineinherited

Definition at line 46 of file IntVarLocalSearchOperatorTemplate.java.

◆ neighbor()

boolean neighbor ( )
inline

Definition at line 69 of file PathOperator.java.

◆ nextNeighbor()

boolean nextNeighbor ( Assignment  delta,
Assignment  deltadelta 
)
inlineinherited

Definition at line 62 of file LocalSearchOperator.java.

◆ oldValue()

long oldValue ( long  index)
inlineinherited

Definition at line 69 of file IntVarLocalSearchOperatorTemplate.java.

◆ oneNeighbor()

boolean oneNeighbor ( )
inlineprotected

This method should not be overridden.

Override MakeNeighbor() instead.

Reimplemented from IntVarLocalSearchOperator.

Definition at line 87 of file PathOperator.java.

◆ OnNodeInitialization()

void OnNodeInitialization ( )
inlineprotected

Called by OnStart() after initializing node information.

Should be overridden instead of OnStart() to avoid calling PathOperator::OnStart explicitly.

Definition at line 94 of file PathOperator.java.

◆ onSamePathAsPreviousBase()

boolean onSamePathAsPreviousBase ( long  base_index)
inlineprotected

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.

Definition at line 108 of file PathOperator.java.

◆ onStart()

void onStart ( )
inlineinherited

Called by Start() after synchronizing the operator with the current assignment.

Should be overridden instead of Start() to avoid calling VarLocalSearchOperator::Start explicitly.

Definition at line 96 of file IntVarLocalSearchOperatorTemplate.java.

◆ Prev()

long Prev ( long  node)
inline

Returns the node before node in the current delta.

Definition at line 80 of file PathOperator.java.

◆ reset()

void reset ( )
inline

Reimplemented from LocalSearchOperator.

Definition at line 73 of file PathOperator.java.

◆ restartAtPathStartOnSynchronize()

boolean restartAtPathStartOnSynchronize ( )
inlineprotected

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.

Definition at line 101 of file PathOperator.java.

◆ setNextBaseToIncrement()

void setNextBaseToIncrement ( long  base_index)
inlineprotected

Set the next base to increment on next iteration.

All base > base_index will be reset to their start value.

Definition at line 122 of file PathOperator.java.

◆ setValue()

void setValue ( long  index,
long  value 
)
inlineinherited

Definition at line 73 of file IntVarLocalSearchOperatorTemplate.java.

◆ size()

int size ( )
inlineinherited

Definition at line 50 of file IntVarLocalSearchOperatorTemplate.java.

◆ start()

void start ( Assignment  assignment)
inlineinherited

Definition at line 66 of file LocalSearchOperator.java.

◆ swigDirectorDisconnect()

void swigDirectorDisconnect ( )
inlineprotected

Reimplemented from IntVarLocalSearchOperator.

Definition at line 46 of file PathOperator.java.

◆ swigReleaseOwnership()

void swigReleaseOwnership ( )
inline

Reimplemented from IntVarLocalSearchOperator.

Definition at line 51 of file PathOperator.java.

◆ swigTakeOwnership()

void swigTakeOwnership ( )
inline

Reimplemented from IntVarLocalSearchOperator.

Definition at line 56 of file PathOperator.java.

◆ toString()

◆ value()

long value ( long  index)
inlineinherited

Returns the value in the current assignment of the variable of given index.

Definition at line 57 of file IntVarLocalSearchOperatorTemplate.java.

◆ var()

IntVar var ( long  index)
inlineinherited

Returns the variable of given index.

Definition at line 64 of file IntVarLocalSearchOperatorTemplate.java.


The documentation for this class was generated from the following file: