Class: MHL::GenericSwarmBehavior

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/mhl/generic_swarm.rb

Direct Known Subclasses

ChargedSwarm, PSOSwarm, QPSOSwarm

Constant Summary collapse

DEFAULT_C1 =

The following values are considered a best practice [SUN11] [CLERC02] [BLACKWELLBRANKE04]. C_1 is the cognitive acceleration coefficient

2.05
DEFAULT_C2 =

C_2 is the social acceleration coefficient

2.05
PHI =

chi is the constraining factor for normal particles

DEFAULT_C1 + DEFAULT_C2
DEFAULT_CHI =
2.0 / (2 - PHI - Math.sqrt((PHI ** 2 - 4.0 * PHI))).abs
DEFAULT_ALPHA =

alpha is the contraction-expansion (CE) coefficient for quantum particles [SUN11]. In order for the QPSO algorithm to converge, alpha must be lower than $e^gamma approx 1.781$, where $gamma approx 0.5772156649$ is the Euler constant. According to [SUN11], 0.75 looks like a sensible default parameter.

0.75

Instance Method Summary collapse

Instance Method Details

#update_attractorObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mhl/generic_swarm.rb', line 29

def update_attractor
  # get the particle attractors
  particle_attractors = @particles.map { |p| p.attractor }

  # update swarm attractor (if needed)
  unless (defined?(@swarm_attractor))
    @swarm_attractor = particle_attractors.max_by {|p| p[:height] }
  else
    @swarm_attractor = [ @swarm_attractor, *particle_attractors ].max_by {|p| p[:height] }
  end

  @swarm_attractor
end