COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
01/31/05 18:00:12 (19 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1509
Message:

new functions for changing lower and upper bounds of variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci/lp/lp_solver_wrapper_3.h

    r1104 r1110  
    238238  protected:
    239239    /// \e
     240    /// The lower bound of a variable (column) have to be given by an
     241    /// extended number of type _Value, i.e. a finite number of type
     242    /// _Value or -INF.
     243    virtual void _setColLowerBound(int i, _Value value) = 0;
     244    /// \e
     245    /// The upper bound of a variable (column) have to be given by an
     246    /// extended number of type _Value, i.e. a finite number of type
     247    /// _Value or INF.
     248    virtual void _setColUpperBound(int i, _Value value) = 0;
     249    /// \e
     250    /// The lower bound of a variable (column) is an
     251    /// extended number of type _Value, i.e. a finite number of type
     252    /// _Value or -INF.
     253    virtual _Value _getColLowerBound(int i) = 0;
     254    /// \e
     255    /// The upper bound of a variable (column) is an
     256    /// extended number of type _Value, i.e. a finite number of type
     257    /// _Value or INF.
     258    virtual _Value _getColUpperBound(int i) = 0;
     259    /// \e
    240260    virtual void _setColBounds(int i, Bound bound,
    241261                               _Value lo, _Value up) = 0;
     
    258278    /// \e
    259279    RowIt addRow() {
    260       int i=_addRow(); 
     280      int i=_addRow();
    261281      RowIt row_it;
    262282      row_iter_map.first(row_it, INVALID_CLASS);
     
    329349    }
    330350    /// \e
     351    void setColLowerBound(ColIt col_it, _Value lo) {
     352      _setColLowerBound(col_iter_map[col_it], lo);
     353    }
     354    /// \e
     355    void setColUpperBound(ColIt col_it, _Value up) {
     356      _setColUpperBound(col_iter_map[col_it], up);
     357    }
     358    /// \e
     359    _Value getColLowerBound(ColIt col_it) {
     360      return _getColLowerBound(col_iter_map[col_it]);
     361    }
     362    /// \e
     363    _Value getColUpperBound(ColIt col_it) {     
     364      return _getColUpperBound(col_iter_map[col_it]);
     365    }
     366    /// \e
    331367    void setColBounds(const ColIt& col_it, Bound bound,
    332368                      _Value lo, _Value up) {
     
    473509    /// \e
    474510    int _addCol() {
    475       return lpx_add_cols(lp, 1);
     511      int i=lpx_add_cols(lp, 1);
     512      _setColLowerBound(i, -INF);
     513      _setColUpperBound(i, INF);
     514      return i;
    476515    }
    477516    /// \e
    478517    int _addRow() {
    479       return lpx_add_rows(lp, 1);
     518      int i=lpx_add_rows(lp, 1);
     519      return i;
    480520    }
    481521    /// \e
     
    527567      lpx_del_rows(lp, 1, rows);
    528568    }
     569    virtual void _setColLowerBound(int i, double lo) {
     570      if (lo==INF) {
     571        //FIXME error
     572      }
     573      int b=lpx_get_col_type(lp, i);
     574      double up=lpx_get_col_ub(lp, i); 
     575      if (lo==-INF) {
     576        switch (b) {
     577        case LPX_FR:
     578        case LPX_LO:
     579          lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
     580          break;
     581        case LPX_UP:
     582          break;
     583        case LPX_DB:
     584        case LPX_FX:
     585          lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
     586          break;
     587        default: ;
     588          //FIXME error
     589        }
     590      } else {
     591        switch (b) {
     592        case LPX_FR:
     593        case LPX_LO:
     594          lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
     595          break;
     596        case LPX_UP:     
     597        case LPX_DB:
     598        case LPX_FX:
     599          if (lo==up)
     600            lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
     601          else
     602            lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
     603          break;
     604        default: ;
     605          //FIXME error
     606        }
     607      }
     608    }
     609    virtual void _setColUpperBound(int i, double up) {
     610      if (up==-INF) {
     611        //FIXME error
     612      }
     613      int b=lpx_get_col_type(lp, i);
     614      double lo=lpx_get_col_lb(lp, i);
     615      if (up==INF) {
     616        switch (b) {
     617        case LPX_FR:
     618        case LPX_LO:
     619          break;
     620        case LPX_UP:
     621          lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
     622          break;
     623        case LPX_DB:
     624        case LPX_FX:
     625          lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
     626          break;
     627        default: ;
     628          //FIXME error
     629        }
     630      } else {
     631        switch (b) {
     632        case LPX_FR:
     633          lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
     634        case LPX_LO:
     635          if (lo==up)
     636            lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
     637          else
     638            lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
     639          break;
     640        case LPX_UP:
     641          lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
     642          break;
     643        case LPX_DB:
     644        case LPX_FX:
     645          if (lo==up)
     646            lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
     647          else
     648            lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
     649          break;
     650        default: ;
     651          //FIXME error
     652        }
     653      }
     654    }
     655    virtual double _getColLowerBound(int i) {
     656      int b=lpx_get_col_type(lp, i);
     657      switch (b) {
     658      case LPX_FR:
     659        return -INF;
     660      case LPX_LO:
     661        return lpx_get_col_lb(lp, i);
     662      case LPX_UP:
     663        return -INF;
     664      case LPX_DB:
     665      case LPX_FX:
     666        return lpx_get_col_lb(lp, i);
     667      default: ;
     668        //FIXME error
     669        return 0.0;
     670      }
     671    }
     672    virtual double _getColUpperBound(int i) {
     673      int b=lpx_get_col_type(lp, i);
     674      switch (b) {
     675      case LPX_FR:
     676      case LPX_LO:
     677        return INF;
     678      case LPX_UP:
     679      case LPX_DB:
     680      case LPX_FX:
     681        return lpx_get_col_ub(lp, i);
     682      default: ;
     683        //FIXME error
     684        return 0.0;
     685      }
     686    }
    529687    virtual void _setColBounds(int i, Bound bound,
    530688                               double lo, double up) {
Note: See TracChangeset for help on using the changeset viewer.