Class RandomNeighborhood
- java.lang.Object
-
- org.chocosolver.solver.search.loop.lns.neighbors.Neighbor
-
- org.chocosolver.solver.search.loop.lns.neighbors.RandomNeighborhood
-
-
Field Summary
Fields Modifier and Type Field Description protected BitSet
fragment
Indicate which variables are selected to be part of the fragmentprotected int
level
Relaxing factorprotected int
limit
Next time the level should be increasedprotected int
n
Number of variables to consider in this neighbor
-
Constructor Summary
Constructors Constructor Description RandomNeighborhood(IntVar[] vars, int level, long seed)
Create a neighbor for LNS which randomly selects variable to be part of a fragment
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fixSomeVariables()
Freezes some variables in order to have a fast computation.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)-
Methods inherited from class org.chocosolver.solver.search.loop.lns.neighbors.Neighbor
forEachIntVar, freeze, init, isSearchComplete
-
-
-
-
Field Detail
-
n
protected final int n
Number of variables to consider in this neighbor
-
limit
protected int limit
Next time the level should be increased
-
level
protected final int level
Relaxing factor
-
fragment
protected BitSet fragment
Indicate which variables are selected to be part of the fragment
-
-
Constructor Detail
-
RandomNeighborhood
public RandomNeighborhood(IntVar[] vars, int level, long seed)
Create a neighbor for LNS which randomly selects variable to be part of a fragment- Parameters:
vars
- variables to consider in thislevel
- relaxing factorseed
- for randomness
-
-
Method Detail
-
recordSolution
public void recordSolution()
Description copied from class:Neighbor
Record values of decision variables to freeze some ones during the next LNS run- Overrides:
recordSolution
in classNeighbor
-
loadFromSolution
public void loadFromSolution(Solution solution)
Description copied from class:Neighbor
Load a solution and record it- Overrides:
loadFromSolution
in classNeighbor
- Parameters:
solution
- a solution to record
-
fixSomeVariables
public void fixSomeVariables() throws ContradictionException
Description copied from class:Neighbor
Freezes some variables in order to have a fast computation. The fixed variables are declared as decisions in the decision path.- Specified by:
fixSomeVariables
in classNeighbor
- Throws:
ContradictionException
-
restrictLess
public void restrictLess()
Description copied from class:Neighbor
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)- Overrides:
restrictLess
in classNeighbor
-
-