Particle swarm optimization: Difference between revisions

→‎{{header|J}}: simplify defn of michalewicz
(updated task description)
(→‎{{header|J}}: simplify defn of michalewicz)
Line 81:
GlobalBestValue: _1.91322</lang>
Apply to Michalewicz Function:
<lang J> michalewicz =: 3 : '-( +/ (sin y) * 20 ^~ sin (>: i. #y) m0* (*:y) % pi'
<lang J>
m0michalewicz =: 4 [: '-@(sin (x{y)+/) sin * 20 ^~ sin @(pi %~ >:x)@i.@# * ((x{y)^2*:) %pi' NB. tacit equivalent
michalewicz =: 3 : '-(+/ (i. #y) m0 y)'
state =: pso_init 0 0 ; (pi,pi) ; 0.3 0.3 0.3; 1000
Line 90 ⟶ 89:
omega, phip, phig: 0.3 0.3 0.3
nParticles: 1000
 
state =: (michalewicz pso)^:30 state
892

edits