V
- VariableT
- Valuepublic class HillClimber<V extends Variable<V,T>,T extends Value<V,T>> extends NeighbourSearch<V,T>
Neighbour.value(Assignment)
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=org.cpsolver.ifs.algorithms.neighbourhoods.RandomMove;org.cpsolver.ifs.algorithms.neighbourhoods.RandomSwapMove@0.1
Selector RandomSwapMove is 10× less probable to be selected than other selectors.
When HillClimber.Random is true, all selectors are selected with the same probability, ignoring these weights.
NeighbourSelector.update(Assignment, 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 | Class and Description |
---|---|
class |
HillClimber.HillClimberContext |
NeighbourSearch.NeighbourSearchContext
Modifier and Type | Field and Description |
---|---|
protected int |
iMaxIdleIters |
protected boolean |
iSetHCMode |
protected static double |
sEPS |
iDF2, iPhase
iContextOverride
sMaxSize
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 |
---|---|
NeighbourSearch.NeighbourSearchContext |
createAssignmentContext(Assignment<V,T> assignment)
Create a new assignment context for the given assignment.
|
String |
getParameterBaseName()
All parameters start with HillClimber base name, e.g., HillClimber.MaxIdle
|
void |
init(Solver<V,T> solver)
Initialization
|
void |
setPhase(String phase)
Set progress phase name
|
accept, accept, addNeighbourSelection, bestCleared, bestRestored, bestSaved, generateMove, getInfo, getInfo, getNeighbours, info, isMaster, logNeibourStatus, nextNeighbourSelection, selectNeighbour, setHCMode, setProgress, setProgressPhase, solutionUpdated
getAssignmentContextReference, getContext, getContext, hasContextOverride, isSingleContextSolver, setAssignmentContextReference
protected int iMaxIdleIters
protected boolean iSetHCMode
protected static double sEPS
public HillClimber(DataProperties properties)
NeighbourSelection
NeighbourSelection
NeighbourSelector.getPoints()
weights (roulette wheel selection)
properties
- solver configurationpublic void setPhase(String phase)
phase
- name of the phase in which the hill climber is used (for logging purposes)public String getParameterBaseName()
getParameterBaseName
in class NeighbourSearch<V extends Variable<V,T>,T extends Value<V,T>>
public NeighbourSearch.NeighbourSearchContext createAssignmentContext(Assignment<V,T> assignment)
HasAssignmentContext
assignment
- an assignment for which there needs to be an assignment context