PPL  1.2
PIP_Problem_defs.hh
Go to the documentation of this file.
1 /* PIP_Problem class declaration.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_PIP_Problem_defs_hh
25 #define PPL_PIP_Problem_defs_hh 1
26 
27 #include "PIP_Problem_types.hh"
28 #include "PIP_Tree_types.hh"
29 #include "globals_types.hh"
31 #include "Matrix_defs.hh"
32 #include "Constraint_defs.hh"
34 #include "Generator_defs.hh"
35 #include "Variables_Set_defs.hh"
36 #include <vector>
37 #include <deque>
38 #include <iosfwd>
39 
40 namespace Parma_Polyhedra_Library {
41 
42 namespace IO_Operators {
43 
45 
46 std::ostream&
47 operator<<(std::ostream& s, const PIP_Problem& pip);
48 
49 } // namespace IO_Operators
50 
52 
53 void swap(PIP_Problem& x, PIP_Problem& y);
54 
55 } // namespace Parma_Polyhedra_Library
56 
58 
494 public:
496 
509  explicit PIP_Problem(dimension_type dim = 0);
510 
538  template <typename In>
539  PIP_Problem(dimension_type dim, In first, In last,
540  const Variables_Set& p_vars);
541 
543  PIP_Problem(const PIP_Problem& y);
544 
546  ~PIP_Problem();
547 
549  PIP_Problem& operator=(const PIP_Problem& y);
550 
553 
556 
562 
563 private:
565  typedef std::vector<Constraint> Constraint_Sequence;
566 
567 public:
572  typedef Constraint_Sequence::const_iterator const_iterator;
573 
578  const_iterator constraints_begin() const;
579 
584  const_iterator constraints_end() const;
585 
587 
590  void clear();
591 
615  dimension_type m_params);
616 
626 
634  void add_constraint(const Constraint& c);
635 
643  void add_constraints(const Constraint_System& cs);
644 
646 
650  bool is_satisfiable() const;
651 
653 
658  PIP_Problem_Status solve() const;
659 
661 
664  PIP_Tree solution() const;
665 
667 
671 
673  bool OK() const;
674 
676 
687  void print_solution(std::ostream& s, int indent = 0) const;
688 
690 
696  bool ascii_load(std::istream& s);
697 
700 
703 
705  void m_swap(PIP_Problem& y);
706 
713 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
714 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
717  };
718 
727 
732 
733 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
734 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
737  };
738 
742 
745 
748 
755 
756 private:
759 
761  void control_parameters_copy(const PIP_Problem& y);
762 
765 
771 
773  enum Status {
784  };
785 
788 
791 
793  Constraint_Sequence input_cs;
794 
797 
803 
804 #if PPL_USE_SPARSE_MATRIX
805  typedef Sparse_Row Row;
806 #else
807  typedef Dense_Row Row;
808 #endif
809 
816 
820 
826 
827  friend class PIP_Solution_Node;
828 };
829 
830 #include "PIP_Problem_inlines.hh"
831 #include "PIP_Problem_templates.hh"
832 
833 #endif // !defined(PPL_PIP_Problem_defs_hh)
PIP_Problem & operator=(const PIP_Problem &y)
Assignment operator.
dimension_type internal_space_dim
The space dimension of the current (partial) solution of the PIP problem; it may be smaller than exte...
const_iterator constraints_end() const
Returns a past-the-end read-only iterator to the sequence of constraints defining the feasible region...
A linear equality or inequality.
static dimension_type max_space_dimension()
Returns the maximum space dimension a PIP_Problem can handle.
void swap(CO_Tree &x, CO_Tree &y)
void add_constraint(const Constraint &c)
Adds a copy of constraint c to the PIP problem.
Definition: PIP_Problem.cc:697
A finite sequence of coefficients.
void set_control_parameter(Control_Parameter_Value value)
Sets control parameter value.
Definition: PIP_Problem.cc:729
size_t dimension_type
An unsigned integral type for representing space dimensions.
PIP_Problem(dimension_type dim=0)
Builds a trivial PIP problem.
Definition: PIP_Problem.cc:50
An std::set of variables' indexes.
void add_constraints(const Constraint_System &cs)
Adds a copy of the constraints in cs to the PIP problem.
Definition: PIP_Problem.cc:713
Variables_Set parameters
A set containing all the indices of space dimensions that are interpreted as problem parameters...
dimension_type external_space_dim
The dimension of the vector space.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
Definition: PIP_Problem.cc:453
PIP_Tree_Node * current_solution
The current solution decision tree.
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
bool OK() const
Checks if all the invariants are satisfied.
Definition: PIP_Problem.cc:277
A sparse matrix of Coefficient.
Definition: Matrix_defs.hh:37
A finite sparse sequence of coefficients.
Constraint_Sequence::const_iterator const_iterator
A type alias for the read-only iterator on the constraints defining the feasible region.
dimension_type space_dimension() const
Returns the space dimension of the PIP problem.
Choose the first row with negative parameter sign.
void set_big_parameter_dimension(dimension_type big_dim)
Sets the dimension for the big parameter to big_dim.
Definition: PIP_Problem.cc:750
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
Definition: PIP_Problem.cc:785
Status
An enumerated type describing the internal status of the PIP problem.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Definition: PIP_Problem.cc:766
A Parametric Integer (linear) Programming problem.
void m_swap(PIP_Problem &y)
Swaps *this with y.
void control_parameters_init()
Initializes the control parameters with default values.
Definition: PIP_Problem.cc:93
#define PPL_OUTPUT_DECLARATIONS
Constraint_Sequence input_cs
The sequence of constraints describing the feasible region.
Control_Parameter_Value control_parameters[CONTROL_PARAMETER_NAME_SIZE]
The control parameters for the problem object.
Control_Parameter_Value
Possible values for PIP_Problem control parameters.
const Variables_Set & parameter_space_dimensions() const
Returns a set containing all the variables' indexes representing the parameters of the PIP problem...
dimension_type first_pending_constraint
The first index of `input_cs' containing a pending constraint.
void control_parameters_copy(const PIP_Problem &y)
Copies the control parameters from problem object y.
Definition: PIP_Problem.cc:99
Status status
The internal state of the MIP problem.
The PIP problem is optimized; the solution tree has been computed.
Choose a row that generates a lexicographically maximal pivot column.
bool is_satisfiable() const
Checks satisfiability of *this.
Definition: PIP_Problem.cc:721
Coefficient value
Definition: PIP_Tree.cc:618
The feasible region of the PIP problem has been changed by adding new variables, parameters or constr...
PIP_Problem_Status
Possible outcomes of the PIP_Problem solver.
std::vector< Constraint > Constraint_Sequence
A type alias for a sequence of constraints.
The entire library is confined to this namespace.
Definition: version.hh:61
PIP_Problem_Status solve() const
Optimizes the PIP problem.
Definition: PIP_Problem.cc:106
dimension_type big_parameter_dimension
The dimension for the big parameter, or not_a_dimension() if not set.
Matrix< Row > initial_context
The initial context.
void clear()
Resets *this to be equal to the trivial PIP problem.
Definition: PIP_Problem.cc:614
PIP_Tree solution() const
Returns a feasible solution for *this, if it exists.
Definition: PIP_Problem.cc:261
Control_Parameter_Name
Possible names for PIP_Problem control parameters.
A tree node representing part of the space of solutions.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
Coefficient c
Definition: PIP_Tree.cc:64
dimension_type get_big_parameter_dimension() const
Returns the space dimension for the big parameter.
void add_to_parameter_space_dimensions(const Variables_Set &p_vars)
Sets the space dimensions whose indexes which are in set p_vars to be parameter space dimensions...
Definition: PIP_Problem.cc:670
const_iterator constraints_begin() const
Returns a read-only iterator to the first constraint defining the feasible region.
A node of the PIP solution tree.
Control_Parameter_Value get_control_parameter(Control_Parameter_Name name) const
Returns the value of control parameter name.
void add_space_dimensions_and_embed(dimension_type m_vars, dimension_type m_params)
Adds m_vars + m_params new space dimensions and embeds the old PIP problem in the new vector space...
Definition: PIP_Problem.cc:632
void print_solution(std::ostream &s, int indent=0) const
Prints on s the solution computed for *this.
Definition: PIP_Problem.cc:790
PIP_Tree optimizing_solution() const
Returns an optimizing solution for *this, if it exists.
Definition: PIP_Problem.cc:269