26#ifndef quantlib_optimization_hybridsimulatedannealing_hpp
27#define quantlib_optimization_hybridsimulatedannealing_hpp
66 template <
class Sampler,
class Probability,
class Temperature,
class Reannealing = ReannealingTrivial>
82 Temperature temperature,
84 Real startTemperature = 200.0,
85 Real endTemperature = 0.01,
86 Size reAnnealSteps = 50,
88 Size resetSteps = 150,
89 ext::shared_ptr<OptimizationMethod> localOptimizer =
90 ext::shared_ptr<OptimizationMethod>(),
119 template <
class Sampler,
class Probability,
class Temperature,
class Reannealing>
123 reannealing_.setProblem(P);
127 Size kStationary = 1;
132 bool temperatureBreached =
false;
133 Array currentTemperature(
n, startTemperature_);
136 Array currentPoint(x);
137 const Array& startingPoint(x);
140 Real currentValue = bestValue;
141 Real startingValue = bestValue;
142 while (k <= maxK && kStationary <= maxKStationary && !temperatureBreached)
145 sampler_(newPoint, currentPoint, currentTemperature);
151 if (probability_(currentValue, newValue, currentTemperature)) {
152 if (optimizeScheme_ == EveryNewPoint) {
155 localOptimizer_->minimize(P, endCriteria);
159 currentPoint = newPoint;
160 currentValue = newValue;
164 if (newValue < bestValue) {
165 if (optimizeScheme_ == EveryBestPoint) {
168 localOptimizer_->minimize(P, endCriteria);
173 bestValue = newValue;
174 bestPoint = newPoint;
182 for (
Real& i : annealStep)
186 if (kReAnneal == reAnnealSteps_) {
188 reannealing_(annealStep, currentPoint, currentValue, currentTemperature);
193 if (kReset == resetSteps_) {
195 switch (resetScheme_) {
199 currentPoint = startingPoint;
200 currentValue = startingValue;
202 case ResetToBestPoint:
203 currentPoint = bestPoint;
204 currentValue = bestValue;
211 temperature_(currentTemperature, currentTemperature, annealStep);
214 for (
Size i = 0; i <
n; i++)
215 temperatureBreached = temperatureBreached && currentTemperature[i] < endTemperature_;
221 else if (kStationary > maxKStationary)
1-D array used in linear algebra.
Size size() const
dimension of the array
Criteria to end optimization process:
Size maxIterations() const
Size maxStationaryStateIterations() const
LocalOptimizeScheme optimizeScheme_
ext::shared_ptr< OptimizationMethod > localOptimizer_
HybridSimulatedAnnealing(const Sampler &sampler, const Probability &probability, Temperature temperature, const Reannealing &reannealing=ReannealingTrivial(), Real startTemperature=200.0, Real endTemperature=0.01, Size reAnnealSteps=50, ResetScheme resetScheme=ResetToBestPoint, Size resetSteps=150, ext::shared_ptr< OptimizationMethod > localOptimizer=ext::shared_ptr< OptimizationMethod >(), LocalOptimizeScheme optimizeScheme=EveryBestPoint)
EndCriteria::Type minimize(Problem &P, const EndCriteria &endCriteria) override
minimize the optimization problem P
Levenberg-Marquardt optimization method.
Abstract class for constrained optimization method.
Constrained optimization problem.
const Array & currentValue() const
current value of the local minimum
Real functionValue() const
value of cost function
Real value(const Array &x)
call cost function computation and increment evaluation counter
void setFunctionValue(Real functionValue)
void setCurrentValue(const Array ¤tValue)
Abstract constraint class.
Real Probability
probability
std::size_t Size
size of a container
Functors for use on HybridSimulatedAnnealing.
Levenberg-Marquardt optimization method.
HybridSimulatedAnnealing< SamplerLogNormal, ProbabilityBoltzmannDownhill, TemperatureExponential, ReannealingTrivial > LogNormalSimulatedAnnealing
HybridSimulatedAnnealing< SamplerVeryFastAnnealing, ProbabilityBoltzmannDownhill, TemperatureVeryFastAnnealing, ReannealingFiniteDifferences > VeryFastSimulatedReAnnealing
HybridSimulatedAnnealing< SamplerVeryFastAnnealing, ProbabilityBoltzmannDownhill, TemperatureVeryFastAnnealing, ReannealingTrivial > VeryFastSimulatedAnnealing
HybridSimulatedAnnealing< SamplerGaussian, ProbabilityBoltzmannDownhill, TemperatureExponential, ReannealingFiniteDifferences > GaussianSimulatedReAnnealing
HybridSimulatedAnnealing< SamplerGaussian, ProbabilityBoltzmannDownhill, TemperatureExponential, ReannealingTrivial > GaussianSimulatedAnnealing
HybridSimulatedAnnealing< SamplerMirrorGaussian, ProbabilityBoltzmannDownhill, TemperatureExponential, ReannealingTrivial > MirrorGaussianSimulatedAnnealing
Abstract optimization problem class.