wolfram mathematica - Creating inequalities out of a auto-generated set of variables -
in mathematica's nminimise function have set up:
nminimize[{1/rij, x1^2 + y1^2 <= 25, x2^2 + y2^2 <= 25, x3^2 + y3^2 <= 25, x4^2 + y4^2 <= 25, x5^2 + y5^2 <= 25, x6^2 + y6^2 <= 25, x7^2 + y7^2 <= 25, x8^2 + y8^2 <= 25, x9^2 + y9^2 <= 25, x10^2 + y10^2 <= 25}, join[take[xi, number], take[yi, number]]]
where xi , yi represent list of generated variables, x1,x2,x3,x4 , on x100. rather set lots of constraints x1^2 + y1^2 <= 25, x2^2 + y2^2 <= 25 , on above id set 1 constraint class of variables, akin x#^2+y#^2<=25 problem can generalised large n.
ive tried inputting list of inequalities however, mathematica not seem accept input.
thanks.
try working indexd variables x[ 1],y[ 1],x[2],y[2]...x[n],y[n]
, can ,
nminimize[ join[{1/rij},table[x[i]^2+y[i]^2<25,{i,number}]] , flatten[table[{x[i],y[i]]},{i,number}] ]]
(..untested..)
update: tested..
n = 15; pts = table[randomreal[{-5, 5}, 2], {n}]; s = nminimize[ join[{sum[norm@({x[i], y[i]} - pts[[i]]), {i, n}]}, table[x[i]^2 + y[i]^2 < 1, {i, n}]], flatten[table[{x[i], y[i]}, {i, n}]]];
i don't known rij is..
graphics[ {pointsize[.05], point /@ pts, circle[{0, 0}, 1], red, point /@ table[{x[i], y[i]}, {i, n}] /. last@s}]
Comments
Post a Comment