-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompute_presets_approx.m
60 lines (49 loc) · 1.46 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
52
53
54
55
56
57
58
59
60
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);
%
const1 = w<=[W.b(1);W.b(1)];
const2 = w>=[-W.b(1);-W.b(1)];
const = const1 + const2;
opt = sdpsettings('solver','sedumi','verbose',0);
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
% % for i=1:size(H,1)
% obj = h - H*w;
% diagnostics=optimize(const,obj,opt);
% w_value = value(w)
% h_tilde = h - H*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(size(H_x,1),size(H_u,2));
% H*A_hat{j} H*B_hat{j};
% zeros(size(H_u,1),size(H_x,2)) H_u],[h_x;h_tilde';h_u]);
% end
% for j=1:size(A_hat,2)
% presets{j} = Polyhedron([H*A_hat{j} H*B_hat{j};
% zeros(size(H_u,1),size(H_x,2)) H_u],[h_tilde';h_u]);
% end
presets = Polyhedron([H_x zeros(size(H_x,1),size(H_u,2));
target.A*A_hat target.A*B_hat;
zeros(size(H_u,1),size(H_x,2)) H_u],[h_x;h_tilde';h_u]);
end
%------------- END CODE --------------