24 #ifndef PPL_termination_templates_hh
25 #define PPL_termination_templates_hh 1
36 #define PRINT_DEBUG_INFO 0
44 namespace Implementation {
46 namespace Termination {
61 static int output_function_MS_which = -1;
68 output_function_MS(std::ostream& s,
const Variable v) {
70 switch (output_function_MS_which) {
72 if (
id < output_function_MS_n) {
75 else if (
id < 2*output_function_MS_n) {
76 s <<
"x" <<
id - output_function_MS_n + 1;
83 if (
id < output_function_MS_n) {
86 else if (
id == output_function_MS_n) {
89 else if (
id <= output_function_MS_n + output_function_MS_m) {
90 s <<
"y" <<
id - output_function_MS_n;
98 if (
id < output_function_MS_n) {
101 else if (
id == output_function_MS_n) {
104 else if (output_function_MS_which == 2
105 &&
id <= output_function_MS_n + output_function_MS_m + 2) {
106 s <<
"z" <<
id - output_function_MS_n;
113 if (
id < output_function_MS_n) {
116 else if (
id == output_function_MS_n) {
119 else if (
id <= output_function_MS_n + output_function_MS_m) {
120 s <<
"y" <<
id - output_function_MS_n;
122 else if (
id <= output_function_MS_n + 2*output_function_MS_m + 2) {
123 s <<
"z" <<
id - (output_function_MS_n + output_function_MS_m);
143 output_function_PR(std::ostream& s,
const Variable v) {
145 if (
id < output_function_PR_s) {
146 s <<
"u3_" <<
id + 1;
148 else if (
id < output_function_PR_s + output_function_PR_r) {
149 s <<
"u2_" <<
id - output_function_PR_s + 1;
151 else if (
id < output_function_PR_s + 2*output_function_PR_r) {
152 s <<
"u1_" <<
id - (output_function_PR_s + output_function_PR_r) + 1;
162 Constraint_System& cs_out);
164 template <
typename PSET>
221 template <
typename PSET>
225 const PSET& pset_after,
235 cs_after_end = cs_after.
end(); i != cs_after_end; ++i) {
240 template <
typename PSET>
244 if (space_dim % 2 != 0) {
245 std::ostringstream s;
246 s <<
"PPL::termination_test_MS(pset):\n"
247 "pset.space_dimension() == " << space_dim
249 throw std::invalid_argument(s.str());
252 using namespace Implementation::Termination;
258 template <
typename PSET>
261 const dimension_type before_space_dim = pset_before.space_dimension();
262 const dimension_type after_space_dim = pset_after.space_dimension();
263 if (after_space_dim != 2*before_space_dim) {
264 std::ostringstream s;
265 s <<
"PPL::termination_test_MS_2(pset_before, pset_after):\n"
266 "pset_before.space_dimension() == " << before_space_dim
267 <<
", pset_after.space_dimension() == " << after_space_dim
268 <<
";\nthe latter should be twice the former.";
269 throw std::invalid_argument(s.str());
272 using namespace Implementation::Termination;
279 template <
typename PSET>
283 if (space_dim % 2 != 0) {
284 std::ostringstream s;
285 s <<
"PPL::one_affine_ranking_function_MS(pset, mu):\n"
286 "pset.space_dimension() == " << space_dim
288 throw std::invalid_argument(s.str());
291 using namespace Implementation::Termination;
297 template <
typename PSET>
300 const PSET& pset_after,
302 const dimension_type before_space_dim = pset_before.space_dimension();
303 const dimension_type after_space_dim = pset_after.space_dimension();
304 if (after_space_dim != 2*before_space_dim) {
305 std::ostringstream s;
306 s <<
"PPL::one_affine_ranking_function_MS_2(pset_before, pset_after, mu):\n"
307 "pset_before.space_dimension() == " << before_space_dim
308 <<
", pset_after.space_dimension() == " << after_space_dim
309 <<
";\nthe latter should be twice the former.";
310 throw std::invalid_argument(s.str());
313 using namespace Implementation::Termination;
320 template <
typename PSET>
324 if (space_dim % 2 != 0) {
325 std::ostringstream s;
326 s <<
"PPL::all_affine_ranking_functions_MS(pset, mu_space):\n"
327 "pset.space_dimension() == " << space_dim
329 throw std::invalid_argument(s.str());
332 if (pset.is_empty()) {
337 using namespace Implementation::Termination;
343 template <
typename PSET>
346 const PSET& pset_after,
348 const dimension_type before_space_dim = pset_before.space_dimension();
349 const dimension_type after_space_dim = pset_after.space_dimension();
350 if (after_space_dim != 2*before_space_dim) {
351 std::ostringstream s;
352 s <<
"PPL::all_affine_ranking_functions_MS_2"
353 <<
"(pset_before, pset_after, mu_space):\n"
354 <<
"pset_before.space_dimension() == " << before_space_dim
355 <<
", pset_after.space_dimension() == " << after_space_dim
356 <<
";\nthe latter should be twice the former.";
357 throw std::invalid_argument(s.str());
360 if (pset_before.is_empty()) {
365 using namespace Implementation::Termination;
372 template <
typename PSET>
378 if (space_dim % 2 != 0) {
379 std::ostringstream s;
380 s <<
"PPL::all_affine_quasi_ranking_functions_MS"
381 <<
"(pset, decr_space, bounded_space):\n"
382 <<
"pset.space_dimension() == " << space_dim
384 throw std::invalid_argument(s.str());
387 if (pset.is_empty()) {
389 bounded_mu_space = decreasing_mu_space;
393 using namespace Implementation::Termination;
401 template <
typename PSET>
404 const PSET& pset_after,
407 const dimension_type before_space_dim = pset_before.space_dimension();
408 const dimension_type after_space_dim = pset_after.space_dimension();
409 if (after_space_dim != 2*before_space_dim) {
410 std::ostringstream s;
411 s <<
"PPL::all_affine_quasi_ranking_functions_MS_2"
412 <<
"(pset_before, pset_after, decr_space, bounded_space):\n"
413 <<
"pset_before.space_dimension() == " << before_space_dim
414 <<
", pset_after.space_dimension() == " << after_space_dim
415 <<
";\nthe latter should be twice the former.";
416 throw std::invalid_argument(s.str());
419 if (pset_before.is_empty()) {
421 bounded_mu_space = decreasing_mu_space;
425 using namespace Implementation::Termination;
434 template <
typename PSET>
437 const dimension_type before_space_dim = pset_before.space_dimension();
438 const dimension_type after_space_dim = pset_after.space_dimension();
439 if (after_space_dim != 2*before_space_dim) {
440 std::ostringstream s;
441 s <<
"PPL::termination_test_PR_2(pset_before, pset_after):\n"
442 <<
"pset_before.space_dimension() == " << before_space_dim
443 <<
", pset_after.space_dimension() == " << after_space_dim
444 <<
";\nthe latter should be twice the former.";
445 throw std::invalid_argument(s.str());
448 using namespace Implementation::Termination;
456 template <
typename PSET>
460 if (space_dim % 2 != 0) {
461 std::ostringstream s;
462 s <<
"PPL::termination_test_PR(pset):\n"
463 <<
"pset.space_dimension() == " << space_dim
465 throw std::invalid_argument(s.str());
468 using namespace Implementation::Termination;
474 template <
typename PSET>
477 const PSET& pset_after,
479 const dimension_type before_space_dim = pset_before.space_dimension();
480 const dimension_type after_space_dim = pset_after.space_dimension();
481 if (after_space_dim != 2*before_space_dim) {
482 std::ostringstream s;
483 s <<
"PPL::one_affine_ranking_function_PR_2"
484 <<
"(pset_before, pset_after, mu):\n"
485 <<
"pset_before.space_dimension() == " << before_space_dim
486 <<
", pset_after.space_dimension() == " << after_space_dim
487 <<
";\nthe latter should be twice the former.";
488 throw std::invalid_argument(s.str());
491 using namespace Implementation::Termination;
499 template <
typename PSET>
503 if (space_dim % 2 != 0) {
504 std::ostringstream s;
505 s <<
"PPL::one_affine_ranking_function_PR(pset, mu):\n"
506 <<
"pset.space_dimension() == " << space_dim
508 throw std::invalid_argument(s.str());
511 using namespace Implementation::Termination;
517 template <
typename PSET>
520 const PSET& pset_after,
522 const dimension_type before_space_dim = pset_before.space_dimension();
523 const dimension_type after_space_dim = pset_after.space_dimension();
524 if (after_space_dim != 2*before_space_dim) {
525 std::ostringstream s;
526 s <<
"PPL::all_affine_ranking_functions_MS_2"
527 <<
"(pset_before, pset_after, mu_space):\n"
528 <<
"pset_before.space_dimension() == " << before_space_dim
529 <<
", pset_after.space_dimension() == " << after_space_dim
530 <<
";\nthe latter should be twice the former.";
531 throw std::invalid_argument(s.str());
534 if (pset_before.is_empty()) {
539 using namespace Implementation::Termination;
547 template <
typename PSET>
552 if (space_dim % 2 != 0) {
553 std::ostringstream s;
554 s <<
"PPL::all_affine_ranking_functions_PR(pset, mu_space):\n"
555 <<
"pset.space_dimension() == " << space_dim
557 throw std::invalid_argument(s.str());
560 if (pset.is_empty()) {
565 using namespace Implementation::Termination;
573 #endif // !defined(PPL_termination_templates_hh)
bool one_affine_ranking_function_PR_original(const Constraint_System &cs, Generator &mu)
An iterator over a system of constraints.
bool one_affine_ranking_function_PR_2(const PSET &pset_before, const PSET &pset_after, Generator &mu)
void shift_space_dimensions(Variable v, dimension_type n)
bool one_affine_ranking_function_PR(const PSET &pset, Generator &mu)
void all_affine_ranking_functions_MS(const PSET &pset, C_Polyhedron &mu_space)
bool termination_test_MS(const Constraint_System &cs)
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool one_affine_ranking_function_MS(const PSET &pset, Generator &mu)
A line, ray, point or closure point.
void assign_all_inequalities_approximation(const Constraint_System &cs_in, Constraint_System &cs_out)
void insert(const Constraint &c)
Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed...
const_iterator begin() const
Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise...
A dimension of the vector space.
bool one_affine_ranking_function_MS(const Constraint_System &cs, Generator &mu)
void all_affine_quasi_ranking_functions_MS(const Constraint_System &cs, C_Polyhedron &decreasing_mu_space, C_Polyhedron &bounded_mu_space)
bool one_affine_ranking_function_PR(const Constraint_System &cs_before, const Constraint_System &cs_after, Generator &mu)
void all_affine_ranking_functions_PR_original(const Constraint_System &cs, NNC_Polyhedron &mu_space)
bool termination_test_PR(const Constraint_System &cs_before, const Constraint_System &cs_after)
void all_affine_ranking_functions_PR_2(const PSET &pset_before, const PSET &pset_after, NNC_Polyhedron &mu_space)
static void assign_all_inequalities_approximation(const PSET &pset_before, const PSET &pset_after, Constraint_System &cs)
void all_affine_ranking_functions_MS(const Constraint_System &cs, C_Polyhedron &mu_space)
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool termination_test_MS_2(const PSET &pset_before, const PSET &pset_after)
const_iterator end() const
Returns the past-the-end const_iterator.
A not necessarily closed convex polyhedron.
A closed convex polyhedron.
The universe element, i.e., the whole vector space.
void all_affine_ranking_functions_PR(const Constraint_System &cs_before, const Constraint_System &cs_after, NNC_Polyhedron &mu_space)
bool termination_test_PR(const PSET &pset)
The entire library is confined to this namespace.
void all_affine_quasi_ranking_functions_MS(const PSET &pset, C_Polyhedron &decreasing_mu_space, C_Polyhedron &bounded_mu_space)
bool termination_test_PR_2(const PSET &pset_before, const PSET &pset_after)
void all_affine_quasi_ranking_functions_MS_2(const PSET &pset_before, const PSET &pset_after, C_Polyhedron &decreasing_mu_space, C_Polyhedron &bounded_mu_space)
void all_affine_ranking_functions_MS_2(const PSET &pset_before, const PSET &pset_after, C_Polyhedron &mu_space)
void all_affine_ranking_functions_PR(const PSET &pset, NNC_Polyhedron &mu_space)
bool one_affine_ranking_function_MS_2(const PSET &pset_before, const PSET &pset_after, Generator &mu)
bool termination_test_PR_original(const Constraint_System &cs)
void assign_all_inequalities_approximation(const PSET &pset, Constraint_System &cs)
bool termination_test_MS(const PSET &pset)