lemon/lp_base.h
changeset 666 d10545c08e61
parent 568 745e182d0139
child 761 f1398882a928
child 766 2eebc8f7dca5
equal deleted inserted replaced
7:f3fed658d59b 8:6f18bf0a0c0f
    50 
    50 
    51   public:
    51   public:
    52 
    52 
    53     ///Possible outcomes of an LP solving procedure
    53     ///Possible outcomes of an LP solving procedure
    54     enum SolveExitStatus {
    54     enum SolveExitStatus {
    55       ///This means that the problem has been successfully solved: either
    55       /// = 0. It means that the problem has been successfully solved: either
    56       ///an optimal solution has been found or infeasibility/unboundedness
    56       ///an optimal solution has been found or infeasibility/unboundedness
    57       ///has been proved.
    57       ///has been proved.
    58       SOLVED = 0,
    58       SOLVED = 0,
    59       ///Any other case (including the case when some user specified
    59       /// = 1. Any other case (including the case when some user specified
    60       ///limit has been exceeded)
    60       ///limit has been exceeded).
    61       UNSOLVED = 1
    61       UNSOLVED = 1
    62     };
    62     };
    63 
    63 
    64     ///Direction of the optimization
    64     ///Direction of the optimization
    65     enum Sense {
    65     enum Sense {
    69       MAX
    69       MAX
    70     };
    70     };
    71 
    71 
    72     ///Enum for \c messageLevel() parameter
    72     ///Enum for \c messageLevel() parameter
    73     enum MessageLevel {
    73     enum MessageLevel {
    74       /// no output (default value)
    74       /// No output (default value).
    75       MESSAGE_NOTHING,
    75       MESSAGE_NOTHING,
    76       /// error messages only
    76       /// Error messages only.
    77       MESSAGE_ERROR,
    77       MESSAGE_ERROR,
    78       /// warnings
    78       /// Warnings.
    79       MESSAGE_WARNING,
    79       MESSAGE_WARNING,
    80       /// normal output
    80       /// Normal output.
    81       MESSAGE_NORMAL,
    81       MESSAGE_NORMAL,
    82       /// verbose output
    82       /// Verbose output.
    83       MESSAGE_VERBOSE
    83       MESSAGE_VERBOSE
    84     };
    84     };
    85     
    85     
    86 
    86 
    87     ///The floating point type used by the solver
    87     ///The floating point type used by the solver
  1003     virtual ~LpBase() {}
  1003     virtual ~LpBase() {}
  1004 
  1004 
  1005     ///Gives back the name of the solver.
  1005     ///Gives back the name of the solver.
  1006     const char* solverName() const {return _solverName();}
  1006     const char* solverName() const {return _solverName();}
  1007 
  1007 
  1008     ///\name Build up and modify the LP
  1008     ///\name Build Up and Modify the LP
  1009 
  1009 
  1010     ///@{
  1010     ///@{
  1011 
  1011 
  1012     ///Add a new empty column (i.e a new variable) to the LP
  1012     ///Add a new empty column (i.e a new variable) to the LP
  1013     Col addCol() { Col c; c._id = _addColId(_addCol()); return c;}
  1013     Col addCol() { Col c; c._id = _addColId(_addCol()); return c;}
  1786   class LpSolver : virtual public LpBase {
  1786   class LpSolver : virtual public LpBase {
  1787   public:
  1787   public:
  1788 
  1788 
  1789     /// The problem types for primal and dual problems
  1789     /// The problem types for primal and dual problems
  1790     enum ProblemType {
  1790     enum ProblemType {
  1791       ///Feasible solution hasn't been found (but may exist).
  1791       /// = 0. Feasible solution hasn't been found (but may exist).
  1792       UNDEFINED = 0,
  1792       UNDEFINED = 0,
  1793       ///The problem has no feasible solution
  1793       /// = 1. The problem has no feasible solution.
  1794       INFEASIBLE = 1,
  1794       INFEASIBLE = 1,
  1795       ///Feasible solution found
  1795       /// = 2. Feasible solution found.
  1796       FEASIBLE = 2,
  1796       FEASIBLE = 2,
  1797       ///Optimal solution exists and found
  1797       /// = 3. Optimal solution exists and found.
  1798       OPTIMAL = 3,
  1798       OPTIMAL = 3,
  1799       ///The cost function is unbounded
  1799       /// = 4. The cost function is unbounded.
  1800       UNBOUNDED = 4
  1800       UNBOUNDED = 4
  1801     };
  1801     };
  1802 
  1802 
  1803     ///The basis status of variables
  1803     ///The basis status of variables
  1804     enum VarStatus {
  1804     enum VarStatus {
  1850     ///\ref SolveExitStatus.
  1850     ///\ref SolveExitStatus.
  1851     SolveExitStatus solve() { return _solve(); }
  1851     SolveExitStatus solve() { return _solve(); }
  1852 
  1852 
  1853     ///@}
  1853     ///@}
  1854 
  1854 
  1855     ///\name Obtain the solution
  1855     ///\name Obtain the Solution
  1856 
  1856 
  1857     ///@{
  1857     ///@{
  1858 
  1858 
  1859     /// The type of the primal problem
  1859     /// The type of the primal problem
  1860     ProblemType primalType() const {
  1860     ProblemType primalType() const {
  1972   class MipSolver : virtual public LpBase {
  1972   class MipSolver : virtual public LpBase {
  1973   public:
  1973   public:
  1974 
  1974 
  1975     /// The problem types for MIP problems
  1975     /// The problem types for MIP problems
  1976     enum ProblemType {
  1976     enum ProblemType {
  1977       ///Feasible solution hasn't been found (but may exist).
  1977       /// = 0. Feasible solution hasn't been found (but may exist).
  1978       UNDEFINED = 0,
  1978       UNDEFINED = 0,
  1979       ///The problem has no feasible solution
  1979       /// = 1. The problem has no feasible solution.
  1980       INFEASIBLE = 1,
  1980       INFEASIBLE = 1,
  1981       ///Feasible solution found
  1981       /// = 2. Feasible solution found.
  1982       FEASIBLE = 2,
  1982       FEASIBLE = 2,
  1983       ///Optimal solution exists and found
  1983       /// = 3. Optimal solution exists and found.
  1984       OPTIMAL = 3,
  1984       OPTIMAL = 3,
  1985       ///The cost function is unbounded
  1985       /// = 4. The cost function is unbounded.
  1986       ///
  1986       ///The Mip or at least the relaxed problem is unbounded.
  1987       ///The Mip or at least the relaxed problem is unbounded
       
  1988       UNBOUNDED = 4
  1987       UNBOUNDED = 4
  1989     };
  1988     };
  1990 
  1989 
  1991     ///Allocate a new MIP problem instance
  1990     ///Allocate a new MIP problem instance
  1992     virtual MipSolver* newSolver() const = 0;
  1991     virtual MipSolver* newSolver() const = 0;
  2004     ///\ref SolveExitStatus.
  2003     ///\ref SolveExitStatus.
  2005     SolveExitStatus solve() { return _solve(); }
  2004     SolveExitStatus solve() { return _solve(); }
  2006 
  2005 
  2007     ///@}
  2006     ///@}
  2008 
  2007 
  2009     ///\name Setting column type
  2008     ///\name Set Column Type
  2010     ///@{
  2009     ///@{
  2011 
  2010 
  2012     ///Possible variable (column) types (e.g. real, integer, binary etc.)
  2011     ///Possible variable (column) types (e.g. real, integer, binary etc.)
  2013     enum ColTypes {
  2012     enum ColTypes {
  2014       ///Continuous variable (default)
  2013       /// = 0. Continuous variable (default).
  2015       REAL = 0,
  2014       REAL = 0,
  2016       ///Integer variable
  2015       /// = 1. Integer variable.
  2017       INTEGER = 1
  2016       INTEGER = 1
  2018     };
  2017     };
  2019 
  2018 
  2020     ///Sets the type of the given column to the given type
  2019     ///Sets the type of the given column to the given type
  2021 
  2020 
  2032     ColTypes colType(Col c) const {
  2031     ColTypes colType(Col c) const {
  2033       return _getColType(cols(id(c)));
  2032       return _getColType(cols(id(c)));
  2034     }
  2033     }
  2035     ///@}
  2034     ///@}
  2036 
  2035 
  2037     ///\name Obtain the solution
  2036     ///\name Obtain the Solution
  2038 
  2037 
  2039     ///@{
  2038     ///@{
  2040 
  2039 
  2041     /// The type of the MIP problem
  2040     /// The type of the MIP problem
  2042     ProblemType type() const {
  2041     ProblemType type() const {