Particle swarm optimization: Difference between revisions

m
→‎{{header|REXX}}: adjusted the alignment of the output columns.
m (→‎{{header|REXX}}: added/changed comments and whitespace. optimized the SIN function.)
m (→‎{{header|REXX}}: adjusted the alignment of the output columns.)
Line 1,539:
<lang rexx>/*REXX program calculates Particle Swarm Optimization as it migrates through a solution.*/
numeric digits length( pi() ) - 1 /*use the number of decimal digs in pi.*/
numeric digits 44
parse arg x y d #part sDigs . /*obtain optional arguments from the CL*/
if x=='' | x=="," then x= -0.5 /*Not specified? Then use the default.*/
Line 1,555 ⟶ 1,556:
end /*until*/ /* [↑] stop refining if no difference.*/
say
$= 1315 + show * 2 /*compute the indentation for alignment*/
say right('The global minimum for f(-.54719, -1.54719) ───► ', $) fmt(f(-.54719, -1.54719))
say right('The published global minimum is:' , $) fmt( -1.9133 )
Line 1,638 ⟶ 1,639:
58 -0.5471975511965977461542145 -1.5471975511965977461542145 -1.9132229549810363929179376
 
The global minimum for f(-.54719, -1.54719) ───► -1.9132229548822735814541188
The published global minimum is: -1.9133
</pre>
Output note: &nbsp; the published global minimum (referenced above, as well as the function's arguments) can be found at: