Class SimulatedAnnealing
- java.lang.Object
-
- org.apache.commons.math4.legacy.optim.nonlinear.scalar.SimulatedAnnealing
-
- All Implemented Interfaces:
OptimizationData
public class SimulatedAnnealing extends Object implements OptimizationData
Simulated annealing setup.- Since:
- 4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SimulatedAnnealing.CoolingSchedule
Specifies the cooling schedule.
-
Constructor Summary
Constructors Constructor Description SimulatedAnnealing(int epoch, double startProb, double endProb, SimulatedAnnealing.CoolingSchedule cooling, org.apache.commons.rng.UniformRandomProvider random)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimulatedAnnealing.CoolingSchedule
getCoolingSchedule()
double
getEndProbability()
int
getEpochDuration()
double
getStartProbability()
DoublePredicate
metropolis(double temperature)
Factory for the Metropolis check for accepting a worse state.
-
-
-
Constructor Detail
-
SimulatedAnnealing
public SimulatedAnnealing(int epoch, double startProb, double endProb, SimulatedAnnealing.CoolingSchedule cooling, org.apache.commons.rng.UniformRandomProvider random)
- Parameters:
epoch
- Number of iterations performed at fixed temperature.startProb
- Initial acceptance probablility.endProb
- Final acceptance probablility.cooling
- Computes the temperature as a function of the initial temperature and the epoch. It is called for computing a new temperature after each cycle ofepoch
iterations. Simulated annealing assumes that the function decreases monotically wrt the epoch (cf.provided implementation
).random
- Random number generator.- Throws:
IllegalArgumentException
- ifepoch < 1
orstartProb
orendProb
is outside the[0, 1]
interval.
-
-
Method Detail
-
getEpochDuration
public int getEpochDuration()
- Returns:
- the epoch duration.
-
getStartProbability
public double getStartProbability()
- Returns:
- the acceptance probability at the beginning of the SA process.
-
getEndProbability
public double getEndProbability()
- Returns:
- the acceptance probability at the end of the SA process.
-
getCoolingSchedule
public SimulatedAnnealing.CoolingSchedule getCoolingSchedule()
- Returns:
- the cooling schedule.
-
metropolis
public DoublePredicate metropolis(double temperature)
Factory for the Metropolis check for accepting a worse state. \( e^{-|\Delta E| / T} \geq \mathrm{rand}(0, 1) \).It is assumed that this check is performed after ensuring that the alternate state is worse than the current best state.
- Parameters:
temperature
- Current temperature.- Returns:
- the acceptance test.
-
-