43 static constexpr double c1 = 1.49445;
45 static constexpr double c2 = 1.49445;
130 bool bBestChanged =
false;
139 rParticle.mVelocity[k]
141 + (
c1 * fRandom1 * (rParticle.mBestPosition[k] - rParticle.mPosition[k]))
146 rParticle.mPosition[k] += rParticle.mVelocity[k];
147 rParticle.mPosition[k] =
mrDataProvider.clampVariable(k, rParticle.mPosition[k]);
150 rParticle.mCurrentFitness =
mrDataProvider.calculateFitness(rParticle.mPosition);
152 if (rParticle.mCurrentFitness > rParticle.mBestFitness)
154 rParticle.mBestFitness = rParticle.mCurrentFitness;
155 rParticle.mBestPosition.insert(rParticle.mBestPosition.begin(),
156 rParticle.mPosition.begin(),
157 rParticle.mPosition.end());
168 rParticle.mPosition.end());
static constexpr double constWeight
static constexpr double c1
std::random_device maRandomDevice
std::vector< Particle > maSwarm
ParticleSwarmOptimizationAlgorithm(DataProvider &rDataProvider, size_t nNumOfParticles)
std::vector< double > maBestPosition
static constexpr double c2
std::vector< double > const & getResult()
DataProvider & mrDataProvider
static constexpr double constAcceptedPrecision
std::uniform_real_distribution maRandom01
std::vector< double > mPosition
std::vector< double > mVelocity
Particle(size_t nDimensionality)
std::vector< double > mBestPosition