Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tutorial example on symbolic control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Girard Antoine
Tutorial example on symbolic control
Commits
00d28c21
Commit
00d28c21
authored
1 year ago
by
Girard Antoine
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
1b364409
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
symb_abs.m
+100
-0
100 additions, 0 deletions
symb_abs.m
with
100 additions
and
0 deletions
symb_abs.m
0 → 100644
+
100
−
0
View file @
00d28c21
%% Tutorial example on symbolic control
%% Author: Antoine GIRARD, Université Paris-Saclay, CNRS, CentraleSupélec, Laboratoire des signaux et systèmes, 91190, Gif-sur-Yvette, France.
%% Date: 2024
% Computation of a symbolic model for the system defined in dynamics.m
clear
dynamics
;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Abstraction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tic
% This part of the script is dedicated to computing the symbolic model
% Space discretization
d_x
=
(
bound_x
(:,
2
)
-
bound_x
(:,
1
))
.
/
n_x
;
p_x
=
[
1
;
cumprod
(
n_x
)];
n_xi
=
prod
(
n_x
);
grid_xi
=
reshape
(
1
:
n_xi
,
n_x
'
);
% abstraction function
q
=@
(
x
)
coord2state
(
floor
((
x
-
bound_x
(:,
1
))
.
/
d_x
)
+
1
,
p_x
);
% Input discretization
d_u
=
(
bound_u
(:,
2
)
-
bound_u
(:,
1
))
.
/(
n_u
-
1
);
p_u
=
[
1
;
cumprod
(
n_u
)];
n_sigma
=
prod
(
n_u
);
% concretisation function
val_u
=
zeros
(
length
(
bound_u
),
n_sigma
);
for
i
=
1
:
n_sigma
val_u
(:,
i
)
=
bound_u
(:,
1
)
+
(
state2coord
(
i
,
p_u
)
-
[
1
;
1
])
.*
d_u
;
end
p
=@
(
sigma
)
val_u
(:,
sigma
);
% Disturbance
d_w
=
(
bound_w
(:,
2
)
-
bound_w
(:,
1
));
w_c
=
0.5
*
(
bound_w
(:,
1
)
+
bound_w
(:,
2
));
disp
(
'Computation of the symbolic model'
)
h
=
waitbar
(
0
,
'Abstraction in progress...'
);
% Computation of the transition relation
% g stores the lower and upper successor states
% for each state under the action of each input
g
=
zeros
(
n_xi
,
n_sigma
,
2
);
robust_margins
=
d_x
;
for
xi
=
1
:
n_xi
waitbar
(
xi
/
n_xi
,
h
)
c_xi
=
state2coord
(
xi
,
p_x
);
x_c
=
bound_x
(:,
1
)
+
(
c_xi
-
0.5
)
.*
d_x
;
% Coordinates of the center of the cell
% Compute the transition relation
for
sigma
=
1
:
n_sigma
% Over approximation of the reachable set
x_c_succ
=
f
(
x_c
,
val_u
(:,
sigma
),
w_c
);
% compute the image of the center point
d_x_succ
=
0.5
*
Jf_x
(
val_u
(:,
sigma
))
*
d_x
+
0.5
*
Jf_w
(
val_u
(:,
sigma
))
*
d_w
;
% bound the deviation
reach
=
[
x_c_succ
-
d_x_succ
,
x_c_succ
+
d_x_succ
];
% reachable set
%Special treatment of the third coordinate (angle)
%not needed in general
if
reach
(
3
,
1
)
<-
pi
&&
reach
(
3
,
2
)
>=-
pi
reach
(
3
,
1
)
=
reach
(
3
,
1
)
+
2
*
pi
;
elseif
reach
(
3
,
1
)
<-
pi
&&
reach
(
3
,
2
)
<-
pi
reach
(
3
,
1
)
=
reach
(
3
,
1
)
+
2
*
pi
;
reach
(
3
,
2
)
=
reach
(
3
,
2
)
+
2
*
pi
;
elseif
reach
(
3
,
2
)
>
pi
&&
reach
(
3
,
1
)
<=
pi
reach
(
3
,
2
)
=
reach
(
3
,
2
)
-
2
*
pi
;
elseif
reach
(
3
,
2
)
>
pi
&&
reach
(
3
,
1
)
>
pi
reach
(
3
,
2
)
=
reach
(
3
,
2
)
-
2
*
pi
;
reach
(
3
,
1
)
=
reach
(
3
,
1
)
-
2
*
pi
;
end
% Store the transition relation
if
all
(
reach
(:,
1
)
>=
bound_x
(:,
1
))
&&
all
(
reach
(:,
2
)
<=
bound_x
(:,
2
))
min_succ
=
coord2state
(
floor
((
reach
(:,
1
)
-
bound_x
(:,
1
))
.
/
d_x
)
+
1
,
p_x
);
max_succ
=
coord2state
(
ceil
((
reach
(:,
2
)
-
bound_x
(:,
1
))
.
/
d_x
),
p_x
);
g
(
xi
,
sigma
,:)
=
[
min_succ
,
max_succ
];
robust_margins
=
min
(
robust_margins
,
...
(
reach
(:,
1
)
-
bound_x
(:,
1
))
-
d_x
.*
floor
((
reach
(:,
1
)
-
bound_x
(:,
1
))
.
/
d_x
));
robust_margins
=
min
(
robust_margins
,
...
(
-
reach
(:,
2
)
+
bound_x
(:,
1
))
+
d_x
.*
ceil
((
reach
(:,
2
)
-
bound_x
(:,
1
))
.
/
d_x
));
end
% g is 0 if and only if reach set outside the state constraints
end
end
close
(
h
)
toc
%%
save
(
'symb_abs.mat'
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment