source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/demos/socpex.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.0 KB
Line 
1clc
2echo on
3%*********************************************************
4%
5% %Second order cone programming
6%
7%*********************************************************
8%
9% The problem is to find the point in the intersection of
10% two circles which is closest to the origin
11pause % Strike any key to continue.
12
13% The two circles are centered at a and b with radius 1,
14% and the point we are looking for will be denoted x
15a = [0;1];
16b = [1;1];
17x = sdpvar(2,1);
18pause % Strike any key to continue.
19
20% The point lies in both circles
21F = set('||x-a||<1')+set('||x-b||<1');
22pause
23
24% An alternative way to define the SOCPs is
25F = set(cone(x-a,1))+set(cone(x-b,1));
26pause
27
28
29% The distance to the origin is limited
30% by a constant t
31t = sdpvar(1,1);
32F = F+set('||x||<t');
33pause % Strike any key to continue.
34
35
36% And we wish to minimize the distance
37sol = solvesdp(F,t);
38pause % Strike any key to continue.
39
40% Optimal point
41double(x)
42
43% Distance from origin
44double(t)
45
46% Which of-course equals ||x||
47norm(double(x))
48
49pause % Strike any key to continue.
50echo off
Note: See TracBrowser for help on using the repository browser.