Anonymous user
Particle swarm optimization: Difference between revisions
m
→{{header|REXX}}: changed use of single and double quote characters.
m (→{{header|REXX}}: added/changed whitespace and comments, added a comment to the REXX section header.) |
m (→{{header|REXX}}: changed use of single and double quote characters.) |
||
Line 426:
numeric digits length(pi()) /*sDigs: is the # of displayed digits.*/
parse arg x y d #part sDigs . /*obtain optional arguments from the CL*/
if x=='' | x==
if y=='' | y==
if d=='' | d==
if #part=='' | #part==
if sDigs=='' | sDigs==
minF=#part; old= /*number of particles is one billion. */
say center('X', sDigs+3,
call refine x,y
do until refine(minX,minY); d=d*.2 /*increase the difference.*/
Line 452:
/*──────────────────────────────────────────────────────────────────────────────────one─liner subroutines───────────────────────────────*/
f: procedure: parse arg a,b; return sin(a+b) + (a-b)**2 - 1.5*a + 2.5*b + 1
fmt: parse arg ?; ?=format(?,,sDigs); L=length(?); if pos(.,?)\==0 then ?=strip(strip(?,'T',0),
pi: pi=3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068; return pi
r2r: return arg(1) // (pi()*2) /*normalize radians ───► a unit circle.*/
|