26#ifndef quantlib_optimization_hybridsimulatedannealing_hpp
27#define quantlib_optimization_hybridsimulatedannealing_hpp
67 template <
class Sampler,
class Probability,
class Temperature,
class Reannealing = ReannealingTrivial>
83 Temperature temperature,
85 Real startTemperature = 200.0,
86 Real endTemperature = 0.01,
87 Size reAnnealSteps = 50,
89 Size resetSteps = 150,
90 const ext::shared_ptr<OptimizationMethod>& localOptimizer =
91 ext::make_shared<LevenbergMarquardt>(),
117 template <
class Sampler,
class Probability,
class Temperature,
class Reannealing>
121 reannealing_.setProblem(P);
125 Size kStationary = 1;
130 bool temperatureBreached =
false;
131 Array currentTemperature(
n, startTemperature_);
134 Array currentPoint(x);
135 const Array& startingPoint(x);
138 Real currentValue = bestValue;
139 Real startingValue = bestValue;
140 while (k <= maxK && kStationary <= maxKStationary && !temperatureBreached)
143 sampler_(newPoint, currentPoint, currentTemperature);
149 if (probability_(currentValue, newValue, currentTemperature)) {
150 if (optimizeScheme_ == EveryNewPoint) {
153 localOptimizer_->minimize(P, endCriteria);
157 currentPoint = newPoint;
158 currentValue = newValue;
162 if (newValue < bestValue) {
163 if (optimizeScheme_ == EveryBestPoint) {
166 localOptimizer_->minimize(P, endCriteria);
171 bestValue = newValue;
172 bestPoint = newPoint;
180 for (
Real& i : annealStep)
184 if (kReAnneal == reAnnealSteps_) {
186 reannealing_(annealStep, currentPoint, currentValue, currentTemperature);
191 if (kReset == resetSteps_) {
193 switch (resetScheme_) {
197 currentPoint = startingPoint;
198 currentValue = startingValue;
200 case ResetToBestPoint:
201 currentPoint = bestPoint;
202 currentValue = bestValue;
209 temperature_(currentTemperature, currentTemperature, annealStep);
212 for (
Size i = 0; i <
n; i++)
213 temperatureBreached = temperatureBreached && currentTemperature[i] < endTemperature_;
219 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
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, const ext::shared_ptr< OptimizationMethod > &localOptimizer=ext::make_shared< LevenbergMarquardt >(), LocalOptimizeScheme optimizeScheme=EveryBestPoint)
LocalOptimizeScheme optimizeScheme_
ext::shared_ptr< OptimizationMethod > localOptimizer_
EndCriteria::Type minimize(Problem &P, const EndCriteria &endCriteria) override
minimize the optimization problem P
Abstract class for constrained optimization method.
Constrained optimization problem.
const Array & currentValue() const
current value of the local minimum
void setCurrentValue(Array currentValue)
Real functionValue() const
value of cost function
Real value(const Array &x)
call cost function computation and increment evaluation counter
void setFunctionValue(Real functionValue)
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.
Maps shared_ptr to either the boost or std implementation.