Class LocalSearchFilter

java.lang.Object
com.google.ortools.constraintsolver.BaseObject
com.google.ortools.constraintsolver.LocalSearchFilter
Direct Known Subclasses:
IntVarLocalSearchFilter

public class LocalSearchFilter extends BaseObject
Classes to which this template function can be applied to as of 04/2014.
Usage: LocalSearchOperator* op = MakeLocalSearchOperator<Relocate>(...);
class TwoOpt;
class Relocate;
class Exchange;
class Cross;
class MakeActiveOperator;
class MakeInactiveOperator;
class MakeChainInactiveOperator;
class SwapActiveOperator;
class ExtendedSwapActiveOperator;
class MakeActiveAndRelocate;
class RelocateAndMakeActiveOperator;
class RelocateAndMakeInactiveOperator;
Local Search Filters are used for fast neighbor pruning.
Filtering a move is done in several phases:
- in the Relax phase, filters determine which parts of their internals
will be changed by the candidate, and modify intermediary State
- in the Accept phase, filters check that the candidate is feasible,
- if the Accept phase succeeds, the solver may decide to trigger a
Synchronize phase that makes filters change their internal representation
to the last candidate,
- otherwise (Accept fails or the solver does not want to synchronize),
a Revert phase makes filters erase any intermediary State generated by the
Relax and Accept phases.
A given filter has phases called with the following pattern:
(Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*.
Filters's Revert() is always called in the reverse order their Accept() was
called, to allow late filters to use state done/undone by early filters'
Accept()/Revert().
  • Field Summary

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

    swigCMemOwn
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
     
    protected
    LocalSearchFilter(long cPtr, boolean cMemoryOwn)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    accept(Assignment delta, Assignment deltadelta, long objective_min, long objective_max)
    Accepts a "delta" given the assignment with which the filter has been
    synchronized; the delta holds the variables which have been modified and
    their new value.
    If the filter represents a part of the global objective, its contribution
    must be between objective_min and objective_max.
    Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
    for the assignment (a,1), (b,0), the delta (b,1) will be rejected
    but the delta (a,0) will be accepted.
    TODO(user): Remove arguments when there are no more need for those.
    void
    Commit(Assignment delta, Assignment deltadelta)
    Dual of Relax(), lets the filter know that the delta was accepted.
    void
     
    protected void
     
    long
    Objective value from the last time Accept() was called and returned true.
    protected static long
     
    long
    Objective value from last time Synchronize() was called.
    boolean
     
    void
    Relax(Assignment delta, Assignment deltadelta)
    Lets the filter know what delta and deltadelta will be passed in the next
    Accept().
    void
    Sets the filter to empty solution.
    void
    Cancels the changes made by the last Relax()/Accept() calls.
    protected void
     
    protected static long
     
    void
     
    void
     
    void
    synchronize(Assignment assignment, Assignment delta)
    Synchronizes the filter with the current solution, delta being the
    difference with the solution passed to the previous call to Synchronize()
    or IncrementalSynchronize().

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

    getCPtr, swigRelease, toString

    Methods inherited from class java.lang.Object

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

    • LocalSearchFilter

      protected LocalSearchFilter(long cPtr, boolean cMemoryOwn)
    • LocalSearchFilter

      public LocalSearchFilter()
  • Method Details

    • getCPtr

      protected static long getCPtr(LocalSearchFilter obj)
    • swigRelease

      protected static long swigRelease(LocalSearchFilter obj)
    • finalize

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

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

      protected void swigDirectorDisconnect()
    • swigReleaseOwnership

      public void swigReleaseOwnership()
    • swigTakeOwnership

      public void swigTakeOwnership()
    • Relax

      public void Relax(Assignment delta, Assignment deltadelta)
      Lets the filter know what delta and deltadelta will be passed in the next
      Accept().
    • Commit

      public void Commit(Assignment delta, Assignment deltadelta)
      Dual of Relax(), lets the filter know that the delta was accepted.
    • accept

      public boolean accept(Assignment delta, Assignment deltadelta, long objective_min, long objective_max)
      Accepts a "delta" given the assignment with which the filter has been
      synchronized; the delta holds the variables which have been modified and
      their new value.
      If the filter represents a part of the global objective, its contribution
      must be between objective_min and objective_max.
      Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
      for the assignment (a,1), (b,0), the delta (b,1) will be rejected
      but the delta (a,0) will be accepted.
      TODO(user): Remove arguments when there are no more need for those.
    • isIncremental

      public boolean isIncremental()
    • synchronize

      public void synchronize(Assignment assignment, Assignment delta)
      Synchronizes the filter with the current solution, delta being the
      difference with the solution passed to the previous call to Synchronize()
      or IncrementalSynchronize(). 'delta' can be used to incrementally
      synchronizing the filter with the new solution by only considering the
      changes in delta.
    • Revert

      public void Revert()
      Cancels the changes made by the last Relax()/Accept() calls.
    • Reset

      public void Reset()
      Sets the filter to empty solution.
    • getSynchronizedObjectiveValue

      public long getSynchronizedObjectiveValue()
      Objective value from last time Synchronize() was called.
    • getAcceptedObjectiveValue

      public long getAcceptedObjectiveValue()
      Objective value from the last time Accept() was called and returned true.