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

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

Added original make3d

File size: 963 bytes
Line 
1function mpt_lti_3
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 = 3;
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% Value functions
18J = cell(1,N);
19
20% Initialize value function at stage N
21J{N} = 0;
22U{N} = 0;
23k=N-1;
24
25for k = N-1:-1:1
26   
27    % Feasible region       
28    bounds(x{k},-5,5);
29    bounds(u{k},-1,1);
30    bounds(x{k+1},-5,5);
31   
32    F =     set(-1 < u{k}     < 1);
33    F = F + set(-1 < C*x{k}   < 1);
34    F = F + set(-5 < x{k}     < 5);
35    F = F + set(-1 < C*x{k+1} < 1);
36    F = F + set(-5 < x{k+1}   < 5); 
37 
38    % LTI Dynamics
39    F = F + set(x{k+1} == A*x{k}+B*u{k});
40   
41    obj =x{k}'*x{k} + u{k}'*u{k};
42   
43    % Compute value function for one step backwards
44    [mpsol{k},sol{k},Uz{k},J{k}] = solvemp(F,obj + J{k+1},[],x{k},u{k});   
45end
46
47mbg_asserttrue(sol{1}.problem == 0);
Note: See TracBrowser for help on using the repository browser.