COIN-OR::LEMON - Graph Library

Changeset 2148:ab368e0ab662 in lemon-0.x


Ignore:
Timestamp:
07/17/06 13:56:17 (18 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2862
Message:

Modifications to the interface: colType() functions, though I left the old integer() functions, too.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • demo/mip_demo.cc

    r2146 r2148  
    1010   Mip ilp;
    1111
    12    
     12
    1313  typedef Mip::Row Row;
    1414  typedef Mip::Col Col;
  • lemon/lp_base.h

    r2144 r2148  
    11591159
    11601160
    1161   ///Common base class for ILP solvers
     1161  ///Common base class for MIP solvers
    11621162  ///\todo Much more docs
    11631163  ///\ingroup gen_opt_group
     
    11651165  public:
    11661166
    1167     ///Set the type of the given Col to integer or remove that property.
    1168     ///
    1169     ///Set the type of the given Col to integer or remove that property.
     1167    ///Possible variable (coloumn) types (e.g. real, integer, binary etc.)
     1168    enum ColTypes {
     1169      ///Continuous variable
     1170      REAL = 0,
     1171      ///Integer variable
     1172      INTEGER = 1
     1173      ///\todo No support for other types yet.
     1174    };
     1175
     1176    ///Sets the type of the given coloumn to the given type
     1177    ///
     1178    ///Sets the type of the given coloumn to the given type.
     1179    void colType(Col c, ColTypes col_type) {
     1180      _colType(cols.floatingId(c.id),col_type);
     1181    }
     1182
     1183    ///Gives back the type of the column.
     1184    ///
     1185    ///Gives back the type of the column.
     1186    ColTypes colType(Col c){
     1187      return _colType(cols.floatingId(c.id));
     1188    }
     1189
     1190    ///Sets the type of the given Col to integer or remove that property.
     1191    ///
     1192    ///Sets the type of the given Col to integer or remove that property.
    11701193    void integer(Col c, bool enable) {
    1171       _integer(cols.floatingId(c.id),enable);
    1172     }
    1173 
    1174     ///Gives back the type of the column.
     1194      if (enable)
     1195        colType(c,INTEGER);
     1196      else
     1197        colType(c,REAL);
     1198    }
     1199
     1200    ///Gives back whether the type of the column is integer or not.
    11751201    ///
    11761202    ///Gives back the type of the column.
    11771203    ///\return true if the column has integer type and false if not.
    11781204    bool integer(Col c){
    1179       return _integer(cols.floatingId(c.id));
     1205      return (colType(c)==INTEGER);
    11801206    }
    11811207
    11821208  protected:
    11831209
    1184     virtual bool _integer(int col) = 0;
    1185     virtual void _integer(int col, bool enable) = 0;
     1210    virtual ColTypes _colType(int col) = 0;
     1211    virtual void _colType(int col, ColTypes col_type) = 0;
     1212
    11861213  };
    11871214 
  • lemon/mip_glpk.cc

    r2144 r2148  
    3030    lpx_set_class(lp,LPX_MIP);
    3131  }
    32  
    33   void MipGlpk::_integer(int i, bool enable){
    34     if(enable){
    35       lpx_set_col_kind(lp,i,LPX_IV);
    36     }else{
    37       lpx_set_col_kind(lp,i,LPX_CV);
     32
     33  void MipGlpk::_colType(int i, ColTypes col_type){
     34    switch (col_type){
     35      case INTEGER:
     36        lpx_set_col_kind(lp,i,LPX_IV);
     37        break;
     38      case REAL:
     39        lpx_set_col_kind(lp,i,LPX_CV);
     40        break;
     41      default:
     42        //FIXME problem
    3843    }
    3944  }
    4045 
    41   bool MipGlpk::_integer(int i){
    42     if(LPX_IV == lpx_get_col_kind(lp,i)){
    43       return true;
     46  ColTypes MipGlpk::_colType(int i){
     47    switch (lpx_get_col_kind(lp,i)){
     48    case LPX_IV:
     49      return INTEGER;//Or binary
     50    case LPX_CV:
     51      return REAL;
     52    default:
     53      return REAL;//Error!
    4454    }
    45     return false;
     55   
    4656  }
    4757 
  • lemon/mip_glpk.h

    r2144 r2148  
    4646  protected:
    4747 
    48     virtual void _integer(int c, bool enable);
    49     virtual bool _integer(int c);
     48    virtual ColTypes _colType(int col);
     49    virtual void _colType(int col, ColTypes col_type);
    5050   
    5151    virtual LpGlpk::SolveExitStatus _solve();
Note: See TracChangeset for help on using the changeset viewer.