public class SimulatedAnnealing.SimulatedAnnealingContext extends NeighbourSearch.NeighbourSearchContext
iIter, iT0
Constructor and Description |
---|
SimulatedAnnealingContext() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(Assignment<V,T> assignment,
Model<V,T> model,
Neighbour<V,T> neighbour,
double value,
boolean lazy)
True if the given neighbour is to be be accepted
|
protected void |
activate(Solution<V,T> solution)
Setup the temperature
|
void |
bestSaved(Solution<V,T> solution)
Memorize the iteration when the last best solution was found.
|
protected void |
cool(Solution<V,T> solution)
Cool temperature
|
protected double |
getCoolingRate(int idx) |
protected void |
incIteration(Solution<V,T> solution)
Increment iteration counter, cool/reheat/restoreBest if necessary
|
protected double |
prob(double value)
Neighbour acceptance probability
|
protected double |
prob(double value,
double temp)
Neighbour acceptance probability
|
protected void |
reheat(Solution<V,T> solution)
Reheat temperature
|
protected void |
restoreBest(Solution<V,T> solution)
restore best ever found solution
|
protected void |
train(Solution<V,T> solution)
Set initial temperature based on the training period
|
bestCleared, bestRestored, canContinue, deactivate, getInfo, getInfo, getTimeMillis, solutionUpdated
public SimulatedAnnealingContext()
protected void activate(Solution<V,T> solution)
activate
in class NeighbourSearch.NeighbourSearchContext
solution
- current solutionprotected double getCoolingRate(int idx)
protected void train(Solution<V,T> solution)
solution
- current solutionprotected void cool(Solution<V,T> solution)
solution
- current solutionprotected void reheat(Solution<V,T> solution)
solution
- current solutionprotected void restoreBest(Solution<V,T> solution)
solution
- current solutionprotected double prob(double value)
value
- absolute or relative value of the proposed change (neighbour)protected double prob(double value, double temp)
value
- absolute or relative value of the proposed change (neighbour)temp
- current temperatureprotected boolean accept(Assignment<V,T> assignment, Model<V,T> model, Neighbour<V,T> neighbour, double value, boolean lazy)
accept
in class NeighbourSearch.NeighbourSearchContext
assignment
- current assignmentneighbour
- proposed movemodel
- problem modelvalue
- value of the generated move (i.e., its impact on the solution value)lazy
- true if lazy moveprotected void incIteration(Solution<V,T> solution)
incIteration
in class NeighbourSearch.NeighbourSearchContext
solution
- current solution