24 #ifndef PPL_MIP_Problem_defs_hh
25 #define PPL_MIP_Problem_defs_hh 1
44 namespace IO_Operators {
49 operator<<(std::ostream& s,
const MIP_Problem& mip);
55 void swap(MIP_Problem& x, MIP_Problem& y);
140 template <
typename In>
178 template <
typename In>
243 typedef Constraint_Sequence::const_iterator
Base;
507 #if PPL_USE_SPARSE_MATRIX
530 std::vector<std::pair<dimension_type, dimension_type> >
mapping;
533 std::vector<dimension_type>
base;
608 : lp(mip), i_vars() {
710 std::deque<bool>& is_tableau_constraint,
711 std::deque<bool>& is_satisfied_inequality,
712 std::deque<bool>& is_nonnegative_variable,
713 std::deque<bool>& is_remergeable_variable)
const;
746 #if PPL_USE_SPARSE_MATRIX
766 #endif // defined(PPL_USE_SPARSE_MATRIX)
770 const std::vector<std::pair<dimension_type, dimension_type> >& mapping,
925 mpq_class& incumbent_solution_value,
976 #endif // !defined(PPL_MIP_Problem_defs_hh)
MIP_Problem & operator=(const MIP_Problem &y)
Assignment operator.
bool operator==(const const_iterator &y) const
Compares *this with y.
bool is_satisfiable() const
Checks satisfiability of *this.
Constraint_Sequence::const_iterator Base
void set_optimization_mode(Optimization_Mode mode)
Sets the optimization mode to mode.
A linear equality or inequality.
void swap(CO_Tree &x, CO_Tree &y)
Optimization_Mode
Possible optimization modes.
Optimization_Mode opt_mode
The optimization mode requested.
A finite sequence of coefficients.
size_t dimension_type
An unsigned integral type for representing space dimensions.
static void linear_combine(Row &x, const Row &y, const dimension_type k)
Linearly combines x with y so that *this[k] is 0.
Linear_Expression input_obj_function
The objective function to be optimized.
An std::set of variables' indexes.
A line, ray, point or closure point.
void add_constraints(const Constraint_System &cs)
Adds a copy of the constraints in cs to the MIP problem.
const_iterator constraints_end() const
Returns a past-the-end read-only iterator to the sequence of constraints defining the feasible region...
const_iterator & operator+=(difference_type n)
Moves iterator forward of n positions.
bool is_in_base(dimension_type var_index, dimension_type &row_index) const
void swap(MIP_Problem &x, MIP_Problem &y)
Swaps x with y.
~MIP_Problem()
Destructor.
Control_Parameter_Value
Possible values for MIP problem's control parameters.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
A sparse matrix of Coefficient.
working_cost_type working_cost
The working cost function.
A finite sparse sequence of coefficients.
const_iterator & operator-=(difference_type n)
Moves iterator backward of n positions.
const_iterator & operator++()
Prefix increment.
const_iterator & operator--()
Prefix decrement.
MIP_Problem_Status compute_tableau(std::vector< dimension_type > &worked_out_row)
Assigns to this->tableau a simplex tableau representing the MIP problem, inserting into this->mapping...
A helper class to temporarily relax a MIP problem using RAII.
std::vector< Constraint * > input_cs
The sequence of constraints describing the feasible region.
void evaluate_objective_function(const Generator &evaluating_point, Coefficient &numer, Coefficient &denom) const
Sets num and denom so that is the result of evaluating the objective function on evaluating_point...
void add_constraint(const Constraint &c)
Adds a copy of constraint c to the MIP problem.
const Constraint * pointer
std::vector< dimension_type > base
The current basic solution.
bool is_lp_satisfiable() const
Returns true if and if only the LP problem is satisfiable.
A tag type to distinguish normal vs. inheriting copy constructor.
const Variables_Set & integer_space_dimensions() const
Returns a set containing all the variables' indexes constrained to be integral.
A read-only iterator on the constraints defining the feasible region.
void erase_artificials(dimension_type begin_artificials, dimension_type end_artificials)
Drop unnecessary artificial variables from the tableau and get ready for the second phase of the simp...
const Linear_Expression & objective_function() const
Returns the objective function.
const Generator & optimizing_point() const
Returns an optimal point for *this, if it exists.
std::vector< std::pair< dimension_type, dimension_type > > mapping
A map between the variables of `input_cs' and `tableau'.
dimension_type get_exiting_base_index(dimension_type entering_var_index) const
Computes the row index of the variable exiting the base of the MIP problem. Implemented with anti-cyc...
bool compute_simplex_using_steepest_edge_float()
Returns true if and if only the algorithm successfully computed a feasible solution.
Control_Parameter_Value get_control_parameter(Control_Parameter_Name name) const
Returns the value of the control parameter name.
pointer operator->() const
Returns the address of the "pointed" object.
std::iterator_traits< Base > Base_Traits
Variables_Set i_variables
A set containing all the indexes of variables that are constrained to have an integer value...
~RAII_Temporary_Real_Relaxation()
const_iterator(Base b)
Constructor from a Base iterator.
#define PPL_OUTPUT_DECLARATIONS
const_iterator constraints_begin() const
Returns a read-only iterator to the first constraint defining the feasible region.
Matrix< Row > tableau
The matrix encoding the current feasible region in tableau form.
std::vector< Constraint * > Constraint_Sequence
A type alias for a sequence of constraints.
dimension_type steepest_edge_float_entering_index() const
Same as steepest_edge_exact_entering_index, but using floating points.
bool OK() const
Checks if all the invariants are satisfied.
Optimization_Mode optimization_mode() const
Returns the optimization mode.
dimension_type merge_split_variable(dimension_type var_index)
Merges back the positive and negative part of a (previously split) variable after detecting a corresp...
const_iterator operator+(difference_type n) const
Returns an iterator n positions forward.
Control_Parameter_Name
Names of MIP problems' control parameters.
The MIP problem is optimized; an optimal solution has been computed.
static bool is_mip_satisfiable(MIP_Problem &mip, const Variables_Set &i_vars, Generator &p)
Returns true if and if only the MIP problem mip is satisfiable when variables in i_vars can only take...
const Constraint & reference
void pivot(dimension_type entering_var_index, dimension_type exiting_base_index)
Performs the pivoting operation on the tableau.
void optimal_value(Coefficient &numer, Coefficient &denom) const
Sets numer and denom so that is the solution of the optimization problem.
Base itr
The Base iterator on the Constraint_Sequence.
dimension_type steepest_edge_exact_entering_index() const
Computes the column index of the variable entering the base, using an exact steepest-edge algorithm w...
A Mixed Integer (linear) Programming problem.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
static bool choose_branching_variable(const MIP_Problem &mip, const Variables_Set &i_vars, dimension_type &branching_index)
Returns true if and if only mip.last_generator satisfies all the integrality conditions implicitly st...
The MIP problem is unsatisfiable.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
static bool is_satisfied(const Constraint &c, const Generator &g)
Returns true if and only if c is satisfied by g.
static MIP_Problem_Status solve_mip(bool &have_incumbent_solution, mpq_class &incumbent_solution_value, Generator &incumbent_solution_point, MIP_Problem &mip, const Variables_Set &i_vars)
Returns a status that encodes the solution of the MIP problem.
The feasible region of the MIP problem has been changed by adding new space dimensions or new constra...
void m_swap(MIP_Problem &y)
Swaps *this with y.
bool initialized
A Boolean encoding whether or not internal data structures have already been properly sized and popul...
void clear()
Resets *this to be equal to the trivial MIP problem.
Status status
The internal state of the MIP problem.
void second_phase()
Optimizes the MIP problem using the second phase of the primal simplex algorithm. ...
static bool is_unbounded_obj_function(const Linear_Expression &obj_function, const std::vector< std::pair< dimension_type, dimension_type > > &mapping, Optimization_Mode optimization_mode)
dimension_type inherited_constraints
The number of constraints that are inherited from our parent in the recursion tree built when solving...
The entire library is confined to this namespace.
bool operator!=(const const_iterator &y) const
Compares *this with y.
dimension_type textbook_entering_index() const
Computes the column index of the variable entering the base, using the textbook algorithm with anti-c...
static bool is_saturated(const Constraint &c, const Generator &g)
Returns true if and only if c is saturated by g.
const Generator & feasible_point() const
Returns a feasible point for *this, if it exists.
void add_constraint_helper(const Constraint &c)
Helper method: implements exception safe addition.
difference_type operator-(const const_iterator &y) const
Iterator difference: computes distances.
Maximization is requested.
Status
An enumerated type describing the internal status of the MIP problem.
Base_Traits::difference_type difference_type
void set_objective_function(const Linear_Expression &obj)
Sets the objective function to obj.
Generator last_generator
The last successfully computed feasible or optimizing point.
MIP_Problem_Status solve() const
Optimizes the MIP problem.
dimension_type internal_space_dim
The space dimension of the current (partial) solution of the MIP problem; it may be smaller than exte...
The MIP problem is unbounded; a feasible solution has been computed.
void compute_generator() const
Computes a valid generator that satisfies all the constraints of the Linear Programming problem assoc...
RAII_Temporary_Real_Relaxation(MIP_Problem &mip)
bool parse_constraints(dimension_type &additional_tableau_rows, dimension_type &additional_slack_variables, std::deque< bool > &is_tableau_constraint, std::deque< bool > &is_satisfied_inequality, std::deque< bool > &is_nonnegative_variable, std::deque< bool > &is_remergeable_variable) const
Parses the pending constraints to gather information on how to resize the tableau.
Steepest edge pricing method, using floating points (default).
Control_Parameter_Value pricing
The pricing method in use.
bool compute_simplex_using_exact_pricing()
Returns true if and if only the algorithm successfully computed a feasible solution.
void process_pending_constraints()
Processes the pending constraints of *this.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
Steepest edge pricing method, using Coefficient.
void set_control_parameter(Control_Parameter_Value value)
Sets control parameter value.
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
dimension_type external_space_dim
The dimension of the vector space.
void add_space_dimensions_and_embed(dimension_type m)
Adds m new space dimensions and embeds the old MIP problem in the new vector space.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
dimension_type first_pending_constraint
The first index of `input_cs' containing a pending constraint.
reference operator*() const
Returns a reference to the "pointed" object.
static dimension_type max_space_dimension()
Returns the maximum space dimension an MIP_Problem can handle.
const Constraint value_type
MIP_Problem(dimension_type dim=0)
Builds a trivial MIP problem.
MIP_Problem_Status
Possible outcomes of the MIP_Problem solver.
Base_Traits::iterator_category iterator_category
void add_to_integer_space_dimensions(const Variables_Set &i_vars)
Sets the variables whose indexes are in set i_vars to be integer space dimensions.
dimension_type space_dimension() const
Returns the space dimension of the MIP problem.
The MIP problem is satisfiable; a feasible solution has been computed.