minor changes for various number types
authormarci
Tue, 04 Jan 2005 17:54:41 +0000
changeset 104838a49245a701
parent 1047 a6094968ed09
child 1049 e27446e1deda
minor changes for various number types
src/work/marci/lp/lp_solver_wrapper_2.h
     1.1 --- a/src/work/marci/lp/lp_solver_wrapper_2.h	Tue Jan 04 17:16:35 2005 +0000
     1.2 +++ b/src/work/marci/lp/lp_solver_wrapper_2.h	Tue Jan 04 17:54:41 2005 +0000
     1.3 @@ -159,9 +159,12 @@
     1.4  
     1.5    /*! \e
     1.6     */
     1.7 +  template <typename _Value>
     1.8    class LPSolverBase {
     1.9    public:
    1.10      /// \e
    1.11 +    typedef _Value Value;
    1.12 +    /// \e
    1.13      typedef IterablePartition<int>::ClassIt RowIt;
    1.14      /// \e
    1.15      typedef IterablePartition<int>::ClassIt ColIt;
    1.16 @@ -191,14 +194,14 @@
    1.17      virtual ColIt addCol() = 0;
    1.18      /// temporally, glpk style indexing
    1.19      virtual void setRowCoeffs(RowIt row_it, int num, 
    1.20 -			      int* indices, double* doubles) = 0;
    1.21 -    //pair<RowIt, double>-bol kell megadni egy std range-et
    1.22 +			      int* indices, _Value* doubles) = 0;
    1.23 +    //pair<RowIt, _Value>-bol kell megadni egy std range-et
    1.24      /// \e
    1.25      template <typename Begin, typename End>
    1.26      void setRowCoeffs(RowIt row_it, Begin begin, End end) {
    1.27        int mem_length=1+colNum();
    1.28        int* indices = new int[mem_length];
    1.29 -      double* doubles = new double[mem_length];
    1.30 +      _Value* doubles = new _Value[mem_length];
    1.31        int length=0;
    1.32        for ( ; begin!=end; ++begin) {
    1.33  	++length;
    1.34 @@ -211,14 +214,14 @@
    1.35      }
    1.36      /// temporally, glpk style indexing
    1.37      virtual void setColCoeffs(ColIt col_it, int num, 
    1.38 -			      int* indices, double* doubles) = 0;
    1.39 -    //pair<ColIt, double>-bol kell megadni egy std range-et
    1.40 +			      int* indices, _Value* doubles) = 0;
    1.41 +    //pair<ColIt, _Value>-bol kell megadni egy std range-et
    1.42      /// \e
    1.43      template <typename Begin, typename End>
    1.44      void setColCoeffs(ColIt col_it, Begin begin, End end) {
    1.45        int mem_length=1+rowNum();
    1.46        int* indices = new int[mem_length];
    1.47 -      double* doubles = new double[mem_length];
    1.48 +      _Value* doubles = new _Value[mem_length];
    1.49        int length=0;
    1.50        for ( ; begin!=end; ++begin) {
    1.51  	++length;
    1.52 @@ -235,14 +238,14 @@
    1.53      virtual void eraseRow(const RowIt& row_it) = 0;
    1.54      /// \e
    1.55      virtual void setColBounds(const ColIt& col_it, int bound_type, 
    1.56 -			      double lo, double up) =0; 
    1.57 +			      _Value lo, _Value up) =0; 
    1.58      /// \e
    1.59 -    virtual double getObjCoef(const ColIt& col_it) = 0;
    1.60 +    virtual _Value getObjCoef(const ColIt& col_it) = 0;
    1.61      /// \e
    1.62      virtual void setRowBounds(const RowIt& row_it, int bound_type, 
    1.63 -			      double lo, double up) = 0;
    1.64 +			      _Value lo, _Value up) = 0;
    1.65      /// \e
    1.66 -    virtual void setObjCoef(const ColIt& col_it, double obj_coef) = 0;
    1.67 +    virtual void setObjCoef(const ColIt& col_it, _Value obj_coef) = 0;
    1.68      /// \e
    1.69      virtual void solveSimplex() = 0;
    1.70      /// \e
    1.71 @@ -250,9 +253,9 @@
    1.72      /// \e
    1.73      virtual void solveDualSimplex() = 0;
    1.74      /// \e
    1.75 -    virtual double getPrimal(const ColIt& col_it) = 0;
    1.76 +    virtual _Value getPrimal(const ColIt& col_it) = 0;
    1.77      /// \e
    1.78 -    virtual double getObjVal() = 0;
    1.79 +    virtual _Value getObjVal() = 0;
    1.80      /// \e
    1.81      virtual int rowNum() const = 0;
    1.82      /// \e
    1.83 @@ -279,6 +282,7 @@
    1.84      virtual void printColStatus(int i) = 0;
    1.85    };
    1.86    
    1.87 +
    1.88    /// \brief Wrappers for LP solvers
    1.89    /// 
    1.90    /// This class implements a lemon wrapper for glpk.
    1.91 @@ -286,9 +290,9 @@
    1.92    /// The aim of this class is to give a general surface to different 
    1.93    /// solvers, i.e. it makes possible to write algorithms using LP's, 
    1.94    /// in which the solver can be changed to an other one easily.
    1.95 -  class LPSolverWrapper : public LPSolverBase {
    1.96 +  class LPSolverWrapper : public LPSolverBase<double> {
    1.97    public:
    1.98 -    typedef LPSolverBase Parent;
    1.99 +    typedef LPSolverBase<double> Parent;
   1.100  
   1.101      //   class Row {
   1.102      //   protected:
   1.103 @@ -323,7 +327,7 @@
   1.104  
   1.105    public:
   1.106      /// \e
   1.107 -    LPSolverWrapper() : LPSolverBase(), 
   1.108 +    LPSolverWrapper() : Parent(), 
   1.109  			lp(lpx_create_prob()) {
   1.110        lpx_set_int_parm(lp, LPX_K_DUAL, 1);
   1.111      }