PPL  0.12.1
PIP_Problem.templates.hh
Go to the documentation of this file.
00001 /* PIP_Problem class implementation: non-inline template functions.
00002    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
00003    Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com)
00004 
00005 This file is part of the Parma Polyhedra Library (PPL).
00006 
00007 The PPL is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 The PPL is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software Foundation,
00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
00020 
00021 For the most up-to-date information see the Parma Polyhedra Library
00022 site: http://bugseng.com/products/ppl/ . */
00023 
00024 #ifndef PPL_PIP_Problem_templates_hh
00025 #define PPL_PIP_Problem_templates_hh 1
00026 
00027 #include "Variables_Set.defs.hh"
00028 
00029 namespace Parma_Polyhedra_Library {
00030 
00031 template <typename In>
00032 PIP_Problem::PIP_Problem(dimension_type dim,
00033                          In first, In last,
00034                          const Variables_Set& p_vars)
00035   : external_space_dim(dim),
00036     internal_space_dim(0),
00037     status(PARTIALLY_SATISFIABLE),
00038     current_solution(0),
00039     input_cs(),
00040     first_pending_constraint(0),
00041     parameters(p_vars),
00042     initial_context(),
00043     big_parameter_dimension(not_a_dimension()) {
00044   // Check that integer Variables_Set does not exceed the space dimension
00045   // of the problem.
00046   if (p_vars.space_dimension() > external_space_dim) {
00047     std::ostringstream s;
00048     s << "PPL::PIP_Problem::PIP_Problem(dim, first, last, p_vars):\n"
00049       << "dim == " << external_space_dim
00050       << " and p_vars.space_dimension() == "
00051       << p_vars.space_dimension()
00052       << " are dimension incompatible.";
00053     throw std::invalid_argument(s.str());
00054   }
00055 
00056   // Check for space dimension overflow.
00057   if (dim > max_space_dimension())
00058     throw std::length_error("PPL::PIP_Problem::"
00059                             "PIP_Problem(dim, first, last, p_vars):\n"
00060                             "dim exceeds the maximum allowed "
00061                             "space dimension.");
00062   // Check the constraints.
00063   for (In i = first; i != last; ++i) {
00064     if (i->space_dimension() > dim) {
00065       std::ostringstream s;
00066       s << "PPL::PIP_Problem::"
00067         << "PIP_Problem(dim, first, last, p_vars):\n"
00068         << "range [first, last) contains a constraint having space "
00069         << "dimension == " << i->space_dimension()
00070         << " that exceeds this->space_dimension == " << dim << ".";
00071       throw std::invalid_argument(s.str());
00072     }
00073     input_cs.push_back(*i);
00074   }
00075   control_parameters_init();
00076   PPL_ASSERT(OK());
00077 }
00078 
00079 } // namespace Parma_Polyhedra_Library
00080 
00081 #endif // !defined(PPL_PIP_Problem_templates_hh)