Class PathOperator
- java.lang.Object
-
- com.google.ortools.constraintsolver.BaseObject
-
- com.google.ortools.constraintsolver.LocalSearchOperator
-
- com.google.ortools.constraintsolver.IntVarLocalSearchOperator
-
- com.google.ortools.constraintsolver.PathOperator
-
public class PathOperator extends IntVarLocalSearchOperator
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).
-
-
Field Summary
-
Fields inherited from class com.google.ortools.constraintsolver.BaseObject
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPathOperator(long cPtr, boolean cMemoryOwn)PathOperator(IntVar[] next_vars, IntVar[] path_vars, int number_of_base_nodes, boolean skip_locally_optimal_paths, boolean accept_path_end_base, java.util.function.LongToIntFunction start_empty_path_class, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_neighbors)PathOperator(IntVar[] next_vars, IntVar[] path_vars, SWIGTYPE_p_operations_research__PathOperator__IterationParameters iteration_parameters)Builds an instance of PathOperator from next and path variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanConsiderAlternatives(long base_index)Indicates if alternatives should be considered when iterating over base
nodes.voiddelete()protected voidfinalize()protected longgetBaseNodeRestartPosition(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.
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.protected static longgetCPtr(PathOperator obj)protected booleaninitPosition()Returns true if the operator needs to restart its initial position at each
call to Start()booleanneighbor()protected booleanoneNeighbor()This method should not be overridden.protected voidOnNodeInitialization()Called by OnStart() after initializing node information.protected booleanonSamePathAsPreviousBase(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).
Useful to limit neighborhood exploration to nodes on the same path.
it's currently way more complicated to implement.longPrev(long node)Returns the node before node in the current delta.voidreset()protected booleanrestartAtPathStartOnSynchronize()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.protected voidsetNextBaseToIncrement(long base_index)Set the next base to increment on next iteration.protected voidswigDirectorDisconnect()protected static longswigRelease(PathOperator obj)voidswigReleaseOwnership()voidswigTakeOwnership()-
Methods inherited from class com.google.ortools.constraintsolver.IntVarLocalSearchOperator
activate, activated, addVars, ApplyChanges, deactivate, getCPtr, HoldsDelta, isIncremental, oldValue, onStart, PrevValue, RevertChanges, setValue, size, SkipUnchanged, start, swigRelease, value, var
-
Methods inherited from class com.google.ortools.constraintsolver.LocalSearchOperator
getCPtr, HasFragments, nextNeighbor, swigRelease
-
Methods inherited from class com.google.ortools.constraintsolver.BaseObject
getCPtr, swigRelease, toString
-
-
-
-
Constructor Detail
-
PathOperator
protected PathOperator(long cPtr, boolean cMemoryOwn)
-
PathOperator
public PathOperator(IntVar[] next_vars, IntVar[] path_vars, SWIGTYPE_p_operations_research__PathOperator__IterationParameters iteration_parameters)
Builds an instance of PathOperator from next and path variables.
-
PathOperator
public PathOperator(IntVar[] next_vars, IntVar[] path_vars, int number_of_base_nodes, boolean skip_locally_optimal_paths, boolean accept_path_end_base, java.util.function.LongToIntFunction start_empty_path_class, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_neighbors)
-
-
Method Detail
-
getCPtr
protected static long getCPtr(PathOperator obj)
-
swigRelease
protected static long swigRelease(PathOperator obj)
-
finalize
protected void finalize()
- Overrides:
finalizein classIntVarLocalSearchOperator
-
delete
public void delete()
- Overrides:
deletein classIntVarLocalSearchOperator
-
swigDirectorDisconnect
protected void swigDirectorDisconnect()
- Overrides:
swigDirectorDisconnectin classIntVarLocalSearchOperator
-
swigReleaseOwnership
public void swigReleaseOwnership()
- Overrides:
swigReleaseOwnershipin classIntVarLocalSearchOperator
-
swigTakeOwnership
public void swigTakeOwnership()
- Overrides:
swigTakeOwnershipin classIntVarLocalSearchOperator
-
neighbor
public boolean neighbor()
-
reset
public void reset()
- Overrides:
resetin classLocalSearchOperator
-
Prev
public long Prev(long node)
Returns the node before node in the current delta.
-
oneNeighbor
protected boolean oneNeighbor()
This method should not be overridden. Override MakeNeighbor() instead.- Overrides:
oneNeighborin classIntVarLocalSearchOperator
-
OnNodeInitialization
protected void OnNodeInitialization()
Called by OnStart() after initializing node information. Should be
overridden instead of OnStart() to avoid calling PathOperator::OnStart
explicitly.
-
restartAtPathStartOnSynchronize
protected 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.
This is used to avoid restarting on base nodes which have changed paths,
leading to potentially skipping neighbors.
-
onSamePathAsPreviousBase
protected 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).
Useful to limit neighborhood exploration to nodes on the same path.
it's currently way more complicated to implement.
-
getBaseNodeRestartPosition
protected 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.
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.
-
setNextBaseToIncrement
protected void setNextBaseToIncrement(long base_index)
Set the next base to increment on next iteration. All base > base_index
will be reset to their start value.
-
ConsiderAlternatives
protected boolean ConsiderAlternatives(long base_index)
Indicates if alternatives should be considered when iterating over base
nodes.
-
initPosition
protected boolean initPosition()
Returns true if the operator needs to restart its initial position at each
call to Start()
-
-