Class RandomNeighborhood
- java.lang.Object
-
- org.chocosolver.solver.search.loop.lns.neighbors.RandomNeighborhood
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]bestSolutionLast solution found, wrtvarsprotected BitSetfragmentIndicate which variables are selected to be part of the fragmentprotected intlevelRelaxing factorprotected intlimitNext time the level should be increasedprotected ModelmModelReference to the modelprotected intnNumber of variables to consider in this neighborprotected intnbCallNumber of times this neighbor is calledprotected IntVar[]varsVariables 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 voidfixSomeVariables(DecisionPath decisionPath)Freezes some variables in order to have a fast computation.protected voidimpose(int id, DecisionPath decisionPath)Impose a decision to be part of the fragmentvoidinit()Initialize this neighborbooleanisSearchComplete()voidloadFromSolution(Solution solution)Load a solution and record itvoidrecordSolution()Record values of decision variables to freeze some ones during the next LNS runvoidrestrictLess()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)protected intselectVariable()
-
-
-
Field Detail
-
n
protected final int n
Number of variables to consider in this neighbor
-
vars
protected final IntVar[] vars
Variables to consider in this neighbor
-
bestSolution
protected final int[] bestSolution
Last solution found, wrtvars
-
nbCall
protected int nbCall
Number of times this neighbor is called
-
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
-
mModel
protected Model mModel
Reference to the model
-
-
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
-
init
public void init()
Description copied from interface:INeighborInitialize this neighbor
-
isSearchComplete
public boolean isSearchComplete()
- Specified by:
isSearchCompletein interfaceINeighbor- Returns:
- true iff the search is in a complete mode (no fixed variable)
-
recordSolution
public void recordSolution()
Description copied from interface:INeighborRecord values of decision variables to freeze some ones during the next LNS run- Specified by:
recordSolutionin interfaceINeighbor
-
loadFromSolution
public void loadFromSolution(Solution solution)
Description copied from interface:INeighborLoad a solution and record it- Specified by:
loadFromSolutionin interfaceINeighbor- Parameters:
solution- a solution to record
-
fixSomeVariables
public void fixSomeVariables(DecisionPath decisionPath)
Description copied from interface:INeighborFreezes some variables in order to have a fast computation. The fixed variables are declared as decisions in the decision path.- Specified by:
fixSomeVariablesin interfaceINeighbor- Parameters:
decisionPath- the decision path in which declaring variable to freeze
-
impose
protected void impose(int id, DecisionPath decisionPath)Impose a decision to be part of the fragment- Parameters:
id- variable id invarsdecisionPath- the current decision path
-
selectVariable
protected int selectVariable()
- Returns:
- a variable id in
varsto be part of the fragment
-
restrictLess
public void restrictLess()
Description copied from interface:INeighborUse 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)- Specified by:
restrictLessin interfaceINeighbor
-
-