PPL  0.12.1
PIP_Problem.defs.hh
Go to the documentation of this file.
00001 /* PIP_Problem class declaration.
00002    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
00003    Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com)
00004 
00005 This file is part of the Parma Polyhedra Library (PPL).
00006 
00007 The PPL is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 The PPL is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software Foundation,
00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
00020 
00021 For the most up-to-date information see the Parma Polyhedra Library
00022 site: http://bugseng.com/products/ppl/ . */
00023 
00024 #ifndef PPL_PIP_Problem_defs_hh
00025 #define PPL_PIP_Problem_defs_hh 1
00026 
00027 #include "PIP_Problem.types.hh"
00028 #include "PIP_Tree.types.hh"
00029 #include "globals.types.hh"
00030 #include "Linear_Expression.defs.hh"
00031 #include "Constraint.defs.hh"
00032 #include "Constraint_System.types.hh"
00033 #include "Generator.defs.hh"
00034 #include "Variables_Set.defs.hh"
00035 #include <vector>
00036 #include <deque>
00037 #include <iosfwd>
00038 
00039 #include "Row.defs.hh"
00040 #include "Matrix.defs.hh"
00041 
00042 namespace Parma_Polyhedra_Library {
00043 
00044 namespace IO_Operators {
00045 
00047 
00048 std::ostream&
00049 operator<<(std::ostream& s, const PIP_Problem& pip);
00050 
00051 } // namespace IO_Operators
00052 
00054 
00055 void swap(PIP_Problem& x, PIP_Problem& y);
00056 
00057 } // namespace Parma_Polyhedra_Library
00058 
00060 
00495 class Parma_Polyhedra_Library::PIP_Problem {
00496 public:
00498 
00511   explicit PIP_Problem(dimension_type dim = 0);
00512 
00540   template <typename In>
00541   PIP_Problem(dimension_type dim, In first, In last,
00542               const Variables_Set& p_vars);
00543 
00545   PIP_Problem(const PIP_Problem& y);
00546 
00548   ~PIP_Problem();
00549 
00551   PIP_Problem& operator=(const PIP_Problem& y);
00552 
00554   static dimension_type max_space_dimension();
00555 
00557   dimension_type space_dimension() const;
00558 
00563   const Variables_Set& parameter_space_dimensions() const;
00564 
00565 private:
00567   typedef std::vector<Constraint> Constraint_Sequence;
00568 
00569 public:
00574   typedef Constraint_Sequence::const_iterator const_iterator;
00575 
00580   const_iterator constraints_begin() const;
00581 
00586   const_iterator constraints_end() const;
00587 
00589 
00592   void clear();
00593 
00616   void add_space_dimensions_and_embed(dimension_type m_vars,
00617                                       dimension_type m_params);
00618 
00627   void add_to_parameter_space_dimensions(const Variables_Set& p_vars);
00628 
00636   void add_constraint(const Constraint& c);
00637 
00645   void add_constraints(const Constraint_System& cs);
00646 
00648 
00652   bool is_satisfiable() const;
00653 
00655 
00660   PIP_Problem_Status solve() const;
00661 
00663 
00666   PIP_Tree solution() const;
00667 
00669 
00672   PIP_Tree optimizing_solution() const;
00673 
00675   bool OK() const;
00676 
00678 
00689   void print_solution(std::ostream& s, int indent = 0) const;
00690 
00691   PPL_OUTPUT_DECLARATIONS
00692 
00698   bool ascii_load(std::istream& s);
00699 
00701   memory_size_type total_memory_in_bytes() const;
00702 
00704   memory_size_type external_memory_in_bytes() const;
00705 
00707   void m_swap(PIP_Problem& y);
00708 
00710   enum Control_Parameter_Name {
00712     CUTTING_STRATEGY,
00714     PIVOT_ROW_STRATEGY,
00715 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00716 
00717 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00718     CONTROL_PARAMETER_NAME_SIZE
00719   };
00720 
00722   enum Control_Parameter_Value {
00724     CUTTING_STRATEGY_FIRST,
00726     CUTTING_STRATEGY_DEEPEST,
00728     CUTTING_STRATEGY_ALL,
00729 
00731     PIVOT_ROW_STRATEGY_FIRST,
00733     PIVOT_ROW_STRATEGY_MAX_COLUMN,
00734 
00735 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00736 
00737 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00738     CONTROL_PARAMETER_VALUE_SIZE
00739   };
00740 
00742   Control_Parameter_Value
00743   get_control_parameter(Control_Parameter_Name name) const;
00744 
00746   void set_control_parameter(Control_Parameter_Value value);
00747 
00749   void set_big_parameter_dimension(dimension_type big_dim);
00750 
00756   dimension_type get_big_parameter_dimension() const;
00757 
00758 private:
00760   void control_parameters_init();
00761 
00763   void control_parameters_copy(const PIP_Problem& y);
00764 
00766   dimension_type external_space_dim;
00767 
00772   dimension_type internal_space_dim;
00773 
00775   enum Status {
00777     UNSATISFIABLE,
00779     OPTIMIZED,
00785     PARTIALLY_SATISFIABLE
00786   };
00787 
00789   Status status;
00790 
00792   PIP_Tree_Node* current_solution;
00793 
00795   Constraint_Sequence input_cs;
00796 
00798   dimension_type first_pending_constraint;
00799 
00804   Variables_Set parameters;
00805 
00811   Matrix initial_context;
00812 
00814   Control_Parameter_Value
00815   control_parameters[CONTROL_PARAMETER_NAME_SIZE];
00816 
00821   dimension_type big_parameter_dimension;
00822 
00823   friend class PIP_Solution_Node;
00824 };
00825 
00826 #include "PIP_Problem.inlines.hh"
00827 #include "PIP_Problem.templates.hh"
00828 
00829 #endif // !defined(PPL_PIP_Problem_defs_hh)