-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathevaluate.m
109 lines (97 loc) · 2.06 KB
/
evaluate.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
function points = evaluate(Z1)
% and - overloads & operator, computes the intersection of two zonotopes
%
% Syntax:
% Z = not(Z1,Z2)
%
% Inputs:
% Z1 - zonotope
% Z2 - zonotope,
%
% Outputs:
% Z - zonotope object enclosing the and zonotope
%
% Example:
% zono1 = zonotope([4 2 2;1 2 0]);
% zono2 = zonotope([3 1 -1 1;3 1 2 0]);
%
% res = zono1 & zono2
%
% figure
% hold on
% plot(zono1,[1,2],'r');
% plot(zono2,[1,2],'b');
% plot(res,[1,2],'g');
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
%
% See also: none
% Author: Amr Alanwar
% Written: 8-Sept-2022
% Last update:
%
%
% Last revision: ---
%------------- BEGIN CODE --------------
points = [];
if ~isempty(Z1.G)
numOfgen = length( Z1.G );
L=2^numOfgen;
%T = zeros(L,N);
for i=1:L
table = de2bi(i-1,numOfgen,'left-msb');
onePoint=[ table(1,1)&Z1.G{1}];
for j=2:numOfgen
onePoint =xor( onePoint, (table(1,j)&Z1.G{j}) );
end
if ~isempty(Z1.c)
points = [ points xor(Z1.c,onePoint)];
else
points = [ points onePoint];
end
if mod(i,1000)==0
points=unique(points','rows')';
end
end
% pointB = dec2bin(i-1,numOfgen);
% [rows,cols]=size(pointB);
% row=[];
% for j =1:cols
% if j==cols
% row=[ row, pointB(j)];
% else
% row=[ row, pointB(j), ' '];
% end
% end
% table=str2num(row);
% points = [];
% %for o=1:numOfgen
% %for k=1:numOfgen
%
%
% table=truth_table(numOfgen);
% [rowsTable,colsTable]=size(table);
% for i =1:rowsTable
%
% % [rowsGen,colsGen]=size(gen1);
% onePoint=[ table(i,1)&Z1.G{1}];
% for j=2:numOfgen
% onePoint =xor( onePoint, (table(i,j)&Z1.G{j}) );
% end
% if ~isempty(Z1.c)
% points = [ points xor(Z1.c,onePoint)];
% else
% points = [ points onePoint];
% end
% end
else
points = Z1.c;
end
points=unique(points','rows')';
end
% function genBeta = computeGenBeta ()
%
% end
%------------- END OF CODE --------------