PPL  1.2
PIP_Problem_templates.hh
Go to the documentation of this file.
1 /* PIP_Problem class implementation: non-inline template functions.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_PIP_Problem_templates_hh
25 #define PPL_PIP_Problem_templates_hh 1
26 
27 #include "Variables_Set_defs.hh"
28 
29 namespace Parma_Polyhedra_Library {
30 
31 template <typename In>
33  In first, In last,
34  const Variables_Set& p_vars)
35  : external_space_dim(dim),
36  internal_space_dim(0),
37  status(PARTIALLY_SATISFIABLE),
38  current_solution(0),
39  input_cs(),
40  first_pending_constraint(0),
41  parameters(p_vars),
42  initial_context(),
43  big_parameter_dimension(not_a_dimension()) {
44  // Check that integer Variables_Set does not exceed the space dimension
45  // of the problem.
46  if (p_vars.space_dimension() > external_space_dim) {
47  std::ostringstream s;
48  s << "PPL::PIP_Problem::PIP_Problem(dim, first, last, p_vars):\n"
49  << "dim == " << external_space_dim
50  << " and p_vars.space_dimension() == "
51  << p_vars.space_dimension()
52  << " are dimension incompatible.";
53  throw std::invalid_argument(s.str());
54  }
55 
56  // Check for space dimension overflow.
57  if (dim > max_space_dimension()) {
58  throw std::length_error("PPL::PIP_Problem::"
59  "PIP_Problem(dim, first, last, p_vars):\n"
60  "dim exceeds the maximum allowed "
61  "space dimension.");
62  }
63  // Check the constraints.
64  for (In i = first; i != last; ++i) {
65  if (i->space_dimension() > dim) {
66  std::ostringstream s;
67  s << "PPL::PIP_Problem::"
68  << "PIP_Problem(dim, first, last, p_vars):\n"
69  << "range [first, last) contains a constraint having space "
70  << "dimension == " << i->space_dimension()
71  << " that exceeds this->space_dimension == " << dim << ".";
72  throw std::invalid_argument(s.str());
73  }
74  input_cs.push_back(*i);
75  }
77  PPL_ASSERT(OK());
78 }
79 
80 } // namespace Parma_Polyhedra_Library
81 
82 #endif // !defined(PPL_PIP_Problem_templates_hh)
dimension_type space_dimension() const
Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in t...
static dimension_type max_space_dimension()
Returns the maximum space dimension a PIP_Problem can handle.
size_t dimension_type
An unsigned integral type for representing space dimensions.
PIP_Problem(dimension_type dim=0)
Builds a trivial PIP problem.
Definition: PIP_Problem.cc:50
An std::set of variables' indexes.
dimension_type not_a_dimension()
Returns a value that does not designate a valid dimension.
dimension_type external_space_dim
The dimension of the vector space.
bool OK() const
Checks if all the invariants are satisfied.
Definition: PIP_Problem.cc:277
void control_parameters_init()
Initializes the control parameters with default values.
Definition: PIP_Problem.cc:93
Constraint_Sequence input_cs
The sequence of constraints describing the feasible region.
The entire library is confined to this namespace.
Definition: version.hh:61