27#ifndef quantlib_optimization_particleswarmoptimization_hpp
28#define quantlib_optimization_particleswarmoptimization_hpp
97 ext::shared_ptr<Topology> topology,
98 ext::shared_ptr<Inertia> inertia,
103 ext::shared_ptr<Topology> topology,
104 ext::shared_ptr<Inertia> inertia,
164 for (
Size i = 0; i <
M_; i++) {
189 for (
Size i = 0; i <
M_; i++) {
219 for (
Size i = 0; i <
M_; i++) {
267 1,
Array(1, 1.0), seed),
276 for (
Size i = 0; i <
M_; i++) {
350 Real bestF = (*pBF_)[0];
352 for (
Size i = 1; i <
M_; i++) {
353 if (bestF < (*
pBF_)[i]) {
358 Array& x = (*pBX_)[bestP];
359 for (
Size i = 0; i <
M_; i++) {
379 QL_REQUIRE(K > 0,
"Neighbors need to be larger than 0");
383 QL_ENSURE(
K_ < M,
"Number of neighbors need to be smaller than total particles in swarm");
void setValues() override
produce changes to PSO state for current iteration
void setSize(Size M, Size N, Real c0, const EndCriteria &endCriteria) override
initialize state for current problem
AdaptiveInertia(Real minInertia, Real maxInertia, Size sh=5, Size sl=2)
1-D array used in linear algebra.
std::uniform_int_distribution< QuantLib::Size > distribution_
std::vector< std::vector< bool > > particles4clubs_
std::vector< std::vector< bool > > clubs4particles_
std::vector< Size > worstByClub_
void setSize(Size M) override
initialize state for current problem
decltype(distribution_)::param_type param_type
void findSocialBest() override
produce changes to PSO state for current iteration
std::vector< Size > bestByClub_
void joinRandomClub(Size particle, Size currentClubs)
void leaveRandomClub(Size particle, Size currentClubs)
void setValues() override
produce changes to PSO state for current iteration
DecreasingInertia(Real threshold=0.5)
void setSize(Size M, Size N, Real c0, const EndCriteria &endCriteria) override
initialize state for current problem
Criteria to end optimization process:
Size maxIterations() const
void setSize(Size M) override
initialize state for current problem
void findSocialBest() override
produce changes to PSO state for current iteration
void setSize(Size M) override
initialize state for current problem
void findSocialBest() override
produce changes to PSO state for current iteration
Levy Flight distribution.
void setValues() override
produce changes to PSO state for current iteration
std::vector< Size > adaptiveCounter_
IsotropicRandomWalk< LevyFlightDistribution, std::mt19937 > flight_
LevyFlightInertia(Real alpha, Size threshold, unsigned long seed=SeedGenerator::instance().get())
MersenneTwisterUniformRng rng_
void setSize(Size M, Size N, Real c0, const EndCriteria &endCriteria) override
initialize state for current problem
void init(ParticleSwarmOptimization *pso) override
Abstract class for constrained optimization method.
Base inertia class used to alter the PSO state.
std::vector< Array > * V_
std::vector< Array > * pBX_
std::vector< Array > * X_
ParticleSwarmOptimization * pso_
virtual void setSize(Size M, Size N, Real c0, const EndCriteria &endCriteria)=0
initialize state for current problem
virtual void init(ParticleSwarmOptimization *pso)
virtual void setValues()=0
produce changes to PSO state for current iteration
virtual ~Inertia()=default
std::vector< Array > * gBX_
Base topology class used to determine the personal and global best.
std::vector< Array > * V_
virtual ~Topology()=default
std::vector< Array > * pBX_
virtual void setSize(Size M)=0
initialize state for current problem
std::vector< Array > * X_
ParticleSwarmOptimization * pso_
virtual void findSocialBest()=0
produce changes to PSO state for current iteration
void init(ParticleSwarmOptimization *pso)
std::vector< Array > * gBX_
std::vector< Array > gBX_
void startState(Problem &P, const EndCriteria &endCriteria)
MersenneTwisterUniformRng rng_
ext::shared_ptr< Topology > topology_
ext::shared_ptr< Inertia > inertia_
std::vector< Array > pBX_
EndCriteria::Type minimize(Problem &P, const EndCriteria &endCriteria) override
minimize the optimization problem P
Constrained optimization problem.
void setValues() override
produce changes to PSO state for current iteration
SimpleRandomInertia(Real threshold=0.5, unsigned long seed=SeedGenerator::instance().get())
MersenneTwisterUniformRng rng_
void setSize(Size M, Size N, Real c0, const EndCriteria &endCriteria) override
initialize state for current problem
static SeedGenerator & instance()
access to the unique instance
void setValues() override
produce changes to PSO state for current iteration
void setSize(Size M, Size N, Real c0, const EndCriteria &endCriteria) override
initialize state for current problem
Abstract constraint class.
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
Levy Flight, aka Pareto Type I, distribution.
Abstract optimization problem class.