numerical - Limitation of Mathematica optimization module -



numerical - Limitation of Mathematica optimization module -

i have question regarding mathematica's global optimization capability. came across text related nag toolbox (kind of white paper).

now tried solve test case paper. expected mathematica pretty fast in solving it.

n=2; fun[x_,y_]:=10 n+(x-2)^2-10cos[2 pi(x-2)]+(y-2)^2-10 cos[2 pi(y-2)]; nminimize[{fun[x,y],-5<= x<= 5&&-5<= y<= 5},{x,y},method->{"randomsearch","searchpoints"->13}]//absolutetiming

output was

{0.0470026,{0.,{x->2.,y->2.}}}

one can see points visited optimization routine.

{sol, pts}=reap[nminimize[{fun[x,y],-5<= x<= 5&&-5<= y<= 5},{x,y},method->`{"randomsearch","searchpoints"->13},evaluationmonitor:>sow[{x,y}]]];show[contourplot[fun[x,y],{x,-5.5,5.5},{y,-5.5,5.5},colorfunction->"temperaturemap",contours->function[{min,max},range[min,max,5]],contourlines->true,plotrange-> all],listplot[pts,frame-> true,axes-> false,plotrange-> all,plotstyle-> directive[red,opacity[.5],pointsize[large]]],graphics[map[{black,opacity[.7],arrowheads[.026],arrow[#]}&,partition[pts//first,2,1]],plotrange-> {{-5.5,5.5},{-5.5,5.5}}]]`

now thought of solving same problem on higher dimension. problems of 5 variables mathematica started fall in traps of local minimum when big number of search points allowed.

n=5;funlist[x_?listq]:=block[{i,symval,rule}, i=table[toexpression["x$"<>tostring[j]],{j,1,n}];symval=10 n+sum[(i[[k]]-2)^2-10cos[2pi(i[[k]]-2)],{k,1,n}];rule=mapthread[(#1-> #2)&,{i,x}];symval/.rule]val=table[randomreal[{-5,5}],{i,1,n}];vars=table[toexpression["x$"<>tostring[j]],{j,1,n}];cons=table[-5<=toexpression["x$"<>tostring[j]]<= 5,{j,1,n}]/.list-> and;nminimize[{funlist[vars],cons},vars,method->{"randomsearch","searchpoints"->4013}]//absolutetiming

output not wold have liked see. took 49 sec in core2duo machine , still local minimum.

{48.5157750,{1.98992,{x$1->2.,x$2->2.,x$3->2.,x$4->2.99496,x$5->1.00504}}}

then tried simulatedanealing 100000 iterations.

nminimize[{funlist[vars],cons},vars,method->"simulatedannealing",maxiterations->100000]//absolutetiming

output still not agreeable.

{111.0733530,{0.994959,{x$1->2.,x$2->2.99496,x$3->2.,x$4->2.,x$5->2.}}}

now mathematica has exact optimization algorithm called minimize. expected must fail on practicality fails fast problem size increases.

n=3;funlist[x_?listq]:=block[{i,symval,rule},i=table[toexpression["x$"<>tostring[j]],{j,1,n}];symval=10 n+sum[(i[[k]]-2)^2-10cos[2 pi(i[[k]]-2)],{k,1,n}];rule=mapthread[(#1-> #2)&,{i,x}];symval/.rule]val=table[randomreal[{-5,5}],{i,1,n}];vars=table[toexpression["x$"<>tostring[j]],{j,1,n}];cons=table[-5<=toexpression["x$"<>tostring[j]]<= 5,{j,1,n}]/.list-> and;minimize[{funlist[vars],cons},vars]//absolutetiming

output right.

{5.3593065,{0,{x$1->2,x$2->2,x$3->2}}}

but if 1 changes problem size 1 step farther n=4 see result. solution not appear long time in notebook.

now question simple here think there way numerically solve problem efficiently in mathematica higher dimensional cases? lets share our ideas , experience. 1 should remember benchmark nonlinear global optimization problem. numerical root-finding/minimization algorithms searches local minimum.

br

p

increasing initial points allows me global minimum:

n = 5; funlist[x_?listq] := total[10 + (x - 2)^2 - 10 cos[2 pi (x - 2)]] val = table[randomreal[{-5, 5}], {i, 1, n}]; vars = array[symbol["x$" <> tostring[#]] &, n]; cons = apply[and, thread[-5 <= vars <= 5]];

these calls. timing may not efficient though, randomized algorithms, 1 has have plenty initial samples, or sense function.

in[27]:= nminimize[{funlist[vars], cons}, vars, method -> {"differentialevolution", "searchpoints" -> 5^5}] // absolutetiming out[27]= {177.7857768, {0., {x$1 -> 2., x$2 -> 2., x$3 -> 2., x$4 -> 2., x$5 -> 2.}}} in[29]:= nminimize[{funlist[vars], cons}, vars, method -> {"randomsearch", "searchpoints" -> 7^5}] // absolutetiming out[29]= {609.3419281, {0., {x$1 -> 2., x$2 -> 2., x$3 -> 2., x$4 -> 2., x$5 -> 2.}}}

wolfram-mathematica numerical mathematical-optimization

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -