Parma_Polyhedra_Library::BHRZ03_Certificate Class Reference
[C++ Language Interface]

The convergence certificate for the BHRZ03 widening operator. More...

#include <BHRZ03_Certificate.defs.hh>

List of all members.

Classes

struct  Compare
 A total ordering on BHRZ03 certificates. More...

Public Member Functions

 BHRZ03_Certificate ()
 Default constructor.
 BHRZ03_Certificate (const Polyhedron &ph)
 Constructor: computes the certificate for ph.
 BHRZ03_Certificate (const BHRZ03_Certificate &y)
 Copy constructor.
 ~BHRZ03_Certificate ()
 Destructor.
int compare (const BHRZ03_Certificate &y) const
 The comparison function for certificates.
int compare (const Polyhedron &ph) const
 Compares *this with the certificate for polyhedron ph.
bool is_stabilizing (const Polyhedron &ph) const
 Returns true if and only if the certificate for polyhedron ph is strictly smaller than *this.
bool OK () const
 Check if gathered information is meaningful.

Private Attributes

dimension_type affine_dim
 Affine dimension of the polyhedron.
dimension_type lin_space_dim
 Dimension of the lineality space of the polyhedron.
dimension_type num_constraints
 Cardinality of a non-redundant constraint system for the polyhedron.
dimension_type num_points
 Number of non-redundant points in a generator system for the polyhedron.
std::vector< dimension_typenum_rays_null_coord
 A vector containing, for each index `0 <= i < space_dim', the number of non-redundant rays in a generator system of the polyhedron having exactly `i' null coordinates.

Detailed Description

The convergence certificate for the BHRZ03 widening operator.

Convergence certificates are used to instantiate the BHZ03 framework so as to define widening operators for the finite powerset domain.

Note:
Each convergence certificate has to be used together with a compatible widening operator. In particular, BHRZ03_Certificate can certify the convergence of both the BHRZ03 and the H79 widenings.

Definition at line 43 of file BHRZ03_Certificate.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::BHRZ03_Certificate::BHRZ03_Certificate (  )  [inline]

Default constructor.

Definition at line 30 of file BHRZ03_Certificate.inlines.hh.

References OK().

00031   : affine_dim(0), lin_space_dim(0), num_constraints(0), num_points(1),
00032     num_rays_null_coord() {
00033   // This is the certificate for a zero-dim universe polyhedron.
00034   PPL_ASSERT(OK());
00035 }

Parma_Polyhedra_Library::BHRZ03_Certificate::BHRZ03_Certificate ( const Polyhedron ph  ) 

Constructor: computes the certificate for ph.

Definition at line 35 of file BHRZ03_Certificate.cc.

References affine_dim, Parma_Polyhedra_Library::Generator_System::begin(), Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::Generator::CLOSURE_POINT, Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Generator_System::end(), Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Polyhedron::is_necessarily_closed(), lin_space_dim, Parma_Polyhedra_Library::Generator::LINE, Parma_Polyhedra_Library::Polyhedron::marked_empty(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::Polyhedron::minimized_constraints(), Parma_Polyhedra_Library::Polyhedron::minimized_generators(), num_constraints, num_points, num_rays_null_coord, OK(), Parma_Polyhedra_Library::Generator::POINT, Parma_Polyhedra_Library::Generator::RAY, and Parma_Polyhedra_Library::Polyhedron::space_dimension().

00036   : affine_dim(0), lin_space_dim(0), num_constraints(0), num_points(0),
00037     num_rays_null_coord(ph.space_dimension(), 0) {
00038   // TODO: provide a correct and reasonably efficient
00039   // implementation for NNC polyhedra.
00040 
00041   // The computation of the certificate requires both the
00042   // constraint and the generator systems in minimal form.
00043   ph.minimize();
00044   // It is assumed that `ph' is not an empty polyhedron.
00045   PPL_ASSERT(!ph.marked_empty());
00046 
00047   // The dimension of the polyhedron is obtained by subtracting
00048   // the number of equalities from the space dimension.
00049   // When counting constraints, for a correct reasoning, we have
00050   // to disregard the low-level constraints (i.e., the positivity
00051   // constraint and epsilon bounds).
00052   const dimension_type space_dim = ph.space_dimension();
00053   affine_dim = space_dim;
00054   PPL_ASSERT(num_constraints == 0);
00055   const Constraint_System& cs = ph.minimized_constraints();
00056   for (Constraint_System::const_iterator i = cs.begin(),
00057          cs_end = cs.end(); i != cs_end; ++i) {
00058     ++num_constraints;
00059     if (i->is_equality())
00060       --affine_dim;
00061   }
00062 
00063   PPL_ASSERT(lin_space_dim == 0);
00064   PPL_ASSERT(num_points == 0);
00065   const Generator_System& gs = ph.minimized_generators();
00066   for (Generator_System::const_iterator i = gs.begin(),
00067          gs_end = gs.end(); i != gs_end; ++i)
00068     switch (i->type()) {
00069     case Generator::POINT:
00070       // Intentionally fall through.
00071     case Generator::CLOSURE_POINT:
00072       ++num_points;
00073       break;
00074     case Generator::RAY:
00075       // For each i such that 0 <= j < space_dim,
00076       // `num_rays_null_coord[j]' will be the number of rays
00077       // having exactly `j' coordinates equal to 0.
00078       {
00079         const Generator& r = *i;
00080         dimension_type num_zeroes = 0;
00081         for (dimension_type j = space_dim; j-- > 0; )
00082           if (r.coefficient(Variable(j)) == 0)
00083             ++num_zeroes;
00084         ++num_rays_null_coord[num_zeroes];
00085       }
00086       break;
00087     case Generator::LINE:
00088       // Since the generator systems is minimized, the dimension of
00089       // the lineality space is equal to the number of lines.
00090       ++lin_space_dim;
00091       break;
00092     }
00093   PPL_ASSERT(OK());
00094 
00095   // TODO: this is an inefficient workaround.
00096   // For NNC polyhedra, constraints might be no longer up-to-date
00097   // (and hence, neither minimized) due to the strong minimization
00098   // process applied to generators when constructing the certificate.
00099   // We have to reinforce the (normal) minimization of the constraint
00100   // system. The future, lazy implementation of the strong minimization
00101   // process will solve this problem.
00102   if (!ph.is_necessarily_closed())
00103     ph.minimize();
00104 }

Parma_Polyhedra_Library::BHRZ03_Certificate::BHRZ03_Certificate ( const BHRZ03_Certificate y  )  [inline]

Copy constructor.

Definition at line 38 of file BHRZ03_Certificate.inlines.hh.

00039   : affine_dim(y.affine_dim), lin_space_dim(y.lin_space_dim),
00040     num_constraints(y.num_constraints), num_points(y.num_points),
00041     num_rays_null_coord(y.num_rays_null_coord) {
00042 }

Parma_Polyhedra_Library::BHRZ03_Certificate::~BHRZ03_Certificate (  )  [inline]

Destructor.

Definition at line 45 of file BHRZ03_Certificate.inlines.hh.

00045                                         {
00046 }


Member Function Documentation

int Parma_Polyhedra_Library::BHRZ03_Certificate::compare ( const Polyhedron ph  )  const

Compares *this with the certificate for polyhedron ph.

Definition at line 130 of file BHRZ03_Certificate.cc.

References affine_dim, Parma_Polyhedra_Library::Generator_System::begin(), Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::Generator::CLOSURE_POINT, Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Generator_System::end(), Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Polyhedron::is_necessarily_closed(), lin_space_dim, Parma_Polyhedra_Library::Generator::LINE, Parma_Polyhedra_Library::Polyhedron::marked_empty(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::Polyhedron::minimized_constraints(), Parma_Polyhedra_Library::Polyhedron::minimized_generators(), num_constraints, num_points, num_rays_null_coord, Parma_Polyhedra_Library::Generator::POINT, Parma_Polyhedra_Library::Generator::RAY, Parma_Polyhedra_Library::Polyhedron::space_dim, and Parma_Polyhedra_Library::Polyhedron::space_dimension().

00130                                                          {
00131   PPL_ASSERT(ph.space_dimension() == num_rays_null_coord.size());
00132 
00133   // TODO: provide a correct and reasonably efficient
00134   // implementation for NNC polyhedra.
00135 
00136   // The computation of the certificate requires both the
00137   // constraint and the generator systems in minimal form.
00138   ph.minimize();
00139   // It is assumed that `ph' is a polyhedron containing the
00140   // polyhedron described by `*this': hence, it cannot be empty.
00141   PPL_ASSERT(!ph.marked_empty());
00142 
00143   // The dimension of the polyhedron is obtained by subtracting
00144   // the number of equalities from the space dimension.
00145   // When counting constraints, for a correct reasoning, we have
00146   // to disregard the low-level constraints (i.e., the positivity
00147   // constraint and epsilon bounds).
00148   const dimension_type space_dim = ph.space_dimension();
00149   dimension_type ph_affine_dim = space_dim;
00150   dimension_type ph_num_constraints = 0;
00151   const Constraint_System& cs = ph.minimized_constraints();
00152   for (Constraint_System::const_iterator i = cs.begin(),
00153          cs_end = cs.end(); i != cs_end; ++i) {
00154     ++ph_num_constraints;
00155     if (i->is_equality())
00156       --ph_affine_dim;
00157   }
00158   // TODO: this is an inefficient workaround.
00159   // For NNC polyhedra, constraints might be no longer up-to-date
00160   // (and hence, neither minimized) due to the strong minimization
00161   // process applied to generators when constructing the certificate.
00162   // We have to reinforce the (normal) minimization of the constraint
00163   // system. The future, lazy implementation of the strong minimization
00164   // process will solve this problem.
00165   if (!ph.is_necessarily_closed())
00166     ph.minimize();
00167 
00168   // If the dimension of `ph' is increasing, the chain is stabilizing.
00169   if (ph_affine_dim > affine_dim)
00170     return 1;
00171 
00172   // At this point the two polyhedra must have the same dimension.
00173   PPL_ASSERT(ph_affine_dim == affine_dim);
00174 
00175   // Speculative optimization: in order to better exploit the incrementality
00176   // of the comparison, we do not compute information about rays here,
00177   // hoping that the other components will be enough.
00178   dimension_type ph_lin_space_dim = 0;
00179   dimension_type ph_num_points = 0;
00180   const Generator_System& gs = ph.minimized_generators();
00181   for (Generator_System::const_iterator i = gs.begin(),
00182          gs_end = gs.end(); i != gs_end; ++i)
00183     switch (i->type()) {
00184     case Generator::POINT:
00185       // Intentionally fall through.
00186     case Generator::CLOSURE_POINT:
00187       ++ph_num_points;
00188       break;
00189     case Generator::RAY:
00190       break;
00191     case Generator::LINE:
00192       // Since the generator systems is minimized, the dimension of
00193       // the lineality space is equal to the number of lines.
00194       ++ph_lin_space_dim;
00195       break;
00196     }
00197   // TODO: this is an inefficient workaround.
00198   // For NNC polyhedra, constraints might be no longer up-to-date
00199   // (and hence, neither minimized) due to the strong minimization
00200   // process applied to generators when constructing the certificate.
00201   // We have to reinforce the (normal) minimization of the constraint
00202   // system. The future, lazy implementation of the strong minimization
00203   // process will solve this problem.
00204   if (!ph.is_necessarily_closed())
00205     ph.minimize();
00206 
00207   // If the dimension of the lineality space is increasing,
00208   // then the chain is stabilizing.
00209   if (ph_lin_space_dim > lin_space_dim)
00210     return 1;
00211 
00212   // At this point the lineality space of the two polyhedra must have
00213   // the same dimension.
00214   PPL_ASSERT(ph_lin_space_dim == lin_space_dim);
00215 
00216   // If the number of constraints of `ph' is decreasing, then the chain
00217   // is stabilizing. If it is increasing, the chain is not stabilizing.
00218   // If they are equal, further investigation is needed.
00219   if (ph_num_constraints != num_constraints)
00220     return ph_num_constraints < num_constraints ? 1 : -1;
00221 
00222   // If the number of points of `ph' is decreasing, then the chain
00223   // is stabilizing. If it is increasing, the chain is not stabilizing.
00224   // If they are equal, further investigation is needed.
00225   if (ph_num_points != num_points)
00226     return ph_num_points < num_points ? 1 : -1;
00227 
00228   // The speculative optimization was not worth:
00229   // compute information about rays.
00230   std::vector<dimension_type> ph_num_rays_null_coord(ph.space_dim, 0);
00231   for (Generator_System::const_iterator i = gs.begin(),
00232          gs_end = gs.end(); i != gs_end; ++i)
00233     if (i->is_ray()) {
00234       const Generator& r = *i;
00235       dimension_type num_zeroes = 0;
00236       for (dimension_type j = space_dim; j-- > 0; )
00237         if (r.coefficient(Variable(j)) == 0)
00238           ++num_zeroes;
00239       ++ph_num_rays_null_coord[num_zeroes];
00240     }
00241   // Compare (lexicographically) the two vectors:
00242   // if ph_num_rays_null_coord < num_rays_null_coord the chain is stabilizing.
00243   for (dimension_type i = 0; i < space_dim; i++)
00244     if (ph_num_rays_null_coord[i] != num_rays_null_coord[i])
00245       return ph_num_rays_null_coord[i] < num_rays_null_coord[i] ? 1 : -1;
00246 
00247   // All components are equal.
00248   return 0;
00249 }

int Parma_Polyhedra_Library::BHRZ03_Certificate::compare ( const BHRZ03_Certificate y  )  const

The comparison function for certificates.

Returns:
$-1$, $0$ or $1$ depending on whether *this is smaller than, equal to, or greater than y, respectively.

Compares *this with y, using a total ordering which is a refinement of the limited growth ordering relation for the BHRZ03 widening.

Definition at line 107 of file BHRZ03_Certificate.cc.

References affine_dim, lin_space_dim, num_constraints, num_points, num_rays_null_coord, and OK().

Referenced by is_stabilizing(), and Parma_Polyhedra_Library::BHRZ03_Certificate::Compare::operator()().

00107                                                                 {
00108   PPL_ASSERT(OK() && y.OK());
00109   if (affine_dim != y.affine_dim)
00110     return affine_dim > y.affine_dim ? 1 : -1;
00111   if (lin_space_dim != y.lin_space_dim)
00112     return lin_space_dim > y.lin_space_dim ? 1 : -1;
00113   if (num_constraints != y.num_constraints)
00114     return num_constraints > y.num_constraints ? 1 : -1;
00115   if (num_points != y.num_points)
00116     return num_points > y.num_points ? 1 : -1;
00117 
00118   const dimension_type space_dim = num_rays_null_coord.size();
00119   PPL_ASSERT(num_rays_null_coord.size() == y.num_rays_null_coord.size());
00120   // Note: iterating upwards, because we have to check first
00121   // the number of rays having more NON-zero coordinates.
00122   for (dimension_type i = 0; i < space_dim; i++)
00123     if (num_rays_null_coord[i] != y.num_rays_null_coord[i])
00124       return num_rays_null_coord[i] > y.num_rays_null_coord[i] ? 1 : -1;
00125   // All components are equal.
00126   return 0;
00127 }

bool Parma_Polyhedra_Library::BHRZ03_Certificate::is_stabilizing ( const Polyhedron ph  )  const [inline]

Returns true if and only if the certificate for polyhedron ph is strictly smaller than *this.

Definition at line 49 of file BHRZ03_Certificate.inlines.hh.

References compare().

Referenced by Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_points(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), and Parma_Polyhedra_Library::Polyhedron::BHRZ03_widening_assign().

00049                                                              {
00050   return compare(ph) == 1;
00051 }

bool Parma_Polyhedra_Library::BHRZ03_Certificate::OK (  )  const

Check if gathered information is meaningful.

Definition at line 252 of file BHRZ03_Certificate.cc.

References affine_dim, lin_space_dim, num_constraints, num_points, and num_rays_null_coord.

Referenced by BHRZ03_Certificate(), and compare().

00252                                 {
00253 #ifndef NDEBUG
00254   using std::endl;
00255   using std::cerr;
00256 #endif
00257 
00258   // The dimension of the vector space.
00259   const dimension_type space_dim = num_rays_null_coord.size();
00260 
00261   if (affine_dim > space_dim) {
00262 #ifndef NDEBUG
00263     cerr << "In the BHRZ03 certificate about a non-empty polyhedron:"
00264          << endl
00265          << "the affine dimension is greater than the space dimension!"
00266          << endl;
00267 #endif
00268     return false;
00269   }
00270 
00271   if (lin_space_dim > affine_dim) {
00272 #ifndef NDEBUG
00273     cerr << "In the BHRZ03 certificate about a non-empty polyhedron:"
00274          << endl
00275          << "the lineality space dimension is greater than "
00276          << "the affine dimension!"
00277          << endl;
00278 #endif
00279     return false;
00280   }
00281 
00282   if (num_constraints < space_dim - affine_dim) {
00283 #ifndef NDEBUG
00284     cerr << "In the BHRZ03 certificate about a non-empty polyhedron:"
00285          << endl
00286          << "in a vector space of dimension `n',"
00287          << "any polyhedron of affine dimension `k'" << endl
00288          << "should have `n-k' non-redundant constraints at least."
00289          << endl
00290          << "Here space_dim = " << space_dim << ", "
00291          << "affine_dim = " << affine_dim << ", "
00292          << "but num_constraints = " << num_constraints << "!"
00293          << endl;
00294 #endif
00295     return false;
00296   }
00297 
00298   if (num_points == 0) {
00299 #ifndef NDEBUG
00300     cerr << "In the BHRZ03 certificate about a non-empty polyhedron:"
00301          << endl
00302          << "the generator system has no points!"
00303          << endl;
00304 #endif
00305     return false;
00306   }
00307 
00308   if (lin_space_dim == space_dim) {
00309     // This was a universe polyhedron.
00310     if (num_constraints > 0) {
00311 #ifndef NDEBUG
00312       cerr << "In the BHRZ03 certificate about a non-empty polyhedron:"
00313            << endl
00314            << "a universe polyhedron has non-redundant constraints!"
00315            << endl;
00316 #endif
00317       return false;
00318     }
00319 
00320     if (num_points != 1) {
00321 #ifndef NDEBUG
00322       cerr << "In the BHRZ03 certificate about a non-empty polyhedron:"
00323            << endl
00324            << "a universe polyhedron has more than one non-redundant point!"
00325            << endl;
00326 #endif
00327       return false;
00328     }
00329   }
00330 
00331   // All tests passed.
00332   return true;
00333 }


Member Data Documentation

Affine dimension of the polyhedron.

Definition at line 98 of file BHRZ03_Certificate.defs.hh.

Referenced by BHRZ03_Certificate(), compare(), and OK().

Dimension of the lineality space of the polyhedron.

Definition at line 100 of file BHRZ03_Certificate.defs.hh.

Referenced by BHRZ03_Certificate(), compare(), and OK().

Cardinality of a non-redundant constraint system for the polyhedron.

Definition at line 102 of file BHRZ03_Certificate.defs.hh.

Referenced by BHRZ03_Certificate(), compare(), and OK().

Number of non-redundant points in a generator system for the polyhedron.

Definition at line 107 of file BHRZ03_Certificate.defs.hh.

Referenced by BHRZ03_Certificate(), compare(), and OK().

A vector containing, for each index `0 <= i < space_dim', the number of non-redundant rays in a generator system of the polyhedron having exactly `i' null coordinates.

Definition at line 113 of file BHRZ03_Certificate.defs.hh.

Referenced by BHRZ03_Certificate(), compare(), and OK().


The documentation for this class was generated from the following files:
Generated on Sun Feb 27 16:20:28 2011 for PPL by  doxygen 1.6.3