-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
199 changed files
with
9,045 additions
and
223,844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function Z = abs(Z) | ||
% abs - Returns a zonotope with absolute values of the center and the | ||
% generators | ||
% | ||
% Syntax: | ||
% Z = abs(Z) | ||
% | ||
% Inputs: | ||
% Z - zonotope object | ||
% | ||
% Outputs: | ||
% Z - zonotope, where Z=(|c|,|g_1|,...,|g_n|) | ||
% | ||
% Example: | ||
% Z=zonotope([1 -1 0; 0 0 -1]); | ||
% Z=abs(Z)-->Z=[1 1 0; 0 0 1] | ||
% | ||
% Other m-files required: none | ||
% Subfunctions: none | ||
% MAT-files required: none | ||
% | ||
% See also: none | ||
|
||
% Author: Matthias Althoff | ||
% Written: 30-September-2006 | ||
% Last update: 22-March-2007 | ||
% Last revision: --- | ||
|
||
%------------- BEGIN CODE -------------- | ||
|
||
Z.Z = abs(Z.Z); | ||
|
||
%------------- END OF CODE -------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
function Z = and(Z1,Z2,varargin) | ||
% and - overloads & operator, computes the AND of two logical zonotopes | ||
% | ||
% Syntax: | ||
% Z = and(Z1,Z2) | ||
% | ||
% Inputs: | ||
% Z1 - zonotope | ||
% Z2 - zonotope, | ||
% | ||
% Outputs: | ||
% Z - zonotope object enclosing the and zonotope | ||
% | ||
% Example: | ||
% | ||
% Other m-files required: none | ||
% Subfunctions: none | ||
% MAT-files required: none | ||
% | ||
% See also: none | ||
|
||
% Author: Amr Alanwar | ||
% Written: 8-Aug-2022 | ||
% Last update: | ||
% | ||
% | ||
% Last revision: --- | ||
|
||
%------------- BEGIN CODE -------------- | ||
newcen = Z1.c & Z2.c; | ||
|
||
if(~isempty(Z1.G) & ~isempty(Z2.G)) | ||
%c2 * G1 | ||
index =1; | ||
for i=1:length(Z1.G) | ||
newGen{index} = Z2.c & Z1.G{i}; | ||
index=index+1; | ||
end | ||
|
||
for i=1:length(Z2.G) | ||
newGen{index} = Z1.c & Z2.G{i}; | ||
index=index+1; | ||
end | ||
|
||
%G1 * G1 | ||
for i=1:length(Z1.G) | ||
[rows,cols]=size(Z1.G{i}); | ||
for k=1:length(Z2.G) | ||
Gcon=[]; | ||
for j=1:cols | ||
gZ1 = Z1.G{i}(:,j); | ||
Gcon = [Gcon (gZ1 & Z2.G{k})]; | ||
end | ||
newGen{index} = Gcon; | ||
index=index+1; | ||
end | ||
end | ||
|
||
Z = logicalZonotope(newcen,newGen); | ||
elseif (~isempty(Z1.G)) | ||
%c2 * G1 | ||
|
||
index =1; | ||
for i=1:length(Z1.G) | ||
newGen{index} = Z2.c & Z1.G{i}; | ||
index=index+1; | ||
end | ||
|
||
|
||
newGen{index} = Z1.c ; | ||
|
||
|
||
Z = logicalZonotope(newcen,newGen); | ||
elseif (~isempty(Z2.G)) | ||
%c2 * G1 | ||
newGen = Z2.G; | ||
|
||
index =length(newGen)+1; | ||
for i=1:length(Z2.G) | ||
newGen{index} = Z1.c & Z2.G{i}; | ||
index=index+1; | ||
end | ||
|
||
|
||
newGen{index} = Z2.c ; | ||
|
||
|
||
Z = logicalZonotope(newcen,newGen); | ||
elseif(isempty(Z1.G) & isempty(Z2.G)) | ||
Z = logicalZonotope(newcen,{Z1.c,Z2.c}); | ||
end | ||
|
||
Z = unique(Z); | ||
end | ||
|
||
%------------- END OF CODE -------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
function Z = and(Z1,Z2,varargin) | ||
% and - overloads & operator, computes the AND of two logical zonotopes | ||
% | ||
% Syntax: | ||
% Z = and(Z1,Z2) | ||
% | ||
% Inputs: | ||
% Z1 - zonotope | ||
% Z2 - zonotope, | ||
% | ||
% Outputs: | ||
% Z - zonotope object enclosing the and zonotope | ||
% | ||
% Example: | ||
% | ||
% Other m-files required: none | ||
% Subfunctions: none | ||
% MAT-files required: none | ||
% | ||
% See also: none | ||
|
||
% Author: Amr Alanwar | ||
% Written: 8-Aug-2022 | ||
% Last update: | ||
% | ||
% | ||
% Last revision: --- | ||
|
||
%------------- BEGIN CODE -------------- | ||
newcen = Z1.c & Z2.c; | ||
|
||
if(~isempty(Z1.G) & ~isempty(Z2.G)) | ||
%c2 * G1 | ||
index =1; | ||
for i=1:length(Z1.G) | ||
newGen{index} = Z2.c & Z1.G{i}; | ||
index=index+1; | ||
end | ||
|
||
for i=1:length(Z2.G) | ||
newGen{index} = Z1.c & Z2.G{i}; | ||
index=index+1; | ||
end | ||
|
||
%G1 * G1 | ||
for i=1:length(Z1.G) | ||
[rows,cols]=size(Z1.G{i}); | ||
for k=1:length(Z2.G) | ||
Gcon=[]; | ||
for j=1:cols | ||
gZ1 = Z1.G{i}(:,j); | ||
Gcon = [Gcon (gZ1 & Z2.G{k})]; | ||
end | ||
newGen{index} = Gcon; | ||
index=index+1; | ||
end | ||
end | ||
|
||
Z = logicalZonotope(newcen,newGen); | ||
elseif (~isempty(Z1.G)) | ||
%c2 * G1 | ||
|
||
index =1; | ||
for i=1:length(Z1.G) | ||
newGen{index} = Z2.c & Z1.G{i}; | ||
index=index+1; | ||
end | ||
|
||
|
||
Z = logicalZonotope(newcen,newGen); | ||
elseif (~isempty(Z2.G)) | ||
%c2 * G1 | ||
newGen = Z2.G; | ||
|
||
index =length(newGen)+1; | ||
for i=1:length(Z2.G) | ||
newGen{index} = Z1.c & Z2.G{i}; | ||
index=index+1; | ||
end | ||
|
||
|
||
newGen{index} = Z2.c ; | ||
|
||
|
||
Z = logicalZonotope(newcen,newGen); | ||
elseif(isempty(Z1.G) & isempty(Z2.G)) | ||
Z = logicalZonotope(newcen,{}); | ||
end | ||
|
||
Z = unique(Z); | ||
end | ||
|
||
%------------- END OF CODE -------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
function Z = cartProd(Z1,Z2) | ||
% cartProd - Returns the cartesian product of two zonotopes | ||
% | ||
% Syntax: | ||
% Z = cartProd(Z1,Z2) | ||
% | ||
% Inputs: | ||
% Z1 - zonotope object | ||
% Z2 - zonotope object | ||
% | ||
% Outputs: | ||
% Z - zonotope object | ||
% | ||
% Example: | ||
% zono1 = zonotope.generateRandom(2); | ||
% zono2 = zonotope.generateRandom(3); | ||
% | ||
% zono = cartProd(zono1,zono2); | ||
% | ||
% Other m-files required: none | ||
% Subfunctions: none | ||
% MAT-files required: none | ||
% | ||
% See also: none | ||
|
||
% Author: Matthias Althoff | ||
% Written: 18-May-2011 | ||
% Last update: 27-Aug-2019 | ||
% 05-May-2020 (MW, standardized error message) | ||
% Last revision:--- | ||
|
||
%------------- BEGIN CODE -------------- | ||
|
||
% first or second set is zonotope | ||
if isa(Z1,'zonotope') | ||
|
||
% different cases for different set representations | ||
if isa(Z2,'zonotope') | ||
|
||
c = [center(Z1);center(Z2)]; | ||
G = blkdiag(generators(Z1),generators(Z2)); | ||
|
||
Z = zonotope([c,G]); | ||
|
||
elseif isnumeric(Z2) | ||
|
||
c = [center(Z1);Z2]; | ||
G = [generators(Z1);zeros(size(Z2,1),size(Z1.Z,2)-1)]; | ||
|
||
Z = zonotope([c,G]); | ||
|
||
elseif isa(Z2,'interval') | ||
Z = cartProd(Z1,zonotope(Z2)); | ||
elseif isa(Z2,'conZonotope') | ||
Z = cartProd(conZonotope(Z1),Z2); | ||
elseif isa(Z2,'zonoBundle') | ||
Z = cartProd(zonoBundle(Z1),Z2); | ||
elseif isa(Z2,'mptPolytope') | ||
Z = cartProd(mptPolytope(Z1),Z2); | ||
elseif isa(Z2,'polyZonotope') | ||
Z = cartProd(polyZonotope(Z1),Z2); | ||
else | ||
% throw error for given arguments | ||
error(noops(Z1,Z2)); | ||
end | ||
|
||
else | ||
|
||
% different cases for different set representations | ||
if isnumeric(Z1) | ||
|
||
c = [Z1;center(Z2)]; | ||
G = [zeros(size(Z1,1),size(Z2.Z,2)-1);generators(Z2)]; | ||
Z = zonotope([c,G]); | ||
|
||
else | ||
% throw error for given arguments | ||
error(noops(Z1,Z2)); | ||
end | ||
|
||
end | ||
|
||
|
||
end | ||
|
||
%------------- END OF CODE -------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function c = center(Z) | ||
% center - Returns the center of a zonotope | ||
% | ||
% Syntax: | ||
% c = center(Z) | ||
% | ||
% Inputs: | ||
% Z - zonotope object | ||
% | ||
% Outputs: | ||
% c - center of the zonotope Z | ||
% | ||
% Example: | ||
% Z = zonotope([1;0],[1 0; 0 1]); | ||
% c = center(Z) | ||
% | ||
% Other m-files required: none | ||
% Subfunctions: none | ||
% MAT-files required: none | ||
% | ||
% See also: none | ||
|
||
% Author: Matthias Althoff | ||
% Written: 30-September-2006 | ||
% Last update: 22-March-2007 | ||
% Last revision:--- | ||
|
||
%------------- BEGIN CODE -------------- | ||
|
||
c = Z.c; | ||
|
||
%------------- END OF CODE -------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function res = conZonotope(obj) | ||
% conZonotope - convert a zonotope object into a constrained zonotope | ||
% object | ||
% | ||
% Syntax: | ||
% res = conZonotope(obj) | ||
% | ||
% Inputs: | ||
% obj - zonotope object | ||
% | ||
% Outputs: | ||
% res - c-zonotope object | ||
% | ||
% Example: | ||
% Z = zonotope([1;0],[1 0; 0 1]); | ||
% cZ = conZonotope(Z); | ||
% | ||
% Other m-files required: none | ||
% Subfunctions: none | ||
% MAT-files required: none | ||
% | ||
% See also: none | ||
|
||
% Author: Niklas Kochdumper | ||
% Written: 23-May-2018 | ||
% Last update: --- | ||
% Last revision:--- | ||
|
||
%------------- BEGIN CODE -------------- | ||
|
||
res = conZonotope(obj.Z); | ||
|
||
%------------- END OF CODE -------------- |
Oops, something went wrong.