source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/dev/tests-mbg/mpt/mpt_lti_2.m @ 37

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

Added original make3d

File size: 1.5 KB
Line 
1function dplti_1
2
3% Data
4A = [2 -1;1 0];nx = 2;
5B = [1;0];nu = 1;
6C = [0.5 0.5];
7
8% Prediction horizon
9N = 5;
10
11% States x(k), ..., x(k+N)
12x = sdpvar(repmat(nx,1,N),repmat(1,1,N));
13
14% Inputs u(k), ..., u(k+N) (last one not used)
15u = sdpvar(repmat(nu,1,N),repmat(1,1,N));
16
17% MPT implementation
18sysStruct.A= A;
19sysStruct.B= B;
20sysStruct.C= C;
21sysStruct.D= [0];
22
23%set constraints on output
24sysStruct.ymin    =   -1;
25sysStruct.ymax    =    1;
26
27%set constraints on input
28sysStruct.umin    =   -1;
29sysStruct.umax    =   1;
30
31sysStruct.xmin    =   [-5;-5];
32sysStruct.xmax    =   [5;5];
33
34probStruct.norm=1;
35probStruct.Q=eye(2);
36probStruct.R=1;
37probStruct.N=N-1;
38probStruct.P_N=zeros(2);
39probStruct.subopt_lev=0;
40probStruct.y0bounds=1;
41probStruct.Tconstraint=0;
42ctrl=mpt_control(sysStruct,probStruct)
43
44% States x(k), ..., x(k+N)
45x = sdpvar(repmat(nx,1,N),repmat(1,1,N));
46
47% Inputs u(k), ..., u(k+N) (last one not used)
48u = sdpvar(repmat(nu,1,N),repmat(1,1,N));
49
50% Value functions
51J = cell(1,N);
52
53% Initialize value function at stage N
54J{N} = 0;
55F = set([]);
56obj = 0;
57for k = N-1:-1:1
58    % Feasible region
59    F = F + set(-1 < u{k}     < 1);
60    F = F + set(-1 < C*x{k}   < 1);
61    F = F + set(-5 < x{k}     < 5);
62    F = F + set(-1 < C*x{k+1} < 1);
63    F = F + set(-5 < x{k+1}   < 5);
64
65    % LTI Dynamics
66    F = F + set(x{k+1} == A*x{k}+B*u{k});
67
68    % Compute value function for one step backwards
69    obj = obj + norm([x{k};u{k}],1);
70end
71mpsol{1}  = solvemp(F,obj,[],x{k},u{k});
72 
73mbg_asserttolequal(mpt_isPWAbigger(mpsol{1}{1},ctrl),0);
74
75
76
77
78
Note: See TracBrowser for help on using the repository browser.