*--------------------------------------------------------------* * Scaled Morse Test Problem * *--------------------------------------------------------------* File res / results / ; Put res ; Sets i number of particles /1*10/ iter number of local mins /1*1/ alias(i,j); Scalars bnd absolute value of bound /5.0/ rho Morse adjustable param /3.0/; Parameters b(i,j) on-off for interactions; loop(i, loop(j, b(i,j) = 1 $ (ord(i) lt ord(j)))); Variables x(i) x coordinates y(i) y coordinates z(i) z coordinates f potential energy; loop(i, x.lo(i) = -bnd $ (ord(i) ge 2); y.lo(i) = -bnd $ (ord(i) ge 3); z.lo(i) = -bnd $ (ord(i) ge 4); x.up(i) = bnd $ (ord(i) ge 2); y.up(i) = bnd $ (ord(i) ge 3); z.up(i) = bnd $ (ord(i) ge 4)); x.fx('1') = 0; y.fx('1') = 0; z.fx('1') = 0; y.fx('2') = 0; z.fx('2') = 0; z.fx('3') = 0; Equations obj objective function; obj .. f =e= sum((i,j) $ b(i,j), power(1-exp(rho*(1- (power(x(i)-x(j),2) + power(y(i)-y(j),2) + power(z(i)-z(j),2))**0.5)), 2) - 1); Model problem /obj/; loop(iter, x.l(i) = uniform(x.lo(i),x.up(i)); y.l(i) = uniform(y.lo(i),y.up(i)); z.l(i) = uniform(z.lo(i),z.up(i)); solve problem using nlp minimizing f; PUT "Local Minimum energy = ",f.l:16:10//; );