COIN-OR::LEMON - Graph Library

Ticket #326: 326-lp-mip-1e16e62a9ea1.patch

File 326-lp-mip-1e16e62a9ea1.patch, 10.6 KB (added by Peter Kovacs, 9 years ago)

Clarified version

  • lemon/lp_base.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1267516057 -3600
    # Node ID 1e16e62a9ea12b735e6c63bbd8905bd93f5a1ba9
    # Parent  e77b621e6e7ecd5a325e1546bdfd51aa01c7b395
    Unify the interface of MipSolver and LpSolver (#326)
    and improve the documentation.
    
     - Add sol() (without parameters) to MipSolver as an alias for solValue(),
       since we had primal() instead of primalValue() in LpSolver.
     - Add primalValue() to LpSolver as an alias for primal() (without
       parameters).
     - Rename ColTypes to ColType in MipSolver and keep the old name as an
       obsolete alias (typedef).
     - Doc improvements and unifications.
    
    diff --git a/lemon/lp_base.h b/lemon/lp_base.h
    a b  
    17901790  ///
    17911791  /// \brief Common base class for LP solvers
    17921792  ///
    1793   /// This class is an abstract base class for LP solvers. This class
     1793  /// This class is an abstract base class for LP solvers. It
    17941794  /// provides a full interface for set and modify an LP problem,
    17951795  /// solve it and retrieve the solution. You can use one of the
    17961796  /// descendants as a concrete implementation, or the \c Lp
     
    18001800  class LpSolver : virtual public LpBase {
    18011801  public:
    18021802
    1803     /// The problem types for primal and dual problems
     1803    /// \brief The problem types for primal and dual problems
     1804    ///
     1805    /// The problem types for primal and dual problems.
    18041806    enum ProblemType {
    18051807      /// = 0. Feasible solution hasn't been found (but may exist).
    18061808      UNDEFINED = 0,
     
    18141816      UNBOUNDED = 4
    18151817    };
    18161818
    1817     ///The basis status of variables
     1819    /// \brief The basis status of variables
     1820    ///
     1821    /// The basis status of variables.
    18181822    enum VarStatus {
    18191823      /// The variable is in the basis
    18201824      BASIC,
     
    18571861
    18581862    ///@{
    18591863
    1860     ///\e Solve the LP problem at hand
     1864    ///\brief Solve the specified LP problem
    18611865    ///
     1866    ///This function solves the specified LP problem.
    18621867    ///\return The result of the optimization procedure. Possible
    18631868    ///values and their meanings can be found in the documentation of
    18641869    ///\ref SolveExitStatus.
     
    18701875
    18711876    ///@{
    18721877
    1873     /// The type of the primal problem
     1878    /// Return the type of the primal problem
     1879
     1880    /// This function returns the type of the primal problem.
     1881    /// \see ProblemType
    18741882    ProblemType primalType() const {
    18751883      return _getPrimalType();
    18761884    }
    18771885
    1878     /// The type of the dual problem
     1886    /// Return the type of the dual problem
     1887
     1888    /// This function returns the type of the dual problem.
     1889    /// \see ProblemType
    18791890    ProblemType dualType() const {
    18801891      return _getDualType();
    18811892    }
    18821893
     1894    /// Return the primal value of the objective function
     1895   
     1896    /// This function returns the primal value of the objective function.
     1897    /// \return
     1898    /// - \ref INF or -\ref INF means either infeasibility or unboundedness
     1899    ///   of the primal problem, depending on whether we minimize or maximize.
     1900    /// - \ref NaN if no primal solution is found.
     1901    /// - The (finite) objective value if an optimal solution is found.
     1902    Value primalValue() const { return _getPrimalValue()+obj_const_comp;}
     1903
     1904    /// Return the primal value of the objective function
     1905
     1906    /// This function returns the primal value of the objective function.
     1907    /// It is an alias for \ref primalValue().
     1908    Value primal() const { return _getPrimalValue()+obj_const_comp;}
     1909
    18831910    /// Return the primal value of the column
    18841911
    1885     /// Return the primal value of the column.
     1912    /// This function returns the primal value of the given column.
    18861913    /// \pre The problem is solved.
    18871914    Value primal(Col c) const { return _getPrimal(cols(id(c))); }
    18881915
    18891916    /// Return the primal value of the expression
    18901917
    1891     /// Return the primal value of the expression, i.e. the dot
    1892     /// product of the primal solution and the expression.
     1918    /// This function returns the primal value of the given expression,
     1919    /// i.e. the dot product of the primal solution and the expression.
    18931920    /// \pre The problem is solved.
    18941921    Value primal(const Expr& e) const {
    18951922      double res = *e;
     
    18981925      }
    18991926      return res;
    19001927    }
    1901     /// Returns a component of the primal ray
     1928
     1929    /// Return a component of the primal ray
    19021930   
    19031931    /// The primal ray is solution of the modified primal problem,
    19041932    /// where we change each finite bound to 0, and we looking for a
     
    19151943
    19161944    /// Return the dual value of the row
    19171945
    1918     /// Return the dual value of the row.
     1946    /// This function returns the dual value of the given row.
    19191947    /// \pre The problem is solved.
    19201948    Value dual(Row r) const { return _getDual(rows(id(r))); }
    19211949
    19221950    /// Return the dual value of the dual expression
    19231951
    1924     /// Return the dual value of the dual expression, i.e. the dot
    1925     /// product of the dual solution and the dual expression.
     1952    /// This function returns the dual value of the given dual expression,
     1953    /// i.e. the dot product of the dual solution and the dual expression.
    19261954    /// \pre The problem is solved.
    19271955    Value dual(const DualExpr& e) const {
    19281956      double res = 0.0;
     
    19321960      return res;
    19331961    }
    19341962
    1935     /// Returns a component of the dual ray
     1963    /// Return a component of the dual ray
    19361964   
    19371965    /// The dual ray is solution of the modified primal problem, where
    19381966    /// we change each finite bound to 0 (i.e. the objective function
     
    19491977
    19501978    /// Return the basis status of the column
    19511979
     1980    /// This function returns the basis status of the column.
    19521981    /// \see VarStatus
    19531982    VarStatus colStatus(Col c) const { return _getColStatus(cols(id(c))); }
    19541983
    19551984    /// Return the basis status of the row
    19561985
     1986    /// This function returns the basis status of the row.
    19571987    /// \see VarStatus
    19581988    VarStatus rowStatus(Row r) const { return _getRowStatus(rows(id(r))); }
    1959 
    1960     ///The value of the objective function
    1961 
    1962     ///\return
    1963     ///- \ref INF or -\ref INF means either infeasibility or unboundedness
    1964     /// of the primal problem, depending on whether we minimize or maximize.
    1965     ///- \ref NaN if no primal solution is found.
    1966     ///- The (finite) objective value if an optimal solution is found.
    1967     Value primal() const { return _getPrimalValue()+obj_const_comp;}
    19681989    ///@}
    19691990
    1970   protected:
    1971 
    19721991  };
    19731992
    19741993
     
    19761995  ///
    19771996  /// \brief Common base class for MIP solvers
    19781997  ///
    1979   /// This class is an abstract base class for MIP solvers. This class
     1998  /// This class is an abstract base class for MIP solvers. It
    19801999  /// provides a full interface for set and modify an MIP problem,
    19812000  /// solve it and retrieve the solution. You can use one of the
    19822001  /// descendants as a concrete implementation, or the \c Lp
     
    19862005  class MipSolver : virtual public LpBase {
    19872006  public:
    19882007
    1989     /// The problem types for MIP problems
     2008    /// \brief The problem types for MIP problems
     2009    ///
     2010    /// The problem types for MIP problems.
    19902011    enum ProblemType {
    19912012      /// = 0. Feasible solution hasn't been found (but may exist).
    19922013      UNDEFINED = 0,
     
    20102031
    20112032    ///@{
    20122033
    2013     /// Solve the MIP problem at hand
     2034    ///\brief Solve the specified MIP problem
    20142035    ///
     2036    ///This function solves the specified MIP problem.
    20152037    ///\return The result of the optimization procedure. Possible
    20162038    ///values and their meanings can be found in the documentation of
    20172039    ///\ref SolveExitStatus.
     
    20222044    ///\name Set Column Type
    20232045    ///@{
    20242046
    2025     ///Possible variable (column) types (e.g. real, integer, binary etc.)
    2026     enum ColTypes {
     2047    /// The column types for MIP problems.
     2048
     2049    /// The column (variable) types for MIP problems.
     2050    ///
     2051    enum ColType {
    20272052      /// = 0. Continuous variable (default).
    20282053      REAL = 0,
    20292054      /// = 1. Integer variable.
    20302055      INTEGER = 1
    20312056    };
    20322057
     2058    /// \brief The column types for MIP problems. It is an obsolete alias for
     2059    /// \ref ColType.
     2060    typedef ColType ColTypes;
     2061
    20332062    ///Sets the type of the given column to the given type
    20342063
    2035     ///Sets the type of the given column to the given type.
     2064    ///This function sets the type of the given column to the given type.
    20362065    ///
    20372066    void colType(Col c, ColTypes col_type) {
    20382067      _setColType(cols(id(c)),col_type);
     
    20402069
    20412070    ///Gives back the type of the column.
    20422071
    2043     ///Gives back the type of the column.
     2072    ///This function gives back the type of the column.
    20442073    ///
    20452074    ColTypes colType(Col c) const {
    20462075      return _getColType(cols(id(c)));
     
    20512080
    20522081    ///@{
    20532082
    2054     /// The type of the MIP problem
     2083    /// Return the type of the MIP problem
     2084
     2085    /// This function returns the type of the MIP problem.
     2086    /// \see ProblemType
    20552087    ProblemType type() const {
    20562088      return _getType();
    20572089    }
    20582090
    2059     /// Return the value of the row in the solution
     2091    /// Return the value of the objective function
     2092   
     2093    /// This function returns the value of the objective function.
     2094    /// \return
     2095    /// - \ref INF or -\ref INF means either infeasibility or unboundedness
     2096    ///   of the problem, depending on whether we minimize or maximize.
     2097    /// - \ref NaN if no primal solution is found.
     2098    /// - The (finite) objective value if an optimal solution is found.
     2099    Value solValue() const { return _getSolValue()+obj_const_comp;}
    20602100
    2061     ///  Return the value of the row in the solution.
     2101    /// Return the value of the objective function
     2102   
     2103    /// This function returns value of the objective function.
     2104    /// It is an alias for \ref solValue().
     2105    Value sol() const { return _getSolValue()+obj_const_comp;}
     2106
     2107    /// Return the value of the column
     2108
     2109    /// This function returns the value of the given column in the solution.
    20622110    /// \pre The problem is solved.
    20632111    Value sol(Col c) const { return _getSol(cols(id(c))); }
    20642112
    2065     /// Return the value of the expression in the solution
     2113    /// Return the value of the expression
    20662114
    2067     /// Return the value of the expression in the solution, i.e. the
    2068     /// dot product of the solution and the expression.
     2115    /// This function returns the value of the given expression in the solution,
     2116    /// i.e. the dot product of the solution and the expression.
    20692117    /// \pre The problem is solved.
    20702118    Value sol(const Expr& e) const {
    20712119      double res = *e;
     
    20742122      }
    20752123      return res;
    20762124    }
    2077     ///The value of the objective function
    2078    
    2079     ///\return
    2080     ///- \ref INF or -\ref INF means either infeasibility or unboundedness
    2081     /// of the problem, depending on whether we minimize or maximize.
    2082     ///- \ref NaN if no primal solution is found.
    2083     ///- The (finite) objective value if an optimal solution is found.
    2084     Value solValue() const { return _getSolValue()+obj_const_comp;}
     2125
    20852126    ///@}
    20862127
    20872128  protected: