Class SimulatedAnnealing<TRng>
Simulated annealing: Numerical Recipes in C (second edition), Chapter 10.9, with the original exit criterion in f(x) replaced by one in x (as the simplex method's).
public sealed class SimulatedAnnealing<TRng> : OptimizationMethod where TRng : class, IRng
Type Parameters
TRngThe generator of the thermal fluctuations, whose samples are uniform in (0, 1).
- Inheritance
-
SimulatedAnnealing<TRng>
- Inherited Members
Remarks
Immutable: it holds a copy of the generator it is given, and each minimization draws from a copy of that, so a
second minimization repeats the first's draws, where QuantLib's continues its generator's stream
(Divergences/SimulatedAnnealingTests.cs). The generator is required: QuantLib's default, a Mersenne Twister
seeded from the clock, is refused.
A vertex whose value is NaN enters the simplex at the largest double, where QuantLib's guard on the initial vertices tests the previous trial's value instead (left from an earlier minimization, or unset) and so lets the NaN in; the vertices a contraction moves are guarded alike, which QuantLib's leaves out.
Constructors
SimulatedAnnealing(double, double, double, int, TRng)
Initializes a new instance of the SimulatedAnnealing<TRng> class that reduces the temperature T by a factor of (1 − ε) after m moves.
public SimulatedAnnealing(double lambda, double T0, double epsilon, int m, TRng rng)
Parameters
lambdadoubleThe characteristic length of the initial simplex.
T0doubleThe initial temperature.
epsilondoubleThe temperature's reduction factor ε.
mintThe number of moves between reductions, not negative.
rngTRngThe generator, which it copies.
Exceptions
- ArgumentOutOfRangeException
mis negative.
SimulatedAnnealing(double, double, int, double, TRng)
Initializes a new instance of the SimulatedAnnealing<TRng> class that budgets a total of K moves and sets the temperature T to the initial temperature times (1 − k/K)^α, with k the total number of moves so far. After K moves the temperature is guaranteed to be zero, after that the optimization runs like a deterministic simplex algorithm.
public SimulatedAnnealing(double lambda, double T0, int K, double alpha, TRng rng)
Parameters
lambdadoubleThe characteristic length of the initial simplex.
T0doubleThe initial temperature.
KintThe budget of moves, not negative.
alphadoubleThe temperature's exponent α.
rngTRngThe generator, which it copies.
Exceptions
- ArgumentOutOfRangeException
Kis negative.
Methods
MinimizeCore(ProblemState, EndCriteria)
The method's algorithm, QuantLib's minimize: minimizes from the state's current value.
protected override EndCriteriaType MinimizeCore(ProblemState P, EndCriteria ec)
Parameters
PProblemStateThe working state, which the minimization changes.
ecEndCriteria
Returns
- EndCriteriaType
The end criterion met.