24 #ifndef PPL_MIP_Problem_templates_hh
25 #define PPL_MIP_Problem_templates_hh 1
31 template <
typename In>
37 : external_space_dim(dim),
38 internal_space_dim(0),
43 status(PARTIALLY_SATISFIABLE),
44 pricing(PRICING_STEEPEST_EDGE_FLOAT),
47 inherited_constraints(0),
48 first_pending_constraint(0),
49 input_obj_function(obj),
51 last_generator(point()),
52 i_variables(int_vars) {
57 s <<
"PPL::MIP_Problem::MIP_Problem"
58 <<
"(dim, first, last, int_vars, obj, mode):\n"
62 throw std::invalid_argument(s.str());
67 throw std::length_error(
"PPL::MIP_Problem:: MIP_Problem(dim, first, "
68 "last, int_vars, obj, mode):\n"
69 "dim exceeds the maximum allowed"
75 s <<
"PPL::MIP_Problem::MIP_Problem(dim, first, last,"
76 <<
"int_vars, obj, mode):\n"
78 <<
" exceeds d == "<< dim <<
".";
79 throw std::invalid_argument(s.str());
83 for (In i = first; i != last; ++i) {
84 if (i->is_strict_inequality()) {
85 throw std::invalid_argument(
"PPL::MIP_Problem::"
86 "MIP_Problem(dim, first, last, int_vars,"
87 "obj, mode):\nrange [first, last) contains"
88 "a strict inequality constraint.");
90 if (i->space_dimension() > dim) {
92 s <<
"PPL::MIP_Problem::"
93 <<
"MIP_Problem(dim, first, last, int_vars, obj, mode):\n"
94 <<
"range [first, last) contains a constraint having space"
95 <<
"dimension == " << i->space_dimension() <<
" that exceeds"
96 "this->space_dimension == " << dim <<
".";
97 throw std::invalid_argument(s.str());
104 for (Constraint_Sequence::const_iterator
115 template <
typename In>
120 : external_space_dim(dim),
121 internal_space_dim(0),
126 status(PARTIALLY_SATISFIABLE),
127 pricing(PRICING_STEEPEST_EDGE_FLOAT),
130 inherited_constraints(0),
131 first_pending_constraint(0),
132 input_obj_function(obj),
134 last_generator(point()),
138 throw std::length_error(
"PPL::MIP_Problem::"
139 "MIP_Problem(dim, first, last, obj, mode):\n"
140 "dim exceeds the maximum allowed space "
145 std::ostringstream s;
146 s <<
"PPL::MIP_Problem::MIP_Problem(dim, first, last,"
149 <<
" exceeds d == "<< dim <<
".";
150 throw std::invalid_argument(s.str());
154 for (In i = first; i != last; ++i) {
155 if (i->is_strict_inequality()) {
156 throw std::invalid_argument(
"PPL::MIP_Problem::"
157 "MIP_Problem(dim, first, last, obj, mode):"
159 "range [first, last) contains a strict "
160 "inequality constraint.");
162 if (i->space_dimension() > dim) {
163 std::ostringstream s;
164 s <<
"PPL::MIP_Problem::"
165 <<
"MIP_Problem(dim, first, last, obj, mode):\n"
166 <<
"range [first, last) contains a constraint having space"
167 <<
"dimension" <<
" == " << i->space_dimension() <<
" that exceeds"
168 "this->space_dimension == " << dim <<
".";
169 throw std::invalid_argument(s.str());
176 for (Constraint_Sequence::const_iterator
189 #endif // !defined(PPL_MIP_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...
Optimization_Mode
Possible optimization modes.
size_t dimension_type
An unsigned integral type for representing space dimensions.
An std::set of variables' indexes.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
std::vector< Constraint * > input_cs
The sequence of constraints describing the feasible region.
Variables_Set i_variables
A set containing all the indexes of variables that are constrained to have an integer value...
bool OK() const
Checks if all the invariants are satisfied.
The entire library is confined to this namespace.
void add_constraint_helper(const Constraint &c)
Helper method: implements exception safe addition.
dimension_type external_space_dim
The dimension of the vector space.
static dimension_type max_space_dimension()
Returns the maximum space dimension an MIP_Problem can handle.
MIP_Problem(dimension_type dim=0)
Builds a trivial MIP problem.