00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_MIP_Problem_templates_hh
00025 #define PPL_MIP_Problem_templates_hh 1
00026
00027 #include "Variables_Set.defs.hh"
00028
00029 namespace Parma_Polyhedra_Library {
00030
00031 template <typename In>
00032 MIP_Problem::MIP_Problem(const dimension_type dim,
00033 In first,
00034 In last,
00035 const Variables_Set& int_vars,
00036 const Linear_Expression& obj,
00037 const Optimization_Mode mode)
00038 : external_space_dim(dim),
00039 internal_space_dim(0),
00040 tableau(),
00041 working_cost(0, Row::Flags()),
00042 mapping(),
00043 base(),
00044 status(PARTIALLY_SATISFIABLE),
00045 pricing(PRICING_STEEPEST_EDGE_FLOAT),
00046 initialized(false),
00047 input_cs(),
00048 first_pending_constraint(0),
00049 input_obj_function(obj),
00050 opt_mode(mode),
00051 last_generator(point()),
00052 i_variables(int_vars) {
00053
00054
00055 if (i_variables.space_dimension() > external_space_dim) {
00056 std::ostringstream s;
00057 s << "PPL::MIP_Problem::MIP_Problem"
00058 << "(dim, first, last, int_vars, obj, mode):\n"
00059 << "dim == "<< external_space_dim << " and int_vars.space_dimension() =="
00060 << " " << i_variables.space_dimension() << " are dimension"
00061 "incompatible.";
00062 throw std::invalid_argument(s.str());
00063 }
00064
00065
00066 if (dim > max_space_dimension())
00067 throw std::length_error("PPL::MIP_Problem:: MIP_Problem(dim, first, "
00068 "last, int_vars, obj, mode):\n"
00069 "dim exceeds the maximum allowed"
00070 "space dimension.");
00071
00072 if (obj.space_dimension() > dim) {
00073 std::ostringstream s;
00074 s << "PPL::MIP_Problem::MIP_Problem(dim, first, last,"
00075 << "int_vars, obj, mode):\n"
00076 << "obj.space_dimension() == "<< obj.space_dimension()
00077 << " exceeds d == "<< dim << ".";
00078 throw std::invalid_argument(s.str());
00079 }
00080
00081 for (In i = first; i != last; ++i) {
00082 if (i->is_strict_inequality())
00083 throw std::invalid_argument("PPL::MIP_Problem::"
00084 "MIP_Problem(dim, first, last, int_vars,"
00085 "obj, mode):\nrange [first, last) contains"
00086 "a strict inequality constraint.");
00087 if (i->space_dimension() > dim) {
00088 std::ostringstream s;
00089 s << "PPL::MIP_Problem::"
00090 << "MIP_Problem(dim, first, last, int_vars, obj, mode):\n"
00091 << "range [first, last) contains a constraint having space"
00092 << "dimension == " << i->space_dimension() << " that exceeds"
00093 "this->space_dimension == " << dim << ".";
00094 throw std::invalid_argument(s.str());
00095 }
00096 input_cs.push_back(*i);
00097 }
00098 PPL_ASSERT(OK());
00099 }
00100
00101 template <typename In>
00102 MIP_Problem::MIP_Problem(dimension_type dim,
00103 In first, In last,
00104 const Linear_Expression& obj,
00105 Optimization_Mode mode)
00106 : external_space_dim(dim),
00107 internal_space_dim(0),
00108 tableau(),
00109 working_cost(0, Row::Flags()),
00110 mapping(),
00111 base(),
00112 status(PARTIALLY_SATISFIABLE),
00113 pricing(PRICING_STEEPEST_EDGE_FLOAT),
00114 initialized(false),
00115 input_cs(),
00116 first_pending_constraint(0),
00117 input_obj_function(obj),
00118 opt_mode(mode),
00119 last_generator(point()),
00120 i_variables() {
00121
00122 if (dim > max_space_dimension())
00123 throw std::length_error("PPL::MIP_Problem::"
00124 "MIP_Problem(dim, first, last, obj, mode):\n"
00125 "dim exceeds the maximum allowed space "
00126 "dimension.");
00127
00128 if (obj.space_dimension() > dim) {
00129 std::ostringstream s;
00130 s << "PPL::MIP_Problem::MIP_Problem(dim, first, last,"
00131 << " obj, mode):\n"
00132 << "obj.space_dimension() == "<< obj.space_dimension()
00133 << " exceeds d == "<< dim << ".";
00134 throw std::invalid_argument(s.str());
00135 }
00136
00137 for (In i = first; i != last; ++i) {
00138 if (i->is_strict_inequality())
00139 throw std::invalid_argument("PPL::MIP_Problem::"
00140 "MIP_Problem(dim, first, last, obj, mode):\n"
00141 "range [first, last) contains a strict "
00142 "inequality constraint.");
00143 if (i->space_dimension() > dim) {
00144 std::ostringstream s;
00145 s << "PPL::MIP_Problem::"
00146 << "MIP_Problem(dim, first, last, obj, mode):\n"
00147 << "range [first, last) contains a constraint having space"
00148 << "dimension" << " == " << i->space_dimension() << " that exceeds"
00149 "this->space_dimension == " << dim << ".";
00150 throw std::invalid_argument(s.str());
00151 }
00152 input_cs.push_back(*i);
00153 }
00154 PPL_ASSERT(OK());
00155 }
00156
00157 }
00158
00159 #endif // !defined(PPL_MIP_Problem_templates_hh)