QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
|
#include <fireflyalgorithm.hpp>
Classes | |
class | Intensity |
Base intensity class. More... | |
class | RandomWalk |
Base Random Walk class. More... | |
Public Member Functions | |
FireflyAlgorithm (Size M, ext::shared_ptr< Intensity > intensity, ext::shared_ptr< RandomWalk > randomWalk, Size Mde=0, Real mutationFactor=1.0, Real crossoverFactor=0.5, unsigned long seed=SeedGenerator::instance().get()) | |
void | startState (Problem &P, const EndCriteria &endCriteria) |
EndCriteria::Type | minimize (Problem &P, const EndCriteria &endCriteria) override |
minimize the optimization problem P More... | |
Public Member Functions inherited from OptimizationMethod | |
virtual | ~OptimizationMethod ()=default |
virtual EndCriteria::Type | minimize (Problem &P, const EndCriteria &endCriteria)=0 |
minimize the optimization problem P More... | |
Protected Attributes | |
std::vector< Array > | x_ |
std::vector< Array > | xI_ |
std::vector< Array > | xRW_ |
std::vector< std::pair< Real, Size > > | values_ |
Array | lX_ |
Array | uX_ |
Real | mutation_ |
Real | crossover_ |
Size | M_ |
Size | N_ |
Size | Mde_ |
Size | Mfa_ |
ext::shared_ptr< Intensity > | intensity_ |
ext::shared_ptr< RandomWalk > | randomWalk_ |
std::mt19937 | generator_ |
std::uniform_int_distribution< QuantLib::Size > | distribution_ |
MersenneTwisterUniformRng | rng_ |
The main process is as follows: M individuals are used to explore the N-dimensional parameter space: \( X_{i}^k = (X_{i, 1}^k, X_{i, 2}^k, \ldots, X_{i, N}^k) \) is the kth-iteration for the ith-individual. X is updated via the rule
\[ X_{i, j}^{k+1} = X_{i, j}^k + I(X^k)_{i,j} + RandomWalk_{i,j}^k \]
The intensity function I(X) should be monotonic The optimization stops either because the number of iterations has been reached or because the stationary function value limit has been reached.
The current implementation extends the normal Firefly Algorithm with a differential evolution (DE) optimizer according to: Afnizanfaizal Abdullah, et al. "A New Hybrid Firefly Algorithm for Complex and Nonlinear Problem". Volume 151 of the series Advances in Intelligent and Soft Computing pp 673-680, 2012. http://link.springer.com/chapter/10.1007%2F978-3-642-28765-7_81
In effect this implementation provides a fully fledged DE global optimizer as well. The Firefly Algorithm was easy to combine with DE because it already contained a step where the current solutions are sorted. The population is then divided into two subpopulations based on their order. The subpopulation with the best results are updated via the firefly algorithm. The worse subpopulation is updated via the DE operator:
\[ Y^{k+1} = X_{best}^k + F(X_{r1}^k - X_{r2}^k) \]
and
\[ X_{i,j}^{k+1} = Y_{i,j}^{k+1}\ \text{if} R_{i,j} <= C \]
\[ X_{i,j}^{k+1} = X_{i,j}^{k+1}\ \text{otherwise} \]
where C is the crossover constant, and R is a random uniformly distributed number.
Definition at line 80 of file fireflyalgorithm.hpp.
FireflyAlgorithm | ( | Size | M, |
ext::shared_ptr< Intensity > | intensity, | ||
ext::shared_ptr< RandomWalk > | randomWalk, | ||
Size | Mde = 0 , |
||
Real | mutationFactor = 1.0 , |
||
Real | crossoverFactor = 0.5 , |
||
unsigned long | seed = SeedGenerator::instance().get() |
||
) |
Definition at line 27 of file fireflyalgorithm.cpp.
void startState | ( | Problem & | P, |
const EndCriteria & | endCriteria | ||
) |
Definition at line 42 of file fireflyalgorithm.cpp.
|
overridevirtual |
minimize the optimization problem P
Implements OptimizationMethod.
Definition at line 75 of file fireflyalgorithm.cpp.
|
protected |
Definition at line 95 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 95 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 95 of file fireflyalgorithm.hpp.
Definition at line 96 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 97 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 97 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 98 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 98 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 99 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 99 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 99 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 99 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 100 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 101 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 102 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 103 of file fireflyalgorithm.hpp.
|
protected |
Definition at line 104 of file fireflyalgorithm.hpp.