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=='",'" then x= -0.5 /*Not specified? Then use the default.*/
if y=='' | y=='",'" then y= -1.5 /* " " " " " " */
if d=='' | d=='",'" then d= 1 /* " " " " " " */
if #part=='' | #part=='",'" then #part=1e12 /* " " " " " " */
if sDigs=='' | sDigs=='",'" then sDigs= 25 /* " " " " " " */
minF=#part; old= /*number of particles is one billion. */
say center('X', sDigs+3, '"'") center('Y', sDigs+3, '"'") center('D', 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),'"T'",.); return left(?,L)
pi: pi=3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068; return pi
r2r: return arg(1) // (pi()*2) /*normalize radians ───► a unit circle.*/