Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

last commit #2

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
e9359a8
Merge pull request #1 from attarmehran/main
attarmehran Mar 7, 2023
ae7a91b
Update README.md
attarmehran Mar 8, 2023
7ba0729
Update README.md
attarmehran Mar 8, 2023
8692745
Update README.md
attarmehran Mar 8, 2023
95d34d5
Update README.md
attarmehran Mar 8, 2023
cca0cc3
Update README.md
attarmehran Mar 8, 2023
03b01c5
Merge pull request #2 from attarmehran/main
attarmehran Mar 8, 2023
4665807
Merge pull request #3 from attarmehran/main
attarmehran Mar 8, 2023
30c84fb
Merge pull request #4 from attarmehran/main
attarmehran Mar 8, 2023
9d4c505
Merge pull request #5 from attarmehran/main
attarmehran Mar 8, 2023
dfbad4a
Merge pull request #6 from attarmehran/main
attarmehran Mar 9, 2023
a683298
Update README.md
attarmehran Mar 9, 2023
f3506d8
Update README.md
attarmehran Mar 9, 2023
2bc2601
Update README.md
WalterLucia Mar 10, 2023
b68a487
Merge branch 'main' into main
attarmehran Mar 10, 2023
498abff
Update README.md
attarmehran Mar 10, 2023
7fe82f8
Update README.md
attarmehran Mar 10, 2023
08ec473
Update README.md
attarmehran Mar 10, 2023
b8c195d
Create README.md
WalterLucia Mar 10, 2023
220fe58
Update README.md
WalterLucia Mar 10, 2023
ec0adaa
Update README.md
attarmehran Mar 10, 2023
516435c
Update README.md
WalterLucia Mar 11, 2023
6698d09
Update README.md
WalterLucia Mar 11, 2023
95f4afb
Update README.md
WalterLucia Mar 13, 2023
d461ee3
Update README.md
WalterLucia Mar 13, 2023
7c4662c
Update README.md
WalterLucia Mar 13, 2023
dfb4773
Update README.md
WalterLucia Mar 13, 2023
8a3ed07
Update README.md
WalterLucia Mar 13, 2023
cfbc7e4
Add files via upload
attarmehran Mar 29, 2023
5a7408c
Delete commandcalculation.m
attarmehran Mar 29, 2023
13dad73
Delete compute_ST_MPC.m
attarmehran Mar 29, 2023
ef7b420
Add files via upload
attarmehran Mar 29, 2023
532270f
Update README.md
attarmehran Mar 29, 2023
9067680
Update compute_ROSC_sets.m
attarmehran May 14, 2023
f3bbd4b
Update compute_ST_MPC.m
attarmehran May 14, 2023
82a1baf
Delete T.mat
attarmehran Aug 2, 2023
024acc1
Delete T_data.mat
attarmehran Aug 2, 2023
eebf896
Delete T_data_aug.mat
attarmehran Aug 2, 2023
f8a4ba3
Delete animated_test.m
attarmehran Aug 2, 2023
2ea5809
Delete computeRPI.m
attarmehran Aug 2, 2023
58ccae4
Delete compute_AB.m
attarmehran Aug 2, 2023
9e93203
Delete compute_ROSC_sets.m
attarmehran Aug 2, 2023
6b9d0a1
Delete compute_ST_MPC.m
attarmehran Aug 2, 2023
6768b2b
Delete compute_intersec.m
attarmehran Aug 2, 2023
9bf3bea
Delete compute_presets_approx.m
attarmehran Aug 2, 2023
c8cb364
Delete indx_finder.m
attarmehran Aug 2, 2023
01132fa
Delete model_based_stmpc.m
attarmehran Aug 2, 2023
2027462
Delete one_step_ctrl.m
attarmehran Aug 2, 2023
9343d24
Delete poly_approx.m
attarmehran Aug 2, 2023
09e2b04
Delete set_index.m
attarmehran Aug 2, 2023
a958c2a
Add files via upload
attarmehran Aug 2, 2023
c28f55b
Update README.md
attarmehran Aug 2, 2023
b81bc55
Update README.md
attarmehran Aug 2, 2023
d949fe9
Update README.md
attarmehran Aug 2, 2023
d8c07fd
Update README.md
attarmehran Aug 2, 2023
ccc5307
Update README.md
attarmehran Aug 2, 2023
91e98d4
Update README.md
attarmehran Aug 2, 2023
fd0582f
Update README.md
attarmehran Aug 2, 2023
705c312
Update README.md
attarmehran Aug 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions All_AB.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
% Author: Mehran Attar
% Written: 08-March-2023
% Last update:
% Last revision:---

%------------- BEGIN CODE --------------
clc
clear all
close all
%% system dynamics
A=[0.7969 -0.2247;
0.1798 0.9767];
B=[0.1271;0.0132];
C = [1,0];
D = 0;
rand('seed',1);
% define continuous time system
% sys_c = ss(A,B,C,D);
% % convert to discrete system
% samplingtime = 0.01;
% sys_d = c2d(sys_c,samplingtime);
dim_x = size(A, 2);
initpoints =1;
%Number of time steps
steps = 4;
totalsamples = initpoints*steps;
%% initial set and input
% X0 = zonotope(zeros(dim_x,1),diag(ones(dim_x,1)));
% X0 = zonotope(zeros(2,1),0.106*[0.999 -0.1;-1 -1]);
U = zonotope(0,3);
X0 = zonotope(zeros(2,1),10*eye(2));
%noise zontope W
W = zonotope(zeros(dim_x,1),0.005*eye(dim_x));

%Construct matrix zonotpe \mathcal{M}_w
index=1;
for i=1:size(W.generators,2)
vec = W.Z(:,i+1);
GW{index}= [vec,zeros(dim_x,totalsamples-1)];
for j=1:totalsamples-1
GW{j+index}= [GW{index+j-1}(:,2:end) GW{index+j-1}(:,1)];
end
index = j+index+1;
end
Wmatzono= matZonotope(zeros(dim_x,totalsamples),GW);

% randomly choose constant inputs for each step / sampling time
for i=1:totalsamples
u(i) = randPoint(U);
end

%simulate the system to get the data
x0 = X0.center;
x(:,1) = x0;
index=1;
for j=1:dim_x:initpoints*dim_x
x(j:j+dim_x-1,1) = randPoint(X0);
for i=1:steps
utraj(j,i) = u(index);
x(j:j+dim_x-1,i+1) = A*x(j:j+dim_x-1,i) + B*u(index) + randPoint(W);
index=index+1;
end
end

% concatenate the data trajectories
index_0 =1;
index_1 =1;
for j=1:dim_x:initpoints*dim_x
for i=2:steps+1
x_meas_vec_1(:,index_1) = x(j:j+dim_x-1,i);
index_1 = index_1 +1;
end
for i=1:steps
u_mean_vec_0(:,index_0) = utraj(j,i);
x_meas_vec_0(:,index_0) = x(j:j+dim_x-1,i);
index_0 = index_0 +1;
end
end

% X_+ is X_1T
% X_- is X_0T
U_full = u_mean_vec_0(:,1:totalsamples); %same as u
X_0T = x_meas_vec_0(:,1:totalsamples);
X_1T = x_meas_vec_1(:,1:totalsamples);

X1W_cen = X_1T - Wmatzono.center;
X1W = matZonotope(X1W_cen,Wmatzono.generator);
% set of A and B
AB = X1W * pinv([X_0T;U_full]);

%%

matrixCenter = [AB.center;zeros(1,3)];

for i=1:AB.gens
G{i}=[AB.generator{i};zeros(1,3)];
end

% instantiate matrix zonotope
M_zono = matZonotope(matrixCenter, G);

% obtain result of all vertices-------------------------
V_AB = vertices(M_zono);

save V_AB
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Data-Driven Set-Theoretic Model Predictive Control

This repository contains the codes for "Data-Driven Robust Backward Reachable Sets for Set-Theoretic Model Predictive Control"
by [Mehran Attar](https://scholar.google.com/citations?user=nnLTy-oAAAAJ&hl=en) and [Walter Lucia](https://users.encs.concordia.ca/~wlucia/index.html), jointly submitted to IEEE Control Systems Letters (L-CSS) and IEEE Conference on Decision and Control (CDC)
[arXiv pre-print link](https://arxiv.org/abs/2303.04749)
This repository contains the codes for "Data-Driven Robust Backward Reachable Sets for Set-Theoretic Model Predictive Control" by [Mehran Attar](https://scholar.google.com/citations?user=nnLTy-oAAAAJ&hl=en) and [Walter Lucia](https://users.encs.concordia.ca/~wlucia/index.html) jointly has been accepted to publish in IEEE Control Systems Letters (L-CSS) and IEEE Conference on Decision and Control (CDC) --> [IEEE link](https://ieeexplore.ieee.org/abstract/document/10153604)


### Problem Statement
Given the input-state trajectories $\mathcal{D}=(x,u)$ collected for the linear model $x_{k+1} = Ax_k + Bu_k + w_k$ with $x_k \in \mathcal{X} \subset \mathbb{R}^n$ and $u_k \in \mathcal{U}\subset \mathbb{R}^m$ and $w_k \in \mathcal{W} \subset \mathbb{R}^n$, with unknown system matrices $(A,B):$

1. Design a data-driven algorithm computing an inner approximation of the ROSC sets $\mathcal{T}^{j} = {x \in \mathcal{X}: \exists u \in \mathcal{U}: x^+ \in \mathcal{T}^{j-1}, \forall w \in \mathcal{W} \}$
1. Design a data-driven algorithm computing an inner approximation of the ROSC sets $\mathcal{T}^{j} = \lbrace x \in \mathcal{X}: \exists u \in \mathcal{U}: x^+ \in \mathcal{T}^{j-1}, \forall w \in \mathcal{W} \rbrace$

2. Design a Data-Driven Set-Theoretic MPC (D-ST-MPC) controller for the linear system enjoying the same properties of ST-MPC.
2. Design a Data-Driven Set-Theoretic MPC (D-ST-MPC) controller for the linear system enjoying the same properties of [ST-MPC](https://www.sciencedirect.com/science/article/pii/S0005109808003014?casa_token=n_C40ZvVjWEAAAAA:y8PyF290r0VL7DdULvbDI1oRdR9I1yO__-ag8JSzWvxPO3AFZTa10AtTl6NMu552nhrUk4ZV).

## Running
1- Download [CORA release 2022](https://tumcps.github.io/CORA/) and [MPT3 release 2022](https://www.mpt3.org/)

2- Add CORA and MPT folder and subfolders to the Matlab (in this work, [MATLAB R2021-a has been used](https://www.mathworks.com/products/new_products/release2021a.html)) path.
2- Add CORA and MPT folder and subfolders to the Matlab (in this work, [MATLAB R2021-a](https://www.mathworks.com/products/new_products/release2021a.html) has been used) path.

3- Add the repo folder and subfolders to the Matlab path.

Expand All @@ -25,8 +24,8 @@ Given the input-state trajectories $\mathcal{D}=(x,u)$ collected for the linear

#### Function Descriptions
- "compute_AB.m": computes all possible system matrices that are consistent with the data
- "computeRPI.m": computes a model-based RCI set based on the proposed method in **"Invariant approximations of the minimal robust positively invariant set" by Rokovic**
- "commandcalculation.m": computes the model-based ST-MPC control commands
- "computeRPI.m": computes a model-based RCI set based on the proposed method in **"Invariant approximations of the minimal robust positively invariant set", by Rakovic et al.
- "model_based_stmpc.m": computes the model-based ST-MPC control commands
- "compute_intersec.m": computes the intersection of polyhedrons
- "compute_presets_approx.m": computes the data-driven ROSC sets in the extended space of $(x,u)$.
- "indx_finder.m": computes the set memebership index of an state for the model-based ROSC sets.
Expand All @@ -39,6 +38,6 @@ Given the input-state trajectories $\mathcal{D}=(x,u)$ collected for the linear
Run "animated_test.m"

## Videos
Check [PreCyse Research Group Youtube channel](https://www.youtube.com/@precysegroup9944)
[Youtube link](https://www.youtube.com/watch?v=BQ3rUl_VqJs)


Loading