Class 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
    protected PathOperator​(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)
    Builds an instance of PathOperator from next and path variables.
    'number_of_base_nodes' is the number of nodes needed to define a
    neighbor.
  • Method Summary

    Modifier and Type Method Description
    protected boolean ConsiderAlternatives​(long base_index)
    Indicates if alternatives should be considered when iterating over base
    nodes.
    void delete()  
    protected void finalize()  
    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.
    protected static long getCPtr​(PathOperator obj)  
    protected boolean initPosition()
    Returns true if the operator needs to restart its initial position at each
    call to Start()
    boolean neighbor()  
    protected boolean oneNeighbor()
    This method should not be overridden.
    protected void OnNodeInitialization()
    Called by OnStart() after initializing node information.
    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.
    long Prev​(long node)
    Returns the node before node in the current delta.
    void reset()  
    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.
    protected void setNextBaseToIncrement​(long base_index)
    Set the next base to increment on next iteration.
    protected void swigDirectorDisconnect()  
    void swigReleaseOwnership()  
    void swigTakeOwnership()  

    Methods inherited from class com.google.ortools.constraintsolver.IntVarLocalSearchOperator

    getCPtr

    Methods inherited from class com.google.ortools.constraintsolver.IntVarLocalSearchOperatorTemplate

    activate, activated, addVars, deactivate, getCPtr, HoldsDelta, isIncremental, oldValue, onStart, setValue, size, value, var

    Methods inherited from class com.google.ortools.constraintsolver.LocalSearchOperator

    getCPtr, HasFragments, nextNeighbor, start

    Methods inherited from class com.google.ortools.constraintsolver.BaseObject

    getCPtr, toString

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PathOperator

      protected PathOperator​(long cPtr, boolean cMemoryOwn)
    • 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)
      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.
  • Method Details

    • getCPtr

      protected static long getCPtr​(PathOperator obj)
    • finalize

      protected void finalize()
      Overrides:
      finalize in class IntVarLocalSearchOperator
    • delete

      public void delete()
      Overrides:
      delete in class IntVarLocalSearchOperator
    • swigDirectorDisconnect

      protected void swigDirectorDisconnect()
      Overrides:
      swigDirectorDisconnect in class IntVarLocalSearchOperator
    • swigReleaseOwnership

      public void swigReleaseOwnership()
      Overrides:
      swigReleaseOwnership in class IntVarLocalSearchOperator
    • swigTakeOwnership

      public void swigTakeOwnership()
      Overrides:
      swigTakeOwnership in class IntVarLocalSearchOperator
    • neighbor

      public boolean neighbor()
    • reset

      public void reset()
      Overrides:
      reset in class LocalSearchOperator
    • 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:
      oneNeighbor in class IntVarLocalSearchOperator
    • 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()