Using const in lp interface
authordeba
Fri, 16 Feb 2007 19:11:31 +0000
changeset 2366bfbdded3763a
parent 2365 751a14b992f2
child 2367 041878e6f388
Using const in lp interface
colByName functionality
lemon/lp_base.h
lemon/lp_cplex.cc
lemon/lp_cplex.h
lemon/lp_glpk.cc
lemon/lp_glpk.h
lemon/lp_skeleton.cc
lemon/lp_skeleton.h
lemon/lp_soplex.cc
lemon/lp_soplex.h
lemon/mip_cplex.cc
lemon/mip_cplex.h
lemon/mip_glpk.cc
lemon/mip_glpk.h
     1.1 --- a/lemon/lp_base.h	Fri Feb 16 15:57:48 2007 +0000
     1.2 +++ b/lemon/lp_base.h	Fri Feb 16 19:11:31 2007 +0000
     1.3 @@ -135,10 +135,10 @@
     1.4      };
     1.5  
     1.6      class ColIt : public Col {
     1.7 -      LpSolverBase *_lp;
     1.8 +      const LpSolverBase *_lp;
     1.9      public:
    1.10        ColIt() {}
    1.11 -      ColIt(LpSolverBase &lp) : _lp(&lp)
    1.12 +      ColIt(const LpSolverBase &lp) : _lp(&lp)
    1.13        {
    1.14          _lp->cols.firstFix(id);
    1.15        }
    1.16 @@ -180,10 +180,10 @@
    1.17      };
    1.18  
    1.19      class RowIt : public Row {
    1.20 -      LpSolverBase *_lp;
    1.21 +      const LpSolverBase *_lp;
    1.22      public:
    1.23        RowIt() {}
    1.24 -      RowIt(LpSolverBase &lp) : _lp(&lp)
    1.25 +      RowIt(const LpSolverBase &lp) : _lp(&lp)
    1.26        {
    1.27          _lp->rows.firstFix(id);
    1.28        }
    1.29 @@ -735,45 +735,47 @@
    1.30  
    1.31      virtual int _addCol() = 0;
    1.32      virtual int _addRow() = 0; 
    1.33 +
    1.34      virtual void _eraseCol(int col) = 0;
    1.35      virtual void _eraseRow(int row) = 0;
    1.36 -    virtual void _getColName(int col, std::string & name) = 0;
    1.37 +
    1.38 +    virtual void _getColName(int col, std::string & name) const = 0;
    1.39      virtual void _setColName(int col, const std::string & name) = 0;
    1.40 +    virtual int _colByName(const std::string& name) const = 0;
    1.41 +
    1.42      virtual void _setRowCoeffs(int i, ConstRowIterator b, 
    1.43                                 ConstRowIterator e) = 0;
    1.44 -    virtual void _getRowCoeffs(int i, RowIterator b) = 0;
    1.45 +    virtual void _getRowCoeffs(int i, RowIterator b) const = 0;
    1.46      virtual void _setColCoeffs(int i, ConstColIterator b, 
    1.47                                 ConstColIterator e) = 0;
    1.48 -    virtual void _getColCoeffs(int i, ColIterator b) = 0;
    1.49 +    virtual void _getColCoeffs(int i, ColIterator b) const = 0;
    1.50      virtual void _setCoeff(int row, int col, Value value) = 0;
    1.51 -    virtual Value _getCoeff(int row, int col) = 0;
    1.52 +    virtual Value _getCoeff(int row, int col) const = 0;
    1.53      virtual void _setColLowerBound(int i, Value value) = 0;
    1.54 -    virtual Value _getColLowerBound(int i) = 0;
    1.55 +    virtual Value _getColLowerBound(int i) const = 0;
    1.56      virtual void _setColUpperBound(int i, Value value) = 0;
    1.57 -    virtual Value _getColUpperBound(int i) = 0;
    1.58 +    virtual Value _getColUpperBound(int i) const = 0;
    1.59      virtual void _setRowBounds(int i, Value lower, Value upper) = 0;
    1.60 -    virtual void _getRowBounds(int i, Value &lower, Value &upper)=0;
    1.61 +    virtual void _getRowBounds(int i, Value &lower, Value &upper) const = 0;
    1.62  
    1.63      virtual void _setObjCoeff(int i, Value obj_coef) = 0;
    1.64 -    virtual Value _getObjCoeff(int i) = 0;
    1.65 +    virtual Value _getObjCoeff(int i) const = 0;
    1.66      virtual void _clearObj()=0;
    1.67  
    1.68      virtual SolveExitStatus _solve() = 0;
    1.69 -    virtual Value _getPrimal(int i) = 0;
    1.70 -    virtual Value _getDual(int i) = 0;
    1.71 -    virtual Value _getPrimalValue() = 0;
    1.72 -    virtual bool _isBasicCol(int i) = 0;
    1.73 -    virtual SolutionStatus _getPrimalStatus() = 0;
    1.74 -    virtual SolutionStatus _getDualStatus() = 0;
    1.75 -    ///\todo This could be implemented here, too, using _getPrimalStatus() and
    1.76 -    ///_getDualStatus()
    1.77 -    virtual ProblemTypes _getProblemType() = 0;
    1.78 +    virtual Value _getPrimal(int i) const = 0;
    1.79 +    virtual Value _getDual(int i) const = 0;
    1.80 +    virtual Value _getPrimalValue() const = 0;
    1.81 +    virtual bool _isBasicCol(int i) const = 0;
    1.82 +    virtual SolutionStatus _getPrimalStatus() const = 0;
    1.83 +    virtual SolutionStatus _getDualStatus() const = 0;
    1.84 +    virtual ProblemTypes _getProblemType() const = 0;
    1.85  
    1.86      virtual void _setMax() = 0;
    1.87      virtual void _setMin() = 0;
    1.88      
    1.89  
    1.90 -    virtual bool _isMax() = 0;
    1.91 +    virtual bool _isMax() const = 0;
    1.92  
    1.93      //Own protected stuff
    1.94      
    1.95 @@ -877,7 +879,7 @@
    1.96  
    1.97      ///\param r is the column to get
    1.98      ///\return the dual expression associated to the column
    1.99 -    DualExpr col(Col c) {
   1.100 +    DualExpr col(Col c) const {
   1.101        DualExpr e;
   1.102        _getColCoeffs(_lpId(c), ColIterator(std::inserter(e, e.end()), *this));
   1.103        return e;
   1.104 @@ -974,7 +976,7 @@
   1.105      ///a better one.
   1.106      ///\todo Option to control whether a constraint with a single variable is
   1.107      ///added or not.
   1.108 -    void row(Row r, Value l,const Expr &e, Value u) {
   1.109 +    void row(Row r, Value l, const Expr &e, Value u) {
   1.110        e.simplify();
   1.111        _setRowCoeffs(_lpId(r), ConstRowIterator(e.begin(), *this),
   1.112                      ConstRowIterator(e.end(), *this));
   1.113 @@ -995,7 +997,7 @@
   1.114  
   1.115      ///\param r is the row to get
   1.116      ///\return the expression associated to the row
   1.117 -    Expr row(Row r) {
   1.118 +    Expr row(Row r) const {
   1.119        Expr e;
   1.120        _getRowCoeffs(_lpId(r), RowIterator(std::inserter(e, e.end()), *this));
   1.121        return e;
   1.122 @@ -1045,7 +1047,7 @@
   1.123      
   1.124      ///\param c is the coresponding coloumn 
   1.125      ///\return The name of the colunm
   1.126 -    std::string colName(Col c){
   1.127 +    std::string colName(Col c) const {
   1.128        std::string name;
   1.129        _getColName(_lpId(c), name);
   1.130        return name;
   1.131 @@ -1055,7 +1057,7 @@
   1.132      
   1.133      ///\param c is the coresponding coloumn 
   1.134      ///\param name The name to be given
   1.135 -    void colName(Col c, const std::string& name){
   1.136 +    void colName(Col c, const std::string& name) {
   1.137        _setColName(_lpId(c), name);
   1.138      }
   1.139      
   1.140 @@ -1065,7 +1067,7 @@
   1.141      ///\param c is the coloumn of the element to be modified
   1.142      ///\param val is the new value of the coefficient
   1.143  
   1.144 -    void coeff(Row r, Col c, Value val){
   1.145 +    void coeff(Row r, Col c, Value val) {
   1.146        _setCoeff(_lpId(r),_lpId(c), val);
   1.147      }
   1.148  
   1.149 @@ -1075,7 +1077,7 @@
   1.150      ///\param c is the coloumn of the element in question
   1.151      ///\return the corresponding coefficient
   1.152  
   1.153 -    Value coeff(Row r, Col c){
   1.154 +    Value coeff(Row r, Col c) const {
   1.155        return _getCoeff(_lpId(r),_lpId(c));
   1.156      }
   1.157  
   1.158 @@ -1093,7 +1095,7 @@
   1.159      /// This function returns the lower bound for column (variable) \t c
   1.160      /// (this might be -\ref INF as well).  
   1.161      ///\return The lower bound for coloumn \t c
   1.162 -    Value colLowerBound(Col c) {
   1.163 +    Value colLowerBound(Col c) const {
   1.164        return _getColLowerBound(_lpId(c));
   1.165      }
   1.166      
   1.167 @@ -1148,7 +1150,7 @@
   1.168      /// This function returns the upper bound for column (variable) \t c
   1.169      /// (this might be \ref INF as well).  
   1.170      ///\return The upper bound for coloumn \t c
   1.171 -    Value colUpperBound(Col c) {
   1.172 +    Value colUpperBound(Col c) const {
   1.173        return _getColUpperBound(_lpId(c));
   1.174      }
   1.175  
   1.176 @@ -1260,7 +1262,7 @@
   1.177      /// lower and the upper bound because we had problems with the 
   1.178      /// implementation of the setting functions for CPLEX:  
   1.179      /// check out whether this can be done for these functions.
   1.180 -    void getRowBounds(Row c, Value &lower, Value &upper) {
   1.181 +    void getRowBounds(Row c, Value &lower, Value &upper) const {
   1.182        _getRowBounds(_lpId(c),lower, upper);
   1.183      }
   1.184  
   1.185 @@ -1268,7 +1270,7 @@
   1.186      void objCoeff(Col c, Value v) {_setObjCoeff(_lpId(c),v); };
   1.187  
   1.188      ///Get an element of the objective function
   1.189 -    Value objCoeff(Col c) {return _getObjCoeff(_lpId(c)); };
   1.190 +    Value objCoeff(Col c) const { return _getObjCoeff(_lpId(c)); };
   1.191  
   1.192      ///Set the objective function
   1.193  
   1.194 @@ -1284,7 +1286,7 @@
   1.195      ///Get the objective function
   1.196  
   1.197      ///\return the objective function as a linear expression of type \ref Expr.
   1.198 -    Expr obj() {
   1.199 +    Expr obj() const {
   1.200        Expr e;
   1.201        for (ColIt it(*this); it != INVALID; ++it) {
   1.202          double c = objCoeff(it);
   1.203 @@ -1302,10 +1304,10 @@
   1.204      void min() { _setMin(); }
   1.205  
   1.206      ///Query function: is this a maximization problem?
   1.207 -    bool is_max() {return _isMax(); }
   1.208 +    bool is_max() const {return _isMax(); }
   1.209  
   1.210      ///Query function: is this a minimization problem?
   1.211 -    bool is_min() {return !is_max(); }
   1.212 +    bool is_min() const {return !is_max(); }
   1.213      
   1.214      ///@}
   1.215  
   1.216 @@ -1330,28 +1332,28 @@
   1.217      ///@{
   1.218  
   1.219      /// The status of the primal problem (the original LP problem)
   1.220 -    SolutionStatus primalStatus() {
   1.221 +    SolutionStatus primalStatus() const {
   1.222        return _getPrimalStatus();
   1.223      }
   1.224  
   1.225      /// The status of the dual (of the original LP) problem 
   1.226 -    SolutionStatus dualStatus() {
   1.227 +    SolutionStatus dualStatus() const {
   1.228        return _getDualStatus();
   1.229      }
   1.230  
   1.231      ///The type of the original LP problem
   1.232 -    ProblemTypes problemType() {
   1.233 +    ProblemTypes problemType() const {
   1.234        return _getProblemType();
   1.235      }
   1.236  
   1.237      ///\e
   1.238 -    Value primal(Col c) { return _getPrimal(_lpId(c)); }
   1.239 +    Value primal(Col c) const { return _getPrimal(_lpId(c)); }
   1.240  
   1.241      ///\e
   1.242 -    Value dual(Row r) { return _getDual(_lpId(r)); }
   1.243 +    Value dual(Row r) const { return _getDual(_lpId(r)); }
   1.244  
   1.245      ///\e
   1.246 -    bool isBasicCol(Col c) { return _isBasicCol(_lpId(c)); }
   1.247 +    bool isBasicCol(Col c) const { return _isBasicCol(_lpId(c)); }
   1.248  
   1.249      ///\e
   1.250  
   1.251 @@ -1360,7 +1362,7 @@
   1.252      /// of the primal problem, depending on whether we minimize or maximize.
   1.253      ///- \ref NaN if no primal solution is found.
   1.254      ///- The (finite) objective value if an optimal solution is found.
   1.255 -    Value primalValue() { return _getPrimalValue()+obj_const_comp;}
   1.256 +    Value primalValue() const { return _getPrimalValue()+obj_const_comp;}
   1.257      ///@}
   1.258      
   1.259    };  
   1.260 @@ -1394,7 +1396,7 @@
   1.261      ///Gives back the type of the column.
   1.262      ///
   1.263      ///Gives back the type of the column.
   1.264 -    ColTypes colType(Col c){
   1.265 +    ColTypes colType(Col c) const {
   1.266        return _colType(_lpId(c));
   1.267      }
   1.268  
   1.269 @@ -1412,20 +1414,20 @@
   1.270      ///
   1.271      ///Gives back the type of the column.
   1.272      ///\return true if the column has integer type and false if not.
   1.273 -    bool integer(Col c){
   1.274 +    bool integer(Col c) const {
   1.275        return (colType(c)==INT);
   1.276      }
   1.277  
   1.278      /// The status of the MIP problem
   1.279 -    SolutionStatus mipStatus() {
   1.280 +    SolutionStatus mipStatus() const {
   1.281        return _getMipStatus();
   1.282      }
   1.283  
   1.284    protected:
   1.285  
   1.286 -    virtual ColTypes _colType(int col) = 0;
   1.287 +    virtual ColTypes _colType(int col) const = 0;
   1.288      virtual void _colType(int col, ColTypes col_type) = 0;
   1.289 -    virtual SolutionStatus _getMipStatus()=0;
   1.290 +    virtual SolutionStatus _getMipStatus() const = 0;
   1.291  
   1.292    };
   1.293    
     2.1 --- a/lemon/lp_cplex.cc	Fri Feb 16 15:57:48 2007 +0000
     2.2 +++ b/lemon/lp_cplex.cc	Fri Feb 16 19:11:31 2007 +0000
     2.3 @@ -84,7 +84,7 @@
     2.4      CPXdelrows(env, lp, i, i);
     2.5    }
     2.6    
     2.7 -  void LpCplex::_getColName(int col, std::string &name)
     2.8 +  void LpCplex::_getColName(int col, std::string &name) const
     2.9    {
    2.10      ///\bug Untested
    2.11      int storespace;
    2.12 @@ -107,6 +107,16 @@
    2.13      ///\bug return code unchecked for error
    2.14      CPXchgcolname(env, lp, 1, &col, names);    
    2.15    }
    2.16 +
    2.17 +  int LpCplex::_colByName(const std::string& name) const
    2.18 +  {
    2.19 +    int index;
    2.20 +    if (CPXgetcolindex(env, lp, 
    2.21 +                       const_cast<char*>(name.c_str()), &index) == 0) {
    2.22 +      return index;
    2.23 +    }
    2.24 +    return -1; 
    2.25 +  }
    2.26    
    2.27    ///\warning Data at index 0 is ignored in the arrays.
    2.28    void LpCplex::_setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e)
    2.29 @@ -125,7 +135,7 @@
    2.30  			    &rowlist[0], &indices[0], &values[0]); 
    2.31    }
    2.32  
    2.33 -  void LpSoplex::_getRowCoeffs(int i, RowIterator b) {
    2.34 +  void LpSoplex::_getRowCoeffs(int i, RowIterator b) const {
    2.35      /// \todo implement
    2.36    }
    2.37    
    2.38 @@ -145,7 +155,7 @@
    2.39  			    &indices[0], &collist[0], &values[0]); 
    2.40    }
    2.41  
    2.42 -  void LpSoplex::_getColCoeffs(int i, ColIterator b) {
    2.43 +  void LpSoplex::_getColCoeffs(int i, ColIterator b) const {
    2.44      /// \todo implement
    2.45    }
    2.46    
    2.47 @@ -154,7 +164,7 @@
    2.48      CPXchgcoef(env, lp, row, col, value);
    2.49    }
    2.50  
    2.51 -  LpCplex::Value LpCplex::_getCoeff(int row, int col) 
    2.52 +  LpCplex::Value LpCplex::_getCoeff(int row, int col) const
    2.53    {
    2.54      LpCplex::Value value;
    2.55      CPXgetcoef(env, lp, row, col, &value);
    2.56 @@ -173,7 +183,7 @@
    2.57   
    2.58    }
    2.59  
    2.60 -  LpCplex::Value LpCplex::_getColLowerBound(int i)
    2.61 +  LpCplex::Value LpCplex::_getColLowerBound(int i) const
    2.62    {
    2.63      LpCplex::Value x;
    2.64      CPXgetlb (env, lp, &x, i, i);
    2.65 @@ -191,7 +201,7 @@
    2.66      status = CPXchgbds(env, lp, 1, indices, lu, bd);
    2.67    }
    2.68  
    2.69 -  LpCplex::Value LpCplex::_getColUpperBound(int i)
    2.70 +  LpCplex::Value LpCplex::_getColUpperBound(int i) const
    2.71    {
    2.72      LpCplex::Value x;
    2.73      CPXgetub (env, lp, &x, i, i);
    2.74 @@ -270,7 +280,7 @@
    2.75  // //     status = CPXchgcoef(env, lp, i, -2, value_rng);
    2.76  //   }
    2.77    
    2.78 -  void LpCplex::_getRowBounds(int i, Value &lb, Value &ub)
    2.79 +  void LpCplex::_getRowBounds(int i, Value &lb, Value &ub) const
    2.80    {
    2.81      char sense;
    2.82      CPXgetsense(env, lp, &sense,i,i);
    2.83 @@ -302,7 +312,7 @@
    2.84      CPXchgcoef(env, lp, -1, i, obj_coef);
    2.85    }
    2.86  
    2.87 -  LpCplex::Value LpCplex::_getObjCoeff(int i)
    2.88 +  LpCplex::Value LpCplex::_getObjCoeff(int i) const
    2.89    {
    2.90      Value x;
    2.91      CPXgetcoef(env, lp, -1, i, &x);
    2.92 @@ -367,21 +377,21 @@
    2.93  #endif
    2.94    }
    2.95  
    2.96 -  LpCplex::Value LpCplex::_getPrimal(int i)
    2.97 +  LpCplex::Value LpCplex::_getPrimal(int i) const
    2.98    {
    2.99      Value x;
   2.100      CPXgetx(env, lp, &x, i, i);
   2.101      return x;
   2.102    }
   2.103  
   2.104 -  LpCplex::Value LpCplex::_getDual(int i)
   2.105 +  LpCplex::Value LpCplex::_getDual(int i) const
   2.106    {
   2.107      Value y;
   2.108      CPXgetpi(env, lp, &y, i, i);
   2.109      return y;
   2.110    }
   2.111    
   2.112 -  LpCplex::Value LpCplex::_getPrimalValue()
   2.113 +  LpCplex::Value LpCplex::_getPrimalValue() const
   2.114    {
   2.115      Value objval;
   2.116      //method = CPXgetmethod (env, lp);
   2.117 @@ -390,7 +400,8 @@
   2.118      //printf("Objective value: %g \n",objval);
   2.119      return objval;
   2.120    }
   2.121 -  bool LpCplex::_isBasicCol(int i) {
   2.122 +  bool LpCplex::_isBasicCol(int i) const
   2.123 +  {
   2.124      int cstat[CPXgetnumcols(env, lp)];
   2.125      CPXgetbase(env, lp, cstat, NULL);
   2.126      return (cstat[i]==CPX_BASIC);
   2.127 @@ -458,7 +469,6 @@
   2.128  // Default: 0 
   2.129  // Description: Method for linear optimization. 
   2.130  // Determines which algorithm is used when CPXlpopt() (or "optimize" in the Interactive Optimizer) is called. Currently the behavior of the "Automatic" setting is that CPLEX simply invokes the dual simplex method, but this capability may be expanded in the future so that CPLEX chooses the method based on problem characteristics 
   2.131 -  //Hulye cplex
   2.132    void statusSwitch(CPXENVptr env,int& stat){
   2.133  #if CPX_VERSION < 900
   2.134      int lpmethod;
   2.135 @@ -475,7 +485,7 @@
   2.136  #endif
   2.137    }
   2.138  
   2.139 -  LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
   2.140 +  LpCplex::SolutionStatus LpCplex::_getPrimalStatus() const
   2.141    {
   2.142      //Unboundedness not treated well: the following is from cplex 9.0 doc
   2.143      // About Unboundedness
   2.144 @@ -558,7 +568,7 @@
   2.145  // CPX_STAT_OPTIMAL_RELAXED
   2.146  // CPX_STAT_UNBOUNDED
   2.147  
   2.148 -  LpCplex::SolutionStatus LpCplex::_getDualStatus()
   2.149 +  LpCplex::SolutionStatus LpCplex::_getDualStatus() const
   2.150    {
   2.151      int stat = CPXgetstat(env, lp);
   2.152  #if CPX_VERSION >= 800
   2.153 @@ -587,7 +597,7 @@
   2.154  #endif
   2.155    }
   2.156  
   2.157 -  LpCplex::ProblemTypes LpCplex::_getProblemType()
   2.158 +  LpCplex::ProblemTypes LpCplex::_getProblemType() const
   2.159    {
   2.160      int stat = CPXgetstat(env, lp);
   2.161  #if CPX_VERSION >= 800
   2.162 @@ -627,7 +637,7 @@
   2.163      CPXchgobjsen(env, lp, CPX_MIN);
   2.164     }
   2.165  
   2.166 -  bool LpCplex::_isMax()
   2.167 +  bool LpCplex::_isMax() const
   2.168    {
   2.169      if (CPXgetobjsen(env, lp)==CPX_MAX)
   2.170        return true;
     3.1 --- a/lemon/lp_cplex.h	Fri Feb 16 15:57:48 2007 +0000
     3.2 +++ b/lemon/lp_cplex.h	Fri Feb 16 19:11:31 2007 +0000
     3.3 @@ -60,44 +60,45 @@
     3.4      virtual int _addRow();
     3.5      virtual void _eraseCol(int i);
     3.6      virtual void _eraseRow(int i);
     3.7 -    virtual void _getColName(int col,       std::string & name);
     3.8 +    virtual void _getColName(int col, std::string & name) const;
     3.9      virtual void _setColName(int col, const std::string & name);
    3.10 +    virtual int _colByName(const std::string& name) const;
    3.11      virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e);
    3.12 -    virtual void _getRowCoeffs(int i, RowIterator b);
    3.13 +    virtual void _getRowCoeffs(int i, RowIterator b) const;
    3.14      virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e);
    3.15 -    virtual void _getColCoeffs(int i, ColIterator b);
    3.16 +    virtual void _getColCoeffs(int i, ColIterator b) const;
    3.17      virtual void _setCoeff(int row, int col, Value value);
    3.18 -    virtual Value _getCoeff(int row, int col);
    3.19 +    virtual Value _getCoeff(int row, int col) const;
    3.20  
    3.21      virtual void _setColLowerBound(int i, Value value);
    3.22 -    virtual Value _getColLowerBound(int i);
    3.23 +    virtual Value _getColLowerBound(int i) const;
    3.24      virtual void _setColUpperBound(int i, Value value);
    3.25 -    virtual Value _getColUpperBound(int i);
    3.26 +    virtual Value _getColUpperBound(int i) const;
    3.27  
    3.28  //     virtual void _setRowLowerBound(int i, Value value);
    3.29  //     virtual void _setRowUpperBound(int i, Value value);
    3.30      virtual void _setRowBounds(int i, Value lower, Value upper);
    3.31 -    virtual void _getRowBounds(int i, Value &lb, Value &ub);
    3.32 +    virtual void _getRowBounds(int i, Value &lb, Value &ub) const;
    3.33      virtual void _setObjCoeff(int i, Value obj_coef);
    3.34 -    virtual Value _getObjCoeff(int i);
    3.35 +    virtual Value _getObjCoeff(int i) const;
    3.36      virtual void _clearObj();
    3.37  
    3.38      
    3.39      virtual SolveExitStatus _solve();
    3.40 -    virtual Value _getPrimal(int i);
    3.41 -    virtual Value _getDual(int i);
    3.42 -    virtual Value _getPrimalValue();
    3.43 -    virtual bool _isBasicCol(int i);
    3.44 +    virtual Value _getPrimal(int i) const;
    3.45 +    virtual Value _getDual(int i) const;
    3.46 +    virtual Value _getPrimalValue() const;
    3.47 +    virtual bool _isBasicCol(int i) const;
    3.48      
    3.49 -    virtual SolutionStatus _getPrimalStatus();
    3.50 -    virtual SolutionStatus _getDualStatus();
    3.51 -    virtual ProblemTypes _getProblemType();
    3.52 +    virtual SolutionStatus _getPrimalStatus() const;
    3.53 +    virtual SolutionStatus _getDualStatus() const;
    3.54 +    virtual ProblemTypes _getProblemType() const;
    3.55  
    3.56      
    3.57      virtual void _setMax();
    3.58      virtual void _setMin();
    3.59  
    3.60 -    virtual bool _isMax();
    3.61 +    virtual bool _isMax() const;
    3.62  
    3.63    };
    3.64  } //END OF NAMESPACE LEMON
     4.1 --- a/lemon/lp_glpk.cc	Fri Feb 16 15:57:48 2007 +0000
     4.2 +++ b/lemon/lp_glpk.cc	Fri Feb 16 19:11:31 2007 +0000
     4.3 @@ -37,6 +37,7 @@
     4.4      rows = _lp_bits::LpId(1);
     4.5      cols = _lp_bits::LpId(1);
     4.6      lp = lpx_create_prob();
     4.7 +    lpx_create_index(lp);
     4.8      ///\todo control function for this:
     4.9      lpx_set_int_parm(lp, LPX_K_DUAL, 1);
    4.10      messageLevel(0);
    4.11 @@ -112,7 +113,7 @@
    4.12      lpx_del_rows(lp, 1, rows);
    4.13    }
    4.14  
    4.15 -  void LpGlpk::_getColName(int col, std::string & name)
    4.16 +  void LpGlpk::_getColName(int col, std::string & name) const
    4.17    {
    4.18      
    4.19      char *n = lpx_get_col_name(lp,col);
    4.20 @@ -125,6 +126,13 @@
    4.21      lpx_set_col_name(lp,col,const_cast<char*>(name.c_str()));
    4.22  
    4.23    }
    4.24 +
    4.25 +  int LpGlpk::_colByName(const std::string& name) const
    4.26 +  {
    4.27 +    int k = lpx_find_col(lp, const_cast<char*>(name.c_str()));
    4.28 +    return k > 0 ? k : -1; 
    4.29 +  }
    4.30 +
    4.31    
    4.32    void LpGlpk::_setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e) 
    4.33    {
    4.34 @@ -142,7 +150,7 @@
    4.35      lpx_set_mat_row(lp, i, values.size() - 1, &indices[0], &values[0]);
    4.36    }
    4.37  
    4.38 -  void LpGlpk::_getRowCoeffs(int i, RowIterator b) 
    4.39 +  void LpGlpk::_getRowCoeffs(int i, RowIterator b) const
    4.40    {
    4.41      int length = lpx_get_mat_row(lp, i, 0, 0);
    4.42      
    4.43 @@ -173,7 +181,7 @@
    4.44      lpx_set_mat_col(lp, i, values.size() - 1, &indices[0], &values[0]);
    4.45    }
    4.46  
    4.47 -  void LpGlpk::_getColCoeffs(int i, ColIterator b) 
    4.48 +  void LpGlpk::_getColCoeffs(int i, ColIterator b) const
    4.49    {
    4.50      int length = lpx_get_mat_col(lp, i, 0, 0);
    4.51      
    4.52 @@ -247,7 +255,7 @@
    4.53      }
    4.54    }
    4.55  
    4.56 -  LpGlpk::Value LpGlpk::_getCoeff(int row, int col)
    4.57 +  LpGlpk::Value LpGlpk::_getCoeff(int row, int col) const
    4.58    {
    4.59  
    4.60      int length=lpx_get_mat_row(lp, row, 0, 0);
    4.61 @@ -312,7 +320,7 @@
    4.62  
    4.63    }
    4.64  
    4.65 -  LpGlpk::Value LpGlpk::_getColLowerBound(int i)
    4.66 +  LpGlpk::Value LpGlpk::_getColLowerBound(int i) const
    4.67    {
    4.68      int b=lpx_get_col_type(lp, i);
    4.69        switch (b) {
    4.70 @@ -369,7 +377,7 @@
    4.71      }
    4.72    }
    4.73  
    4.74 -  LpGlpk::Value LpGlpk::_getColUpperBound(int i)
    4.75 +  LpGlpk::Value LpGlpk::_getColUpperBound(int i) const
    4.76    {
    4.77      int b=lpx_get_col_type(lp, i);
    4.78        switch (b) {
    4.79 @@ -414,7 +422,7 @@
    4.80  
    4.81    }
    4.82  
    4.83 -  void LpGlpk::_getRowBounds(int i, Value &lb, Value &ub)
    4.84 +  void LpGlpk::_getRowBounds(int i, Value &lb, Value &ub) const
    4.85    {
    4.86  
    4.87      int b=lpx_get_row_type(lp, i);
    4.88 @@ -444,7 +452,7 @@
    4.89      lpx_set_obj_coef(lp, i, obj_coef);
    4.90    }
    4.91  
    4.92 -  LpGlpk::Value LpGlpk::_getObjCoeff(int i){
    4.93 +  LpGlpk::Value LpGlpk::_getObjCoeff(int i) const {
    4.94      //i=0 means the constant term (shift)
    4.95      return lpx_get_obj_coef(lp, i);
    4.96    }
    4.97 @@ -472,26 +480,27 @@
    4.98      }
    4.99    }
   4.100  
   4.101 -  LpGlpk::Value LpGlpk::_getPrimal(int i)
   4.102 +  LpGlpk::Value LpGlpk::_getPrimal(int i) const
   4.103    {
   4.104      return lpx_get_col_prim(lp,i);
   4.105    }
   4.106  
   4.107 -  LpGlpk::Value LpGlpk::_getDual(int i)
   4.108 +  LpGlpk::Value LpGlpk::_getDual(int i) const
   4.109    {
   4.110      return lpx_get_row_dual(lp,i);
   4.111    }
   4.112    
   4.113 -  LpGlpk::Value LpGlpk::_getPrimalValue()
   4.114 +  LpGlpk::Value LpGlpk::_getPrimalValue() const
   4.115    {
   4.116      return lpx_get_obj_val(lp);
   4.117    }
   4.118 -  bool LpGlpk::_isBasicCol(int i) {
   4.119 +  bool LpGlpk::_isBasicCol(int i) const
   4.120 +  {
   4.121      return (lpx_get_col_stat(lp, i)==LPX_BS);
   4.122    }
   4.123    
   4.124   
   4.125 -  LpGlpk::SolutionStatus LpGlpk::_getPrimalStatus()
   4.126 +  LpGlpk::SolutionStatus LpGlpk::_getPrimalStatus() const
   4.127    {
   4.128      int stat=  lpx_get_status(lp);
   4.129      switch (stat) {
   4.130 @@ -512,11 +521,8 @@
   4.131      }
   4.132    }
   4.133  
   4.134 -  LpGlpk::SolutionStatus LpGlpk::_getDualStatus()
   4.135 +  LpGlpk::SolutionStatus LpGlpk::_getDualStatus() const
   4.136    {
   4.137 -//     std::cout<<"Itt megy: "<<lpx_get_dual_stat(lp)<<std::endl;
   4.138 -//     std::cout<<"Itt a primal: "<<lpx_get_prim_stat(lp)<<std::endl;
   4.139 -
   4.140      switch (lpx_get_dual_stat(lp)) {
   4.141      case LPX_D_UNDEF://Undefined (no solve has been run yet)
   4.142        return UNDEFINED;
   4.143 @@ -538,7 +544,7 @@
   4.144      }
   4.145    }
   4.146  
   4.147 -  LpGlpk::ProblemTypes LpGlpk::_getProblemType()
   4.148 +  LpGlpk::ProblemTypes LpGlpk::_getProblemType() const
   4.149    {
   4.150        //int stat=  lpx_get_status(lp);
   4.151      int statp=  lpx_get_prim_stat(lp);
   4.152 @@ -565,7 +571,7 @@
   4.153      lpx_set_obj_dir(lp, LPX_MIN);
   4.154    }
   4.155  
   4.156 -  bool LpGlpk::_isMax()
   4.157 +  bool LpGlpk::_isMax() const
   4.158    {
   4.159      return (lpx_get_obj_dir(lp)==LPX_MAX);
   4.160    }
     5.1 --- a/lemon/lp_glpk.h	Fri Feb 16 15:57:48 2007 +0000
     5.2 +++ b/lemon/lp_glpk.h	Fri Feb 16 19:11:31 2007 +0000
     5.3 @@ -55,52 +55,48 @@
     5.4      virtual int _addRow();
     5.5      virtual void _eraseCol(int i);
     5.6      virtual void _eraseRow(int i);
     5.7 -    virtual void _getColName(int col,       std::string & name);
     5.8 +    virtual void _getColName(int col, std::string & name) const;
     5.9      virtual void _setColName(int col, const std::string & name);
    5.10 +    virtual int _colByName(const std::string& name) const;
    5.11      virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e);
    5.12 -    virtual void _getRowCoeffs(int i, RowIterator b);
    5.13 +    virtual void _getRowCoeffs(int i, RowIterator b) const;
    5.14      virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e);
    5.15 -    virtual void _getColCoeffs(int i, ColIterator b);
    5.16 +    virtual void _getColCoeffs(int i, ColIterator b) const;
    5.17      virtual void _setCoeff(int row, int col, Value value);
    5.18 -    virtual Value _getCoeff(int row, int col);
    5.19 +    virtual Value _getCoeff(int row, int col) const;
    5.20  
    5.21      virtual void _setColLowerBound(int i, Value value);
    5.22 -    virtual Value _getColLowerBound(int i);
    5.23 +    virtual Value _getColLowerBound(int i) const;
    5.24      virtual void _setColUpperBound(int i, Value value);
    5.25 -    virtual Value _getColUpperBound(int i);
    5.26 +    virtual Value _getColUpperBound(int i) const;
    5.27  
    5.28 -//     virtual void _setRowLowerBound(int i, Value value);
    5.29 -//     virtual void _setRowUpperBound(int i, Value value);
    5.30      virtual void _setRowBounds(int i, Value lower, Value upper);
    5.31 -    virtual void _getRowBounds(int i, Value &lb, Value &ub);
    5.32 +    virtual void _getRowBounds(int i, Value &lb, Value &ub) const;
    5.33      virtual void _setObjCoeff(int i, Value obj_coef);
    5.34 -    virtual Value _getObjCoeff(int i);
    5.35 +    virtual Value _getObjCoeff(int i) const;
    5.36      virtual void _clearObj();
    5.37 -//     virtual void _setObj(int length,
    5.38 -//                          int  const * indices, 
    5.39 -//                          Value  const * values ) = 0;
    5.40  
    5.41      ///\e
    5.42      
    5.43      ///\todo It should be clarified
    5.44      ///
    5.45      virtual SolveExitStatus _solve();
    5.46 -    virtual Value _getPrimal(int i);
    5.47 -    virtual Value _getDual(int i);
    5.48 -    virtual Value _getPrimalValue();
    5.49 -    virtual bool _isBasicCol(int i);
    5.50 +    virtual Value _getPrimal(int i) const;
    5.51 +    virtual Value _getDual(int i) const;
    5.52 +    virtual Value _getPrimalValue() const;
    5.53 +    virtual bool _isBasicCol(int i) const;
    5.54      ///\e
    5.55      
    5.56      ///\todo It should be clarified
    5.57      ///
    5.58 -    virtual SolutionStatus _getPrimalStatus();
    5.59 -    virtual SolutionStatus _getDualStatus();
    5.60 -    virtual ProblemTypes _getProblemType();
    5.61 +    virtual SolutionStatus _getPrimalStatus() const;
    5.62 +    virtual SolutionStatus _getDualStatus() const;
    5.63 +    virtual ProblemTypes _getProblemType() const;
    5.64  
    5.65      virtual void _setMax();
    5.66      virtual void _setMin();
    5.67  
    5.68 -    virtual bool _isMax();
    5.69 +    virtual bool _isMax() const;
    5.70  
    5.71    public:
    5.72      ///Set the verbosity of the messages
     6.1 --- a/lemon/lp_skeleton.cc	Fri Feb 16 15:57:48 2007 +0000
     6.2 +++ b/lemon/lp_skeleton.cc	Fri Feb 16 19:11:31 2007 +0000
     6.3 @@ -50,31 +50,33 @@
     6.4    void LpSkeleton::_eraseRow(int) {
     6.5    }
     6.6  
     6.7 -  void LpSkeleton::_getColName(int, std::string &) {
     6.8 +  void LpSkeleton::_getColName(int, std::string &) const {
     6.9    }
    6.10    
    6.11    
    6.12    void LpSkeleton::_setColName(int, const std::string &) {
    6.13    }
    6.14 +
    6.15 +  int LpSkeleton::_colByName(const std::string&) const { return -1; }
    6.16    
    6.17    
    6.18    void LpSkeleton::_setRowCoeffs(int, ConstRowIterator, ConstRowIterator) {
    6.19    }
    6.20  
    6.21 -  void LpSkeleton::_getRowCoeffs(int, RowIterator) {
    6.22 +  void LpSkeleton::_getRowCoeffs(int, RowIterator) const {
    6.23    }
    6.24    
    6.25    void LpSkeleton::_setColCoeffs(int, ConstColIterator, ConstColIterator) {
    6.26    }
    6.27  
    6.28 -  void LpSkeleton::_getColCoeffs(int, ColIterator) {
    6.29 +  void LpSkeleton::_getColCoeffs(int, ColIterator) const {
    6.30    }
    6.31  
    6.32    void LpSkeleton::_setCoeff(int, int, Value )
    6.33    {
    6.34    }
    6.35  
    6.36 -  LpSkeleton::Value LpSkeleton::_getCoeff(int, int)
    6.37 +  LpSkeleton::Value LpSkeleton::_getCoeff(int, int) const
    6.38    {
    6.39      return 0;
    6.40    }
    6.41 @@ -84,7 +86,7 @@
    6.42    {
    6.43    }
    6.44    
    6.45 -  LpSkeleton::Value LpSkeleton::_getColLowerBound(int)
    6.46 +  LpSkeleton::Value LpSkeleton::_getColLowerBound(int) const
    6.47    {
    6.48      return 0;
    6.49    }
    6.50 @@ -93,7 +95,7 @@
    6.51    {
    6.52    }
    6.53  
    6.54 -  LpSkeleton::Value LpSkeleton::_getColUpperBound(int)
    6.55 +  LpSkeleton::Value LpSkeleton::_getColUpperBound(int) const
    6.56    {
    6.57      return 0;
    6.58    }
    6.59 @@ -110,7 +112,7 @@
    6.60    {
    6.61    }
    6.62  
    6.63 -  void LpSkeleton::_getRowBounds(int, Value&, Value&)
    6.64 +  void LpSkeleton::_getRowBounds(int, Value&, Value&) const
    6.65    {
    6.66    }
    6.67    
    6.68 @@ -118,7 +120,8 @@
    6.69    {
    6.70    }
    6.71  
    6.72 -  LpSkeleton::Value LpSkeleton::_getObjCoeff(int){
    6.73 +  LpSkeleton::Value LpSkeleton::_getObjCoeff(int) const
    6.74 +  {
    6.75      return 0;
    6.76    }
    6.77  
    6.78 @@ -130,7 +133,7 @@
    6.79    {
    6.80    }
    6.81  
    6.82 -  bool LpSkeleton::_isMax()
    6.83 +  bool LpSkeleton::_isMax() const
    6.84    {
    6.85      return true;
    6.86    }
    6.87 @@ -145,37 +148,37 @@
    6.88      return SOLVED;
    6.89    }
    6.90  
    6.91 -  LpSkeleton::Value LpSkeleton::_getPrimal(int)
    6.92 +  LpSkeleton::Value LpSkeleton::_getPrimal(int) const
    6.93    {
    6.94      return 0;
    6.95    }
    6.96    
    6.97 -  LpSkeleton::Value LpSkeleton::_getDual(int)
    6.98 +  LpSkeleton::Value LpSkeleton::_getDual(int) const
    6.99    {
   6.100      return 0;
   6.101    }
   6.102    
   6.103 -  LpSkeleton::Value LpSkeleton::_getPrimalValue()
   6.104 +  LpSkeleton::Value LpSkeleton::_getPrimalValue() const
   6.105    {
   6.106      return 0;
   6.107    }
   6.108    
   6.109 -  LpSkeleton::SolutionStatus LpSkeleton::_getPrimalStatus()
   6.110 +  LpSkeleton::SolutionStatus LpSkeleton::_getPrimalStatus() const
   6.111    {
   6.112      return UNDEFINED;
   6.113    }
   6.114  
   6.115 -  LpSkeleton::SolutionStatus LpSkeleton::_getDualStatus()
   6.116 +  LpSkeleton::SolutionStatus LpSkeleton::_getDualStatus() const
   6.117    {
   6.118      return UNDEFINED;
   6.119    }
   6.120  
   6.121 -  LpSkeleton::ProblemTypes LpSkeleton::_getProblemType()
   6.122 +  LpSkeleton::ProblemTypes LpSkeleton::_getProblemType() const
   6.123    {
   6.124      return UNKNOWN;
   6.125    }
   6.126  
   6.127 -  bool LpSkeleton::_isBasicCol(int)
   6.128 +  bool LpSkeleton::_isBasicCol(int) const
   6.129    {
   6.130      return true;
   6.131    }
     7.1 --- a/lemon/lp_skeleton.h	Fri Feb 16 15:57:48 2007 +0000
     7.2 +++ b/lemon/lp_skeleton.h	Fri Feb 16 19:11:31 2007 +0000
     7.3 @@ -44,24 +44,26 @@
     7.4      /// \e
     7.5      virtual void _eraseRow(int i);
     7.6      /// \e
     7.7 -    virtual void _getColName(int col, std::string & name);
     7.8 +    virtual void _getColName(int col, std::string & name) const;
     7.9      /// \e
    7.10      virtual void _setColName(int col, const std::string & name);
    7.11 +    /// \e
    7.12 +    virtual int _colByName(const std::string& name) const;
    7.13  
    7.14      /// \e
    7.15      virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e);
    7.16      /// \e
    7.17 -    virtual void _getRowCoeffs(int i, RowIterator b);
    7.18 +    virtual void _getRowCoeffs(int i, RowIterator b) const;
    7.19      /// \e
    7.20      virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e);
    7.21      /// \e
    7.22 -    virtual void _getColCoeffs(int i, ColIterator b);
    7.23 +    virtual void _getColCoeffs(int i, ColIterator b) const;
    7.24      
    7.25      /// Set one element of the coefficient matrix
    7.26      virtual void _setCoeff(int row, int col, Value value);
    7.27  
    7.28      /// Get one element of the coefficient matrix
    7.29 -    virtual Value _getCoeff(int row, int col);
    7.30 +    virtual Value _getCoeff(int row, int col) const;
    7.31  
    7.32      /// The lower bound of a variable (column) have to be given by an 
    7.33      /// extended number of type Value, i.e. a finite number of type 
    7.34 @@ -72,7 +74,7 @@
    7.35      /// The lower bound of a variable (column) is an 
    7.36      /// extended number of type Value, i.e. a finite number of type 
    7.37      /// Value or -\ref INF.
    7.38 -    virtual Value _getColLowerBound(int i);
    7.39 +    virtual Value _getColLowerBound(int i) const;
    7.40  
    7.41      /// The upper bound of a variable (column) have to be given by an 
    7.42      /// extended number of type Value, i.e. a finite number of type 
    7.43 @@ -83,7 +85,7 @@
    7.44      /// The upper bound of a variable (column) is an 
    7.45      /// extended number of type Value, i.e. a finite number of type 
    7.46      /// Value or \ref INF.
    7.47 -    virtual Value _getColUpperBound(int i);
    7.48 +    virtual Value _getColUpperBound(int i) const;
    7.49  
    7.50  //     /// The lower bound of a linear expression (row) have to be given by an 
    7.51  //     /// extended number of type Value, i.e. a finite number of type 
    7.52 @@ -108,7 +110,7 @@
    7.53      /// a constraint (row) are  
    7.54      /// extended numbers of type Value, i.e.  finite numbers of type 
    7.55      /// Value, -\ref INF or \ref INF. 
    7.56 -    virtual void _getRowBounds(int i, Value &lb, Value &ub);
    7.57 +    virtual void _getRowBounds(int i, Value &lb, Value &ub) const;
    7.58      /// \e
    7.59  
    7.60  
    7.61 @@ -118,7 +120,7 @@
    7.62      virtual void _setObjCoeff(int i, Value obj_coef);
    7.63  
    7.64      /// \e
    7.65 -    virtual Value _getObjCoeff(int i);
    7.66 +    virtual Value _getObjCoeff(int i) const;
    7.67  
    7.68      ///\e
    7.69      
    7.70 @@ -130,32 +132,32 @@
    7.71  
    7.72      ///\bug Wrong interface
    7.73      ///
    7.74 -    virtual Value _getPrimal(int i);
    7.75 +    virtual Value _getPrimal(int i) const;
    7.76  
    7.77      ///\e
    7.78  
    7.79      ///\bug Wrong interface
    7.80      ///
    7.81 -    virtual Value _getDual(int i);
    7.82 +    virtual Value _getDual(int i) const;
    7.83  
    7.84      ///\e
    7.85  
    7.86      ///\bug Wrong interface
    7.87      ///
    7.88 -    virtual Value _getPrimalValue();
    7.89 +    virtual Value _getPrimalValue() const;
    7.90  
    7.91      ///\e
    7.92  
    7.93      ///\bug Wrong interface
    7.94      ///
    7.95 -    virtual SolutionStatus _getPrimalStatus();
    7.96 +    virtual SolutionStatus _getPrimalStatus() const;
    7.97  
    7.98      ////e
    7.99 -    virtual SolutionStatus _getDualStatus();
   7.100 +    virtual SolutionStatus _getDualStatus() const;
   7.101  
   7.102  
   7.103      ///\e
   7.104 -    virtual ProblemTypes _getProblemType();
   7.105 +    virtual ProblemTypes _getProblemType() const;
   7.106  
   7.107      ///\e
   7.108      virtual void _setMax();
   7.109 @@ -163,12 +165,12 @@
   7.110      virtual void _setMin();
   7.111  
   7.112      ///\e
   7.113 -    virtual bool _isMax();
   7.114 +    virtual bool _isMax() const;
   7.115  
   7.116  
   7.117  
   7.118      ///\e
   7.119 -    virtual bool _isBasicCol(int i);
   7.120 +    virtual bool _isBasicCol(int i) const;
   7.121  
   7.122      
   7.123  
     8.1 --- a/lemon/lp_soplex.cc	Fri Feb 16 15:57:48 2007 +0000
     8.2 +++ b/lemon/lp_soplex.cc	Fri Feb 16 19:11:31 2007 +0000
     8.3 @@ -90,12 +90,26 @@
     8.4      solved = false;
     8.5    }
     8.6    
     8.7 -  void LpSoplex::_getColName(int col, std::string &name) {
     8.8 +  void LpSoplex::_getColName(int col, std::string &name) const {
     8.9      name = colNames[col]; 
    8.10    }
    8.11    
    8.12    void LpSoplex::_setColName(int col, const std::string &name) {
    8.13 +    invColNames.erase(colNames[col]);
    8.14      colNames[col] = name; 
    8.15 +    if (!name.empty()) {
    8.16 +      invColNames.insert(std::make_pair(name, col));
    8.17 +    }
    8.18 +  }
    8.19 +
    8.20 +  int LpSoplex::_colByName(const std::string& name) const {
    8.21 +    std::map<std::string, int>::const_iterator it =
    8.22 +      invColNames.find(name);
    8.23 +    if (it != invColNames.end()) {
    8.24 +      return it->second;
    8.25 +    } else {
    8.26 +      return -1;
    8.27 +    }
    8.28    }
    8.29    
    8.30  
    8.31 @@ -109,7 +123,7 @@
    8.32      solved = false;
    8.33    }
    8.34  
    8.35 -  void LpSoplex::_getRowCoeffs(int i, RowIterator b) {
    8.36 +  void LpSoplex::_getRowCoeffs(int i, RowIterator b) const {
    8.37      const soplex::SVector& vec = soplex->rowVector(i);
    8.38      for (int k = 0; k < vec.size(); ++k) {
    8.39        *b = std::make_pair(vec.index(k), vec.value(k));
    8.40 @@ -127,7 +141,7 @@
    8.41      solved = false;
    8.42    }
    8.43  
    8.44 -  void LpSoplex::_getColCoeffs(int i, ColIterator b) {
    8.45 +  void LpSoplex::_getColCoeffs(int i, ColIterator b) const {
    8.46      const soplex::SVector& vec = soplex->colVector(i);
    8.47      for (int k = 0; k < vec.size(); ++k) {
    8.48        *b = std::make_pair(vec.index(k), vec.value(k));
    8.49 @@ -140,7 +154,7 @@
    8.50      solved = false;
    8.51    }
    8.52  
    8.53 -  LpSoplex::Value LpSoplex::_getCoeff(int i, int j) {
    8.54 +  LpSoplex::Value LpSoplex::_getCoeff(int i, int j) const {
    8.55      return soplex->rowVector(i)[j];
    8.56    }
    8.57  
    8.58 @@ -149,7 +163,7 @@
    8.59      solved = false;
    8.60    }
    8.61    
    8.62 -  LpSoplex::Value LpSoplex::_getColLowerBound(int i) {
    8.63 +  LpSoplex::Value LpSoplex::_getColLowerBound(int i) const {
    8.64      double value = soplex->lower(i);
    8.65      return value != -soplex::infinity ? value : -INF;
    8.66    }
    8.67 @@ -159,7 +173,7 @@
    8.68      solved = false;
    8.69    }
    8.70  
    8.71 -  LpSoplex::Value LpSoplex::_getColUpperBound(int i) {
    8.72 +  LpSoplex::Value LpSoplex::_getColUpperBound(int i) const {
    8.73      double value = soplex->upper(i);
    8.74      return value != soplex::infinity ? value : INF;
    8.75    }
    8.76 @@ -169,7 +183,7 @@
    8.77                          ub != INF ? ub : soplex::infinity);
    8.78      solved = false;
    8.79    }
    8.80 -  void LpSoplex::_getRowBounds(int i, Value &lower, Value &upper) {
    8.81 +  void LpSoplex::_getRowBounds(int i, Value &lower, Value &upper) const {
    8.82      lower = soplex->lhs(i);
    8.83      if (lower == -soplex::infinity) lower = -INF;
    8.84      upper = soplex->rhs(i);
    8.85 @@ -181,7 +195,7 @@
    8.86      solved = false;
    8.87    }
    8.88  
    8.89 -  LpSoplex::Value LpSoplex::_getObjCoeff(int i) {
    8.90 +  LpSoplex::Value LpSoplex::_getObjCoeff(int i) const {
    8.91      return soplex->obj(i);
    8.92    }
    8.93  
    8.94 @@ -212,23 +226,23 @@
    8.95      }
    8.96    }
    8.97  
    8.98 -  LpSoplex::Value LpSoplex::_getPrimal(int i) {
    8.99 +  LpSoplex::Value LpSoplex::_getPrimal(int i) const {
   8.100      return primal_value[i];
   8.101    }
   8.102  
   8.103 -  LpSoplex::Value LpSoplex::_getDual(int i) {
   8.104 +  LpSoplex::Value LpSoplex::_getDual(int i) const {
   8.105      return dual_value[i];
   8.106    }
   8.107    
   8.108 -  LpSoplex::Value LpSoplex::_getPrimalValue() {
   8.109 +  LpSoplex::Value LpSoplex::_getPrimalValue() const {
   8.110      return soplex->objValue();
   8.111    }
   8.112  
   8.113 -  bool LpSoplex::_isBasicCol(int i) {
   8.114 +  bool LpSoplex::_isBasicCol(int i) const {
   8.115      return soplex->getBasisColStatus(i) == soplex::SPxSolver::BASIC;
   8.116    }  
   8.117  
   8.118 -  LpSoplex::SolutionStatus LpSoplex::_getPrimalStatus() {
   8.119 +  LpSoplex::SolutionStatus LpSoplex::_getPrimalStatus() const {
   8.120      if (!solved) return UNDEFINED;
   8.121      switch (soplex->status()) {
   8.122      case soplex::SPxSolver::OPTIMAL:
   8.123 @@ -242,7 +256,7 @@
   8.124      }
   8.125    }
   8.126  
   8.127 -  LpSoplex::SolutionStatus LpSoplex::_getDualStatus() {
   8.128 +  LpSoplex::SolutionStatus LpSoplex::_getDualStatus() const {
   8.129      if (!solved) return UNDEFINED;
   8.130      switch (soplex->status()) {
   8.131      case soplex::SPxSolver::OPTIMAL:
   8.132 @@ -254,7 +268,7 @@
   8.133      }
   8.134    }
   8.135  
   8.136 -  LpSoplex::ProblemTypes LpSoplex::_getProblemType() {
   8.137 +  LpSoplex::ProblemTypes LpSoplex::_getProblemType() const {
   8.138      if (!solved) return UNKNOWN;
   8.139      switch (soplex->status()) {
   8.140      case soplex::SPxSolver::OPTIMAL:
   8.141 @@ -274,7 +288,7 @@
   8.142      soplex->changeSense(soplex::SPxSolver::MINIMIZE);
   8.143      solved = false;
   8.144    }
   8.145 -  bool LpSoplex::_isMax() {
   8.146 +  bool LpSoplex::_isMax() const {
   8.147      return soplex->spxSense() == soplex::SPxSolver::MAXIMIZE;
   8.148    }
   8.149  
     9.1 --- a/lemon/lp_soplex.h	Fri Feb 16 15:57:48 2007 +0000
     9.2 +++ b/lemon/lp_soplex.h	Fri Feb 16 19:11:31 2007 +0000
     9.3 @@ -34,9 +34,15 @@
     9.4  
     9.5  namespace lemon {
     9.6  
     9.7 +  /// \ingroup gen_opt_group
     9.8 +  ///
     9.9    /// \brief Interface for the SOPLEX solver
    9.10    /// 
    9.11 -  /// This class implements an interface for the SOPLEX LP solver.
    9.12 +  /// This class implements an interface for the SoPlex LP solver.
    9.13 +  /// The SoPlex library is an object oriented lp solver library
    9.14 +  /// developed at the Konrad-Zuse-Zentrum für Informationstechnik
    9.15 +  /// Berlin (ZIB). You can find detailed information about it at the
    9.16 +  /// <tt>http://soplex.zib.de</tt> address.
    9.17    class LpSoplex :virtual public LpSolverBase {
    9.18    protected:
    9.19  
    9.20 @@ -46,6 +52,7 @@
    9.21      bool solved;
    9.22  
    9.23      std::vector<std::string> colNames;
    9.24 +    std::map<std::string, int> invColNames;
    9.25  
    9.26      std::vector<Value> primal_value;
    9.27      std::vector<Value> dual_value;
    9.28 @@ -70,38 +77,39 @@
    9.29      virtual int _addRow();
    9.30      virtual void _eraseCol(int i);
    9.31      virtual void _eraseRow(int i);
    9.32 -    virtual void _getColName(int col, std::string & name);
    9.33 +    virtual void _getColName(int col, std::string & name) const;
    9.34      virtual void _setColName(int col, const std::string & name);
    9.35 +    virtual int _colByName(const std::string& name) const;
    9.36      virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e);
    9.37 -    virtual void _getRowCoeffs(int i, RowIterator b);
    9.38 +    virtual void _getRowCoeffs(int i, RowIterator b) const;
    9.39      virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e);
    9.40 -    virtual void _getColCoeffs(int i, ColIterator b);
    9.41 +    virtual void _getColCoeffs(int i, ColIterator b) const;
    9.42      virtual void _setCoeff(int row, int col, Value value);
    9.43 -    virtual Value _getCoeff(int row, int col);
    9.44 +    virtual Value _getCoeff(int row, int col) const;
    9.45      virtual void _setColLowerBound(int i, Value value);
    9.46 -    virtual Value _getColLowerBound(int i);
    9.47 +    virtual Value _getColLowerBound(int i) const;
    9.48      virtual void _setColUpperBound(int i, Value value);
    9.49 -    virtual Value _getColUpperBound(int i);
    9.50 +    virtual Value _getColUpperBound(int i) const;
    9.51      virtual void _setRowBounds(int i, Value lower, Value upper);
    9.52 -    virtual void _getRowBounds(int i, Value &lower, Value &upper);
    9.53 +    virtual void _getRowBounds(int i, Value &lower, Value &upper) const;
    9.54      virtual void _setObjCoeff(int i, Value obj_coef);
    9.55 -    virtual Value _getObjCoeff(int i);
    9.56 +    virtual Value _getObjCoeff(int i) const;
    9.57      virtual void _clearObj();
    9.58      
    9.59      virtual SolveExitStatus _solve();
    9.60 -    virtual Value _getPrimal(int i);
    9.61 -    virtual Value _getDual(int i);
    9.62 -    virtual Value _getPrimalValue();
    9.63 -    virtual bool _isBasicCol(int i);
    9.64 +    virtual Value _getPrimal(int i) const;
    9.65 +    virtual Value _getDual(int i) const;
    9.66 +    virtual Value _getPrimalValue() const;
    9.67 +    virtual bool _isBasicCol(int i) const;
    9.68      
    9.69 -    virtual SolutionStatus _getPrimalStatus();
    9.70 -    virtual SolutionStatus _getDualStatus();
    9.71 -    virtual ProblemTypes _getProblemType();
    9.72 +    virtual SolutionStatus _getPrimalStatus() const;
    9.73 +    virtual SolutionStatus _getDualStatus() const;
    9.74 +    virtual ProblemTypes _getProblemType() const;
    9.75  
    9.76      
    9.77      virtual void _setMax();
    9.78      virtual void _setMin();
    9.79 -    virtual bool _isMax();
    9.80 +    virtual bool _isMax() const;
    9.81  
    9.82    };
    9.83  } //END OF NAMESPACE LEMON
    10.1 --- a/lemon/mip_cplex.cc	Fri Feb 16 15:57:48 2007 +0000
    10.2 +++ b/lemon/mip_cplex.cc	Fri Feb 16 19:11:31 2007 +0000
    10.3 @@ -58,7 +58,7 @@
    10.4      CPXchgctype (env, lp, 1, indices, ctype);
    10.5    }
    10.6    
    10.7 -  MipCplex::ColTypes MipCplex::_colType(int i){
    10.8 +  MipCplex::ColTypes MipCplex::_colType(int i) const {
    10.9      
   10.10      char ctype[1];
   10.11      status = CPXgetctype (env, lp, ctype, i, i);
   10.12 @@ -85,7 +85,7 @@
   10.13    }
   10.14  
   10.15  
   10.16 -  LpCplex::SolutionStatus MipCplex::_getMipStatus(){
   10.17 +  LpCplex::SolutionStatus MipCplex::_getMipStatus() const {
   10.18  
   10.19      int stat = CPXgetstat(env, lp);
   10.20  
   10.21 @@ -119,13 +119,13 @@
   10.22        
   10.23    }  
   10.24  
   10.25 -  MipCplex::Value MipCplex::_getPrimal(int i){
   10.26 +  MipCplex::Value MipCplex::_getPrimal(int i) const {
   10.27      Value x;
   10.28      CPXgetmipx(env, lp, &x, i, i);
   10.29      return x;
   10.30    }
   10.31    
   10.32 -  MipCplex::Value MipCplex::_getPrimalValue(){
   10.33 +  MipCplex::Value MipCplex::_getPrimalValue() const {
   10.34      Value objval;
   10.35      status = CPXgetmipobjval(env, lp, &objval);
   10.36      return objval;
    11.1 --- a/lemon/mip_cplex.h	Fri Feb 16 15:57:48 2007 +0000
    11.2 +++ b/lemon/mip_cplex.h	Fri Feb 16 19:11:31 2007 +0000
    11.3 @@ -47,13 +47,13 @@
    11.4      
    11.5    protected:
    11.6    
    11.7 -    virtual ColTypes _colType(int col);
    11.8 +    virtual ColTypes _colType(int col) const;
    11.9      virtual void _colType(int col, ColTypes col_type);
   11.10      
   11.11      virtual LpCplex::SolveExitStatus _solve();
   11.12 -    virtual LpCplex::SolutionStatus _getMipStatus();
   11.13 -    virtual ParentLp::Value _getPrimal(int i);
   11.14 -    virtual ParentLp::Value _getPrimalValue();
   11.15 +    virtual LpCplex::SolutionStatus _getMipStatus() const;
   11.16 +    virtual ParentLp::Value _getPrimal(int i) const;
   11.17 +    virtual ParentLp::Value _getPrimalValue() const;
   11.18    };
   11.19  
   11.20  } //END OF NAMESPACE LEMON
    12.1 --- a/lemon/mip_glpk.cc	Fri Feb 16 15:57:48 2007 +0000
    12.2 +++ b/lemon/mip_glpk.cc	Fri Feb 16 19:11:31 2007 +0000
    12.3 @@ -40,7 +40,7 @@
    12.4      }
    12.5    }
    12.6    
    12.7 -  MipGlpk::ColTypes MipGlpk::_colType(int i){
    12.8 +  MipGlpk::ColTypes MipGlpk::_colType(int i) const {
    12.9      switch (lpx_get_col_kind(lp,i)){
   12.10      case LPX_IV:
   12.11        return INT;//Or binary
   12.12 @@ -52,7 +52,7 @@
   12.13      
   12.14    }
   12.15    
   12.16 -  LpGlpk::SolveExitStatus MipGlpk::_solve(){
   12.17 +  LpGlpk::SolveExitStatus MipGlpk::_solve() {
   12.18      int result = lpx_simplex(lp);
   12.19      //
   12.20      if (lpx_get_status(lp)==LPX_OPT){
   12.21 @@ -71,7 +71,7 @@
   12.22    }
   12.23  
   12.24  
   12.25 -  LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){
   12.26 +  LpGlpk::SolutionStatus MipGlpk::_getMipStatus() const {
   12.27  
   12.28      if (lpx_get_status(lp)==LPX_OPT){
   12.29        //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is
   12.30 @@ -100,11 +100,11 @@
   12.31        
   12.32    }  
   12.33  
   12.34 -  MipGlpk::Value MipGlpk::_getPrimal(int i){
   12.35 +  MipGlpk::Value MipGlpk::_getPrimal(int i) const {
   12.36      return lpx_mip_col_val(lp,i);
   12.37    }
   12.38    
   12.39 -  MipGlpk::Value MipGlpk::_getPrimalValue(){
   12.40 +  MipGlpk::Value MipGlpk::_getPrimalValue() const {
   12.41      return lpx_mip_obj_val(lp);
   12.42    }
   12.43  } //END OF NAMESPACE LEMON
    13.1 --- a/lemon/mip_glpk.h	Fri Feb 16 15:57:48 2007 +0000
    13.2 +++ b/lemon/mip_glpk.h	Fri Feb 16 19:11:31 2007 +0000
    13.3 @@ -45,13 +45,13 @@
    13.4      
    13.5    protected:
    13.6    
    13.7 -    virtual ColTypes _colType(int col);
    13.8 +    virtual ColTypes _colType(int col) const;
    13.9      virtual void _colType(int col, ColTypes col_type);
   13.10      
   13.11      virtual LpGlpk::SolveExitStatus _solve();
   13.12 -    virtual LpGlpk::SolutionStatus _getMipStatus();
   13.13 -    virtual ParentLp::Value _getPrimal(int i);
   13.14 -    virtual ParentLp::Value _getPrimalValue();
   13.15 +    virtual LpGlpk::SolutionStatus _getMipStatus() const;
   13.16 +    virtual ParentLp::Value _getPrimal(int i) const;
   13.17 +    virtual ParentLp::Value _getPrimalValue() const;
   13.18    };
   13.19  
   13.20  } //END OF NAMESPACE LEMON