TomSym Circle Enclosing Points - SNOPT Example: Difference between revisions
From TomWiki
Jump to navigationJump to search
(Created page with "{{Part Of Manual|title=the TomSym Manual|link=TomSym Manual}} TomSym implementation of GAMS Example (CIRCLE,SEQ=201) This is an example from the GAMS/SNOPT manual. F...") |
No edit summary |
||
Line 60: | Line 60: | ||
<pre> | <pre> | ||
Problem type appears to be: lpcon | Problem type appears to be: lpcon | ||
Time for symbolic processing: 0. | Time for symbolic processing: 0.065086 seconds | ||
Starting numeric solver | Starting numeric solver | ||
===== * * * =================================================================== * * * | ===== * * * =================================================================== * * * | ||
Line 75: | Line 75: | ||
FuncEv 1 ConstrEv 7 ConJacEv 7 Iter 4 MinorIter 7 | FuncEv 1 ConstrEv 7 ConJacEv 7 Iter 4 MinorIter 7 | ||
CPU time: 0.015600 sec. Elapsed time: 0. | CPU time: 0.015600 sec. Elapsed time: 0.008000 sec. | ||
</pre> | </pre> | ||
[[File:tomsym_circle_01.png]] | [[File:tomsym_circle_01.png]] |
Latest revision as of 09:33, 8 November 2011
This page is part of the TomSym Manual. See TomSym Manual. |
TomSym implementation of GAMS Example (CIRCLE,SEQ=201)
This is an example from the GAMS/SNOPT manual. Find the smallest circle that contains a number of given points.
Gill, P E, Murray, W, and Saunders, M A, GAMS/SNOPT: An SQP Algorithm for Large-Scale Constrained Optimization, 1988.
% x coordinates (random data)
x = [0.950129285147175;0.231138513574288;0.606842583541787;...
0.485982468709300;0.891298966148902;0.762096833027395;...
0.456467665168341;0.018503643248224;0.821407164295253;...
0.444703364353194];
% y coordinates (random data)
y = [0.615432348100095;0.791937037427035;0.921812970744803;...
0.738207245810665;0.176266144494618;0.405706213062095;...
0.935469699107605;0.916904439913408;0.410270206990945;...
0.893649530913534];
% Variables
% a: x coordinate of center of circle
% b: y coordinate of center of circle
% r: radius
toms a b r
% Points must be inside circle and radius must be positive
eq1 = {r >= 0
(x-a).^2 + (y-b).^2 <= r.^2};
obj = r;
% Parameters xmin,ymin,xmax,ymax;
xmin = min(x);
xmax = max(x);
ymin = min(y);
ymax = max(y);
% Set starting point
x0 = {a == (xmin+xmax)/2
b == (ymin+ymax)/2
r == sqrt( (a-xmin).^2 + (b-ymin).^2 )};
options = struct;
options.name = 'Inside circle';
solution = ezsolve(obj,eq1,x0,options);
a = solution.a;
b = solution.b;
r = solution.r;
figure(1);
th = 0:pi/20:2*pi;
x1 = r*cos(th)+a;
y1 = r*sin(th)+b;
plot(x,y,'*',x1,y1,'-');
Problem type appears to be: lpcon Time for symbolic processing: 0.065086 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Inside circle f_k 0.572345341380648520 sum(|constr|) 0.000000000558818603 f(x_k) + sum(|constr|) 0.572345341939467070 f(x_0) 0.600898571720017370 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 1 ConstrEv 7 ConJacEv 7 Iter 4 MinorIter 7 CPU time: 0.015600 sec. Elapsed time: 0.008000 sec.