public class HillClimber<V extends Variable<V,T>,T extends Value<V,T>> extends NeighbourSearch<V,T>
Neighbour.value()
is below or equal to zero. The search is
stopped after a given amount of idle iterations ( can be defined by problem
property HillClimber.MaxIdle). NeighbourSelection
. By default,
each neighbour selection is selected with the same probability (each has 1 point in
a roulette wheel selection). It can be changed by adding @n at the end
of the name of the class, for example:
HillClimber.Neighbours=net.sf.cpsolver.ifs.algorithms.neighbourhoods.RandomMove;net.sf.cpsolver.ifs.algorithms.neighbourhoods.RandomSwapMove@0.1
NeighbourSelector.update(Neighbour, long)
is called
after each iteration (on the selector that was used) and roulette wheel selection
that is using NeighbourSelector.getPoints()
is used to pick a selector in each iteration.
See NeighbourSelector
for more details.
Modifier and Type | Field and Description |
---|---|
protected double |
iBestValue |
protected int |
iLastImprovingIter |
protected int |
iMaxIdleIters |
protected boolean |
iSetHCMode |
Constructor and Description |
---|
HillClimber(DataProperties properties)
Constructor
HillClimber.MaxIdle ... maximum number of idle iterations (default is 200000)
HillClimber.Neighbours ... semicolon separated list of classes implementing
NeighbourSelection
HillClimber.AdditionalNeighbours ... semicolon separated list of classes implementing NeighbourSelection
HillClimber.Random ... when true, a neighbour selector is selected randomly
HillClimber.Update ... when true, a neighbour selector is selected using NeighbourSelector.getPoints() weights (roulette wheel selection)
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(Model<V,T> model,
Neighbour<V,T> neighbour,
double value,
boolean lazy)
Accept any move that does not worsen the solution (value <= 0)
|
protected void |
activate(Solution<V,T> solution)
Reset the idle iterations counter
|
void |
bestSaved(Solution<V,T> solution)
Memorize the iteration when the last best solution was found.
|
protected boolean |
canContinue(Solution<V,T> solution)
Stop the search after a given number of idle (not improving) iterations
|
String |
getParameterBaseName()
All parameters start with HillClimber base name, e.g., HillClimber.MaxIdle
|
protected void |
incIteration(Solution<V,T> solution)
Increase iteration counter
|
void |
init(Solver<V,T> solver)
Initialization
|
void |
setPhase(String phase)
Set progress phase name
|
accept, accept, addNeighbourSelection, bestCleared, bestRestored, deactivate, generateMove, getInfo, getInfo, getNeighbours, getTimeMillis, logNeibourStatus, nextNeighbourSelection, selectNeighbour, setHCMode, solutionUpdated
protected int iMaxIdleIters
protected int iLastImprovingIter
protected double iBestValue
protected boolean iSetHCMode
public HillClimber(DataProperties properties)
NeighbourSelection
NeighbourSelection
NeighbourSelector.getPoints()
weights (roulette wheel selection)
protected void incIteration(Solution<V,T> solution)
incIteration
in class NeighbourSearch<V extends Variable<V,T>,T extends Value<V,T>>
protected boolean canContinue(Solution<V,T> solution)
canContinue
in class NeighbourSearch<V extends Variable<V,T>,T extends Value<V,T>>
public void bestSaved(Solution<V,T> solution)
protected boolean accept(Model<V,T> model, Neighbour<V,T> neighbour, double value, boolean lazy)
public String getParameterBaseName()
getParameterBaseName
in class NeighbourSearch<V extends Variable<V,T>,T extends Value<V,T>>