16.01.2015 Views

GAMS — The Solver Manuals - Available Software

GAMS — The Solver Manuals - Available Software

GAMS — The Solver Manuals - Available Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

528 SNOPT<br />

* fill with random data<br />

x(i) = uniform(1,10);<br />

y(i) = uniform(1,10);<br />

variables<br />

a<br />

b<br />

r<br />

equations<br />

e(i)<br />

x coordinate of center of circle<br />

y coordinate of center of circle<br />

radius;<br />

points must be inside circle;<br />

e(i).. sqr(x(i)-a) + sqr(y(i)-b) =l= sqr(r);<br />

r.lo = 0;<br />

model m /all/;<br />

option nlp=snopt;<br />

solve m using nlp minimizing r;<br />

Without help, SNOPT will not be able to find an optimal solution. <strong>The</strong> problem will be declared infeasible. In<br />

this case, providing a good starting point is very easy. If we define<br />

then good estimates are<br />

Thus we include in our model:<br />

x min = min<br />

i<br />

x i ,<br />

y min = min<br />

i<br />

y i ,<br />

x max = max<br />

i<br />

y max = max<br />

i<br />

a = (x min + x max )/2,<br />

b = (y min + y max )/2,<br />

x i ,<br />

y i ,<br />

r = √ (a − x min ) 2 + (b − y min ) 2 .<br />

parameters xmin,ymin,xmax,ymax;<br />

xmin = smin(i, x(i));<br />

ymin = smin(i, x(i));<br />

xmax = smax(i, x(i));<br />

ymax = smax(i, y(i));<br />

* set starting point<br />

a.l = (xmin+xmax)/2;<br />

b.l = (ymin+ymax)/2;<br />

r.l = sqrt( sqr(a.l-xmin) + sqr(b.l-ymin) );<br />

and now the model solves very easily.<br />

Level values can also be set implicitly as a result of assigning bounds. When a variable is bounded away from<br />

zero, for instance by the statement Y.LO = 1;, the SOLVE statement will override the default level of zero of such<br />

a variable in order to make it feasible.<br />

Note: another way to formulate the model would be to minimize r 2 instead of r. This allows SNOPT to solve<br />

the problem even with the default starting point.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!