Class Neighbor
- java.lang.Object
-
- org.chocosolver.solver.search.loop.lns.neighbors.Neighbor
-
- All Implemented Interfaces:
ICause
- Direct Known Subclasses:
PropagationGuidedNeighborhood
,RandomNeighborhood
,SequenceNeighborhood
public abstract class Neighbor extends Object implements ICause
An abstract class that defines services required for the LNS to select variables to freeze-unfreeze.- Since:
- 18/06/13
- Author:
- Charles Prud'homme
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
fixSomeVariables()
Freezes some variables in order to have a fast computation.void
forEachIntVar(Consumer<IntVar> action)
Apply an action on each variable declared on the scope of this cause, if any.void
freeze(int i)
Freeze variable at position 'i' to its value in that recorded solution.void
init()
Initialize this neighborboolean
isSearchComplete()
void
loadFromSolution(Solution solution)
Load a solution and record itvoid
recordSolution()
Record values of decision variables to freeze some ones during the next LNS runvoid
restrictLess()
Use less restriction at the beginning of a LNS run in order to get better solutions Called when no solution was found during a LNS run (trapped into a local optimum)
-
-
-
Field Detail
-
variables
protected final IntVar[] variables
-
values
protected final int[] values
-
-
Constructor Detail
-
Neighbor
protected Neighbor(IntVar[] variables)
-
-
Method Detail
-
init
public void init()
Initialize this neighbor
-
recordSolution
public void recordSolution()
Record values of decision variables to freeze some ones during the next LNS run
-
fixSomeVariables
public abstract void fixSomeVariables() throws ContradictionException
Freezes some variables in order to have a fast computation. The fixed variables are declared as decisions in the decision path.- Throws:
ContradictionException
-
freeze
public void freeze(int i) throws ContradictionException
Freeze variable at position 'i' to its value in that recorded solution.- Parameters:
i
- position of the variable to instantiate- Throws:
ContradictionException
- if a contradiction occurs
-
restrictLess
public void restrictLess()
Use less restriction at the beginning of a LNS run in order to get better solutions Called when no solution was found during a LNS run (trapped into a local optimum)
-
isSearchComplete
public boolean isSearchComplete()
- Returns:
- true iff the search is in a complete mode (no fixed variable)
-
loadFromSolution
public void loadFromSolution(Solution solution)
Load a solution and record it- Parameters:
solution
- a solution to record
-
forEachIntVar
public void forEachIntVar(Consumer<IntVar> action)
Description copied from interface:ICause
Apply an action on each variable declared on the scope of this cause, if any.- Specified by:
forEachIntVar
in interfaceICause
- Parameters:
action
- action to perform on each variable declared in this cause.
-
-