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_inlines_hh
00025 #define PPL_MIP_Problem_inlines_hh 1
00026
00027 #include "Constraint.defs.hh"
00028 #include <stdexcept>
00029
00030 namespace Parma_Polyhedra_Library {
00031
00032 inline dimension_type
00033 MIP_Problem::max_space_dimension() {
00034 return Constraint::max_space_dimension();
00035 }
00036
00037 inline dimension_type
00038 MIP_Problem::space_dimension() const {
00039 return external_space_dim;
00040 }
00041
00042
00043 inline
00044 MIP_Problem::MIP_Problem(const MIP_Problem& y)
00045 : external_space_dim(y.external_space_dim),
00046 internal_space_dim(y.internal_space_dim),
00047 tableau(y.tableau),
00048 working_cost(y.working_cost),
00049 mapping(y.mapping),
00050 base(y.base),
00051 status(y.status),
00052 pricing(y.pricing),
00053 initialized(y.initialized),
00054 input_cs(y.input_cs),
00055 first_pending_constraint(y.first_pending_constraint),
00056 input_obj_function(y.input_obj_function),
00057 opt_mode(y.opt_mode),
00058 last_generator(y.last_generator),
00059 i_variables(y.i_variables) {
00060 PPL_ASSERT(OK());
00061 }
00062
00063 inline
00064 MIP_Problem::~MIP_Problem() {
00065 }
00066
00067
00068 inline void
00069 MIP_Problem::set_optimization_mode(const Optimization_Mode mode) {
00070 if (opt_mode != mode) {
00071 opt_mode = mode;
00072 if (status == UNBOUNDED || status == OPTIMIZED)
00073 status = SATISFIABLE;
00074 PPL_ASSERT(OK());
00075 }
00076 }
00077
00078 inline const Linear_Expression&
00079 MIP_Problem::objective_function() const {
00080 return input_obj_function;
00081 }
00082
00083 inline Optimization_Mode
00084 MIP_Problem::optimization_mode() const {
00085 return opt_mode;
00086 }
00087
00088 inline void
00089 MIP_Problem::optimal_value(Coefficient& num, Coefficient& den) const {
00090 const Generator& g = optimizing_point();
00091 evaluate_objective_function(g, num, den);
00092 }
00093
00094 inline MIP_Problem::const_iterator
00095 MIP_Problem::constraints_begin() const {
00096 return input_cs.begin();
00097 }
00098
00099 inline MIP_Problem::const_iterator
00100 MIP_Problem::constraints_end() const {
00101 return input_cs.end();
00102 }
00103
00104 inline const Variables_Set&
00105 MIP_Problem::integer_space_dimensions() const {
00106 return i_variables;
00107 }
00108
00109 inline MIP_Problem::Control_Parameter_Value
00110 MIP_Problem::get_control_parameter(Control_Parameter_Name name) const {
00111 used(name);
00112 PPL_ASSERT(name == PRICING);
00113 return pricing;
00114 }
00115
00116 inline void
00117 MIP_Problem::set_control_parameter(Control_Parameter_Value value) {
00118 pricing = value;
00119 }
00120
00121 inline void
00122 MIP_Problem::swap(MIP_Problem& y) {
00123 std::swap(external_space_dim, y.external_space_dim);
00124 std::swap(internal_space_dim, y.internal_space_dim);
00125 std::swap(tableau, y.tableau);
00126 std::swap(working_cost, y.working_cost);
00127 std::swap(mapping, y.mapping);
00128 std::swap(initialized, y.initialized);
00129 std::swap(base, y.base);
00130 std::swap(status, y.status);
00131 std::swap(pricing, y.pricing);
00132 std::swap(input_cs, y.input_cs);
00133 std::swap(first_pending_constraint, y.first_pending_constraint);
00134 std::swap(input_obj_function, y.input_obj_function);
00135 std::swap(opt_mode, y.opt_mode);
00136 std::swap(last_generator, y.last_generator);
00137 std::swap(i_variables, y.i_variables);
00138 }
00139
00140 inline MIP_Problem&
00141 MIP_Problem::operator=(const MIP_Problem& y) {
00142 MIP_Problem tmp(y);
00143 swap(tmp);
00144 return *this;
00145 }
00146
00147 inline void
00148 MIP_Problem::clear() {
00149 MIP_Problem tmp;
00150 swap(tmp);
00151 }
00152
00153 inline memory_size_type
00154 MIP_Problem::external_memory_in_bytes() const {
00155 memory_size_type n
00156 = tableau.external_memory_in_bytes()
00157 + working_cost.external_memory_in_bytes()
00158 + input_obj_function.external_memory_in_bytes()
00159 + last_generator.external_memory_in_bytes();
00160
00161 n += input_cs.capacity() * sizeof(Constraint);
00162 for (const_iterator i = input_cs.begin(),
00163 i_end = input_cs.end(); i != i_end; ++i)
00164 n += (i->external_memory_in_bytes());
00165
00166 n += base.capacity() * sizeof(dimension_type);
00167
00168 n += mapping.capacity() * sizeof(std::pair<dimension_type, dimension_type>);
00169 return n;
00170 }
00171
00172 inline memory_size_type
00173 MIP_Problem::total_memory_in_bytes() const {
00174 return sizeof(*this) + external_memory_in_bytes();
00175 }
00176
00177 }
00178
00179 namespace std {
00180
00182 inline void
00183 swap(Parma_Polyhedra_Library::MIP_Problem& x,
00184 Parma_Polyhedra_Library::MIP_Problem& y) {
00185 x.swap(y);
00186 }
00187
00188 }
00189
00190 #endif // !defined(PPL_MIP_Problem_inlines_hh)