* indentations + whitespace cleanup
This commit is contained in:
parent
8457e39efe
commit
56c6edab04
285 changed files with 6068 additions and 6223 deletions
|
|
@ -35,7 +35,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** Extended velocity performer for particle swarm optimization.
|
||||
/** Extended velocity performer for particle swarm optimization.
|
||||
*
|
||||
* Derivated from abstract eoVelocity,
|
||||
* At step t: v(t+1)= w * v(t) + c1 * r1 * ( xbest(t)-x(t) ) + c2 * r2 * ( lbest(t) - x(t) ) + c3 * r3 * ( gbest(t) - x(t) )
|
||||
|
|
@ -57,16 +57,16 @@ public:
|
|||
/** Full constructor: Bounds and bound modifier required
|
||||
* @param _topology - The topology
|
||||
* @param _w - The weight factor.
|
||||
* @param _c1 - Learning factor used for the particle's best. Type must be POT::ParticleVelocityType
|
||||
* @param _c1 - Learning factor used for the particle's best. Type must be POT::ParticleVelocityType
|
||||
* @param _c2 - Learning factor used for the local best
|
||||
* @param _c3 - Learning factor used for the global best
|
||||
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
|
||||
* @param _c3 - Learning factor used for the global best
|
||||
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
|
||||
* If the velocities are not real, they won't be bounded by default. Should have a eoBounds ?
|
||||
* @param _bndsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only).
|
||||
* @param _gen - The eo random generator, default=rng
|
||||
*/
|
||||
eoExtendedVelocity (eoTopology < POT > & _topology,
|
||||
const VelocityType & _w,
|
||||
const VelocityType & _w,
|
||||
const VelocityType & _c1,
|
||||
const VelocityType & _c2,
|
||||
const VelocityType & _c3,
|
||||
|
|
@ -86,10 +86,10 @@ public:
|
|||
/** Constructor: No bound updater required <-> fixed bounds
|
||||
* @param _topology - The topology
|
||||
* @param _w - The weight factor.
|
||||
* @param _c1 - The second learning factor used for the particle's best. Type must be POT::ParticleVelocityType
|
||||
* @param _c2 - The third learning factor used for the local best. Type must be POT::ParticleVelocityType
|
||||
* @param _c1 - The second learning factor used for the particle's best. Type must be POT::ParticleVelocityType
|
||||
* @param _c2 - The third learning factor used for the local best. Type must be POT::ParticleVelocityType
|
||||
* @param _c3 - Learning factor used for the global best
|
||||
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
|
||||
* @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities.
|
||||
* If the velocities are not real, they won't be bounded by default. Should have a eoBounds ?
|
||||
* @param _gen - The eo random generator, default=rng
|
||||
*/
|
||||
|
|
@ -113,8 +113,8 @@ public:
|
|||
/** Constructor: Neither bounds nor bound updater required <-> free velocity
|
||||
* @param _topology - The topology
|
||||
* @param _w - The weight factor.
|
||||
* @param _c1 - The second learning factor used for the particle's best. Type must be POT::ParticleVelocityType
|
||||
* @param _c2 - The third learning factor used for the local best. Type must be POT::ParticleVelocityType
|
||||
* @param _c1 - The second learning factor used for the particle's best. Type must be POT::ParticleVelocityType
|
||||
* @param _c2 - The third learning factor used for the local best. Type must be POT::ParticleVelocityType
|
||||
* @param _c3 - Learning factor used for the global best
|
||||
* @param _gen - The eo random generator, default=rng
|
||||
*/
|
||||
|
|
@ -145,25 +145,25 @@ public:
|
|||
{
|
||||
VelocityType r1;
|
||||
VelocityType r2;
|
||||
VelocityType r3;
|
||||
|
||||
VelocityType r3;
|
||||
|
||||
VelocityType newVelocity;
|
||||
|
||||
// cast the learning factors to VelocityType
|
||||
r1 = (VelocityType) rng.uniform (1) * c1;
|
||||
r2 = (VelocityType) rng.uniform (1) * c2;
|
||||
r3 = (VelocityType) rng.uniform (1) * c3;
|
||||
|
||||
r3 = (VelocityType) rng.uniform (1) * c3;
|
||||
|
||||
// need to resize the bounds even if there are dummy because of "isBounded" call
|
||||
bounds.adjust_size(_po.size());
|
||||
|
||||
// assign the new velocities
|
||||
for (unsigned j = 0; j < _po.size (); j++)
|
||||
{
|
||||
newVelocity= omega * _po.velocities[j]
|
||||
+ r1 * (_po.bestPositions[j] - _po[j])
|
||||
+ r2 * (topology.best (_indice)[j] - _po[j])
|
||||
+ r3 * (topology.globalBest()[j] - _po[j]);
|
||||
newVelocity= omega * _po.velocities[j]
|
||||
+ r1 * (_po.bestPositions[j] - _po[j])
|
||||
+ r2 * (topology.best (_indice)[j] - _po[j])
|
||||
+ r3 * (topology.globalBest()[j] - _po[j]);
|
||||
|
||||
/* check bounds */
|
||||
if (bounds.isMinBounded(j))
|
||||
|
|
@ -182,27 +182,27 @@ public:
|
|||
{
|
||||
topology.updateNeighborhood(_po,_indice);
|
||||
}
|
||||
|
||||
|
||||
//! eoTopology<POT> getTopology
|
||||
//! @return topology
|
||||
|
||||
eoTopology<POT> & getTopology ()
|
||||
{
|
||||
return topology;
|
||||
}
|
||||
eoTopology<POT> & getTopology ()
|
||||
{
|
||||
return topology;
|
||||
}
|
||||
|
||||
protected:
|
||||
eoTopology < POT > & topology;
|
||||
const VelocityType & omega; // social/cognitive coefficient
|
||||
const VelocityType & omega; // social/cognitive coefficient
|
||||
const VelocityType & c1;
|
||||
const VelocityType & c2; // social/cognitive coefficient
|
||||
const VelocityType & c3; // social/cognitive coefficient
|
||||
|
||||
eoRealVectorBounds bounds; // REAL bounds even if the velocity could be of another type.
|
||||
eoRealBoundModifier & bndsModifier;
|
||||
const VelocityType & c2; // social/cognitive coefficient
|
||||
const VelocityType & c3; // social/cognitive coefficient
|
||||
|
||||
eoRealVectorBounds bounds; // REAL bounds even if the velocity could be of another type.
|
||||
eoRealBoundModifier & bndsModifier;
|
||||
|
||||
eoRng & gen; // the random generator
|
||||
|
||||
eoRng & gen; // the random generator
|
||||
|
||||
// If the bound modifier doesn't need to be used, use the dummy instance
|
||||
eoDummyRealBoundModifier dummyModifier;
|
||||
};
|
||||
|
|
@ -211,4 +211,3 @@ protected:
|
|||
* Example of a test program using this class:
|
||||
*/
|
||||
#endif /*eoExtendedVelocity_H */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue