-
Notifications
You must be signed in to change notification settings - Fork 1
/
compute_presets_approx.m
51 lines (41 loc) · 1.11 KB
/
compute_presets_approx.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function presets = compute_presets_approx(target,W,U,X,A_hat,B_hat)
% Author: Mehran Attar
% Written: 08-March-2023
% Last update:
% Last revision:---
% This function computes augmentd ROSC sets of $(x-u)$
%------------- BEGIN CODE --------------
H_x = X.A;
h_x = X.b;
H_u = U.A;
h_u = U.b;
H = target.A;
h = target.b;
%% compute h_tilde
w = sdpvar(W.Dim,1);
%
global h_tilde
const1 = w<=[W.b(1);W.b(1)];
const2 = w>=[-W.b(1);-W.b(1)];
const = const1 + const2;
opt = sdpsettings('verbose',0,'debug',1);
for i=1:size(H,1)
obj = h(i,:) - H(i,:)*w;
diagnostics=optimize(const,obj,opt);
w_value = value(w);
h_tilde(i) = h(i,:) - H(i,:)*value(w);
end
%% compute augmented ROSC sets
global A_hat
global B_hat
for j=1:size(A_hat,2)
presets{j} = Polyhedron([H_x zeros(4,2);
target.A*A_hat{j} target.A*B_hat{j};
zeros(4,2) H_u],[h_x;h_tilde';h_u]);
end
% %
% presets = Polyhedron([H_x zeros(4,2);
% target.A*A_hat target.A*B_hat;
% zeros(4,2) H_u],[h_x;h_tilde';h_u]);
end
%------------- END CODE --------------