source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/dev/tests-mbg/geometric/test_gp_gpposybeam.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 
1function test_gp_gpposybeam
2
3N = 8;
4w = sdpvar(N,1);
5h = sdpvar(N,1);
6
7% constants
8wmin = .1; wmax = 100;
9hmin = .1; hmax = 6;
10Smin = 1/5; Smax = 5;
11sigma_max = 1;
12ymax = 10;
13E = 1; F = 1;
14
15% objective is the total volume of the beam
16% obj = sum of (widths*heights*lengths) over each section
17% (recall that the length of each segment is set to be 1)
18obj = w'*h;
19
20% recursive formulation
21v = sdpvar(N+1,1); y = sdpvar(N+1,1);
22v(N+1,1) = 0; y(N+1,1) = 0;
23for i = N:-1:1
24  disp(['Processing recursion number: ' num2str(i)])
25  v(i) = 12*(i-1/2)*F/(E*w(i)*h(i)^3) + v(i+1);
26  y(i) = 6*(i-1/3)*F/(E*w(i)*h(i)^3)  + v(i+1) + y(i+1);
27end
28
29% constraint set
30constr = [ ...
31  wmin*ones(N,1) <= w; w <= wmax*ones(N,1);
32  hmin*ones(N,1) <= h; h <= hmax*ones(N,1);
33  Smin*ones(N,1) <= h./w; h./w <= Smax*ones(N,1);
34  6*F*[1:N]'./(w.*(h.^2)) <= sigma_max*ones(N,1);
35  y(1) <= ymax;
36];
37
38% solve GP and compute the optimal volume
39sol  = solvesdp(constr,obj)
40
41mbg_asserttolequal(sol.problem,0);
42
43mbg_asserttolequal(double(obj),42.39654132455499,1e-5);
Note: See TracBrowser for help on using the repository browser.