PPL  1.2
H79_Certificate.cc
Go to the documentation of this file.
1 /* H79_Certificate class implementation
2  (non-inline member functions).
3  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
4  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
5 
6 This file is part of the Parma Polyhedra Library (PPL).
7 
8 The PPL is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 The PPL is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
21 
22 For the most up-to-date information see the Parma Polyhedra Library
23 site: http://bugseng.com/products/ppl/ . */
24 
25 #include "ppl-config.h"
26 #include "H79_Certificate_defs.hh"
27 #include "Polyhedron_defs.hh"
28 #include "assertions.hh"
29 #include <iostream>
30 
31 namespace PPL = Parma_Polyhedra_Library;
32 
34  : affine_dim(0), num_constraints(0) {
35  // The affine dimension of the polyhedron is obtained by subtracting
36  // the number of equalities from the space dimension.
37  // When counting constraints, for a correct reasoning, we have
38  // to disregard the low-level constraints (i.e., the positivity
39  // constraint and epsilon bounds).
40  const dimension_type space_dim = ph.space_dimension();
41  affine_dim = space_dim;
43  // It is assumed that `ph' is not an empty polyhedron.
44  PPL_ASSERT(!ph.marked_empty());
46  cs_end = cs.end(); i != cs_end; ++i) {
48  if (i->is_equality()) {
49  --affine_dim;
50  }
51  }
52 
53  // TODO: this is an inefficient workaround.
54  // For NNC polyhedra, generators might be no longer up-to-date
55  // (and hence, neither minimized) due to the strong minimization
56  // process applied to constraints when constructing the certificate.
57  // We have to reinforce the (normal) minimization of the generator
58  // system. The future, lazy implementation of the strong minimization
59  // process will solve this problem.
60  if (!ph.is_necessarily_closed()) {
61  ph.minimize();
62  }
63 }
64 
65 int
67  if (affine_dim != y.affine_dim) {
68  return (affine_dim > y.affine_dim) ? 1 : -1;
69  }
71  return (num_constraints > y.num_constraints) ? 1 : -1;
72  }
73  // All components are equal.
74  return 0;
75 }
76 
77 int
79  // The affine dimension of the polyhedron is obtained by subtracting
80  // the number of equalities from the space dimension.
81  // When counting constraints, for a correct reasoning, we have
82  // to disregard the low-level constraints (i.e., the positivity
83  // constraint and epsilon bounds).
84  const dimension_type space_dim = ph.space_dimension();
85  dimension_type ph_affine_dim = space_dim;
86  dimension_type ph_num_constraints = 0;
88  // It is assumed that `ph' is a polyhedron containing the
89  // polyhedron described by `*this': hence, it cannot be empty.
90  PPL_ASSERT(!ph.marked_empty());
92  cs_end = cs.end(); i != cs_end; ++i) {
93  ++ph_num_constraints;
94  if (i->is_equality()) {
95  --ph_affine_dim;
96  }
97  }
98  // TODO: this is an inefficient workaround.
99  // For NNC polyhedra, generators might be no longer up-to-date
100  // (and hence, neither minimized) due to the strong minimization
101  // process applied to constraints when constructing the certificate.
102  // We have to reinforce the (normal) minimization of the generator
103  // system. The future, lazy implementation of the strong minimization
104  // process will solve this problem.
105  if (!ph.is_necessarily_closed()) {
106  ph.minimize();
107  }
108 
109  // If the affine dimension of `ph' is increasing, the chain is stabilizing.
110  if (ph_affine_dim > affine_dim) {
111  return 1;
112  }
113 
114  // At this point the two polyhedra must have the same affine dimension.
115  PPL_ASSERT(ph_affine_dim == affine_dim);
116 
117  // If the number of constraints of `ph' is decreasing, then the chain
118  // is stabilizing. If it is increasing, the chain is not stabilizing.
119  if (ph_num_constraints != num_constraints) {
120  return (ph_num_constraints < num_constraints) ? 1 : -1;
121  }
122 
123  // All components are equal.
124  return 0;
125 }
bool marked_empty() const
Returns true if the polyhedron is known to be empty.
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_constraints(const Constraint_System &cs)
Helper returning number of constraints in system.
const_iterator begin() const
Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise...
The base class for convex polyhedra.
const_iterator end() const
Returns the past-the-end const_iterator.
int compare(const H79_Certificate &y) const
The comparison function for certificates.
dimension_type num_constraints(const Constraint_System &cs)
bool minimize(const Linear_Expression &expr, Coefficient &inf_n, Coefficient &inf_d, bool &minimum) const
Returns true if and only if *this is not empty and expr is bounded from below in *this, in which case the infimum value is computed.
The entire library is confined to this namespace.
Definition: version.hh:61
dimension_type num_constraints
Cardinality of a non-redundant constraint system for the polyhedron.
bool is_necessarily_closed() const
Returns true if and only if the polyhedron is necessarily closed.
dimension_type affine_dim
Affine dimension of the polyhedron.
A convergence certificate for the H79 widening operator.
const Constraint_System & minimized_constraints() const
Returns the system of constraints, with no redundant constraint.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.