Package: ppl / 0.10.2-8

dfff7e13e8817970647c38289b1f4e8d94999ea2 Patch series | download
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
From dfff7e13e8817970647c38289b1f4e8d94999ea2 Mon Sep 17 00:00:00 2001
From: Enea Zaffanella <zaffanella@cs.unipr.it>
Date: Sat, 15 Aug 2009 08:10:19 +0200
Subject: [PATCH] Corrected a few expected results in Powerset/maxmin1.cc.
 This uncovered a bug in Pointset_Powerset methods maximize() and minimize(),
 whereby we are returning true even for empty powersets.

---
 tests/Octagonal_Shape/max_min1.cc |    1 -
 tests/Polyhedron/max_min1.cc      |   25 ++++++++++-
 tests/Powerset/maxmin1.cc         |   93 +++++++++++++++++++------------------
 3 files changed, 72 insertions(+), 47 deletions(-)

diff --git a/tests/Octagonal_Shape/max_min1.cc b/tests/Octagonal_Shape/max_min1.cc
index c0915ac..4d87172 100644
--- a/tests/Octagonal_Shape/max_min1.cc
+++ b/tests/Octagonal_Shape/max_min1.cc
@@ -326,7 +326,6 @@ test09() {
 
 bool
 test10() {
-
   TOctagonal_Shape oct(0);
 
   print_constraints(oct, "*** oct ***");
diff --git a/tests/Polyhedron/max_min1.cc b/tests/Polyhedron/max_min1.cc
index c8da74b..8a73b99 100644
--- a/tests/Polyhedron/max_min1.cc
+++ b/tests/Polyhedron/max_min1.cc
@@ -132,7 +132,6 @@ test02() {
 
 bool
 test03() {
-
   C_Polyhedron ph(0);
 
   print_constraints(ph, "*** ph ***");
@@ -172,10 +171,34 @@ test03() {
   return ok;
 }
 
+bool
+test04() {
+  C_Polyhedron ph(2, EMPTY);
+
+  print_constraints(ph, "*** ph ***");
+
+  Coefficient num = 0;
+  Coefficient den = 0;
+  bool included = false;
+  Generator g(point());
+  Linear_Expression LE;
+  bool ok = !ph.maximize(LE, num, den, included, g)
+    && num == 0 && den == 0 && !included
+    && g.is_point()
+    && g.divisor() == 1;
+  ok = ok && !ph.minimize(LE, num, den, included, g)
+    && num == 0 && den == 0 && !included
+    && g.is_point()
+    && g.divisor() == 1;
+
+  return ok;
+}
+
 } // namespace
 
 BEGIN_MAIN
   DO_TEST(test01);
   DO_TEST_F8(test02);
   DO_TEST(test03);
+  DO_TEST(test04);
 END_MAIN
diff --git a/tests/Powerset/maxmin1.cc b/tests/Powerset/maxmin1.cc
index b1a351f..0973762 100644
--- a/tests/Powerset/maxmin1.cc
+++ b/tests/Powerset/maxmin1.cc
@@ -29,15 +29,15 @@ namespace {
 bool
 test01() {
   Pointset_Powerset<C_Polyhedron> ps(0, EMPTY);
-  Coefficient num;
-  Coefficient den;
-  bool included;
+  Coefficient num = 0;
+  Coefficient den = 0;
+  bool included = false;
   Generator g(point());
   Linear_Expression LE;
-  bool ok = ps.maximize(LE, num, den, included)
-    && num == 0 && den == 1 && !included;
-  ok = ok && ps.maximize(LE, num, den, included, g)
-    && num == 0 && den == 1 && !included
+  bool ok = !ps.maximize(LE, num, den, included)
+    && num == 0 && den == 0 && !included;
+  ok = ok && !ps.maximize(LE, num, den, included, g)
+    && num == 0 && den == 0 && !included
     && g.is_point()
     && g.divisor() == 1;
 
@@ -69,9 +69,9 @@ test02() {
   Constraint_System cs;
   Linear_Expression LE = x;
 
-  Coefficient max_n;
-  Coefficient max_d;
-  bool max_included;
+  Coefficient max_n = 0;
+  Coefficient max_d = 0;
+  bool max_included = false;
   Generator max_g(point());
   Pointset_Powerset<NNC_Polyhedron> ps(1, EMPTY);
 
@@ -123,9 +123,9 @@ test03() {
   Constraint_System cs;
   Linear_Expression LE = 9*x + y;
 
-  Coefficient num;
-  Coefficient den;
-  bool included;
+  Coefficient num = 0;
+  Coefficient den = 0;
+  bool included = false;
   Generator g(point());
   Pointset_Powerset<C_Polyhedron> ps(2, EMPTY);
 
@@ -148,7 +148,6 @@ test03() {
   print_generator(g);
   nout << endl;
 
-
   if (!ok)
     return false;
 
@@ -180,16 +179,16 @@ test04() {
   Variable x(0);
   Linear_Expression LE = x;
 
-  Coefficient num;
-  Coefficient den;
-  bool included;
+  Coefficient num = 0;
+  Coefficient den = 0;
+  bool included = false;
   Generator g(point());
   Pointset_Powerset<C_Polyhedron> ps(1, EMPTY);
 
-  bool ok = ps.maximize(LE, num, den, included)
-    && num == 0 && den == 1 && !included;
-  ok = ok && ps.maximize(LE, num, den, included, g)
-    && num == 0 && den == 1 && !included
+  bool ok = !ps.maximize(LE, num, den, included)
+    && num == 0 && den == 0 && !included;
+  ok = ok && !ps.maximize(LE, num, den, included, g)
+    && num == 0 && den == 0 && !included
     && g.is_point()
     && g.divisor() == 1;
 
@@ -197,7 +196,10 @@ test04() {
     return false;
 
   ps.add_disjunct(C_Polyhedron(1));
-  ok = !ps.maximize(LE, num, den, included, g);
+  ok = !ps.maximize(LE, num, den, included, g)
+    && num == 0 && den == 0 && !included
+    && g.is_point()
+    && g.divisor() == 1;
 
   return ok;
 }
@@ -206,16 +208,16 @@ test04() {
 bool
 test05() {
   Linear_Expression LE;
-  Coefficient num;
-  Coefficient den;
-  bool included;
+  Coefficient num = 0;
+  Coefficient den = 0;
+  bool included = false;
   Generator g(point());
   Pointset_Powerset<C_Polyhedron> ps(0, EMPTY);
 
-  bool ok = ps.minimize(LE, num, den, included)
-    && num == 0 && den == 1 && !included;
-  ok = ok && ps.minimize(LE, num, den, included, g)
-    && num == 0 && den == 1 && !included
+  bool ok = !ps.minimize(LE, num, den, included)
+    && num == 0 && den == 0 && !included;
+  ok = ok && !ps.minimize(LE, num, den, included, g)
+    && num == 0 && den == 0 && !included
     && g.is_point()
     && g.divisor() == 1;
 
@@ -247,9 +249,9 @@ test06() {
   Constraint_System cs;
   Linear_Expression LE = x;
 
-  Coefficient min_n;
-  Coefficient min_d;
-  bool min_included;
+  Coefficient min_n = 0;
+  Coefficient min_d = 0;
+  bool min_included = false;
   Generator min_g(point());
 
   Pointset_Powerset<NNC_Polyhedron> ps(1, EMPTY);
@@ -302,9 +304,9 @@ test07() {
   Constraint_System cs;
   Linear_Expression LE = x + y;
 
-  Coefficient num;
-  Coefficient den;
-  bool included;
+  Coefficient num = 0;
+  Coefficient den = 0;
+  bool included = false;
   Generator g(point());
   Pointset_Powerset<C_Polyhedron> ps(2, EMPTY);
 
@@ -327,7 +329,6 @@ test07() {
   print_generator(g);
   nout << endl;
 
-
   if (!ok)
     return false;
 
@@ -359,25 +360,27 @@ test08() {
   Variable x(0);
   Linear_Expression LE = x;
 
-  Coefficient num;
-  Coefficient den;
-  bool included;
+  Coefficient num = 0;
+  Coefficient den = 0;
+  bool included = false;
   Generator g(point());
   Pointset_Powerset<C_Polyhedron> ps(1, EMPTY);
 
-  bool ok = ps.minimize(LE, num, den, included)
-    && num == 0 && den == 1 && !included;
-  ok = ok && ps.minimize(LE, num, den, included, g)
-    && num == 0 && den == 1 && !included
+  bool ok = !ps.minimize(LE, num, den, included)
+    && num == 0 && den == 0 && !included;
+  ok = ok && !ps.minimize(LE, num, den, included, g)
+    && num == 0 && den == 0 && !included
     && g.is_point()
     && g.divisor() == 1;
 
-
   if (!ok)
     return false;
 
   ps.add_disjunct(C_Polyhedron(1));
-  ok = !ps.minimize(LE, num, den, included, g);
+  ok = !ps.minimize(LE, num, den, included, g)
+    && num == 0 && den == 0 && !included
+    && g.is_point()
+    && g.divisor() == 1;
 
   return ok;
 }
-- 
1.6.0.6