src/work/athos/lp/lp_solver_glpk.h
author alpar
Fri, 15 Apr 2005 19:56:25 +0000
changeset 1359 1581f961cfaa
permissions -rw-r--r--
Correct the english name of EGRES.
athos@1260
     1
// -*- c++ -*-
athos@1260
     2
#ifndef LEMON_LP_SOLVER_GLPK_H
athos@1260
     3
#define LEMON_LP_SOLVER_GLPK_H
athos@1260
     4
athos@1260
     5
///\ingroup misc
athos@1260
     6
///\file
athos@1260
     7
athos@1260
     8
extern "C" {
athos@1260
     9
#include "glpk.h"
athos@1260
    10
}
athos@1260
    11
#include <lp_solver_base.h>
athos@1260
    12
athos@1260
    13
namespace lemon {
athos@1260
    14
  
athos@1260
    15
  
athos@1260
    16
  template <typename Value>
athos@1260
    17
  const Value LpSolverBase<Value>::INF=std::numeric_limits<Value>::infinity();
athos@1260
    18
athos@1260
    19
athos@1260
    20
  /// \brief Wrapper for GLPK solver
athos@1260
    21
  /// 
athos@1260
    22
  /// This class implements a lemon wrapper for GLPK.
athos@1260
    23
  class LpGlpk : public LpSolverBase<double> {
athos@1260
    24
athos@1260
    25
  public:
athos@1260
    26
athos@1260
    27
    typedef LpSolverBase<double> Parent;
athos@1260
    28
    
athos@1260
    29
    /// \e
athos@1260
    30
    LPX* lp;
athos@1260
    31
athos@1260
    32
    /// \e
athos@1260
    33
    LpGlpk() : Parent(), 
athos@1260
    34
			lp(lpx_create_prob()) {
athos@1260
    35
      //int_row_map.push_back(Row());
athos@1260
    36
      //int_col_map.push_back(Col());
athos@1260
    37
      lpx_set_int_parm(lp, LPX_K_DUAL, 1);
athos@1260
    38
    }
athos@1260
    39
    /// \e
athos@1260
    40
    ~LpGlpk() {
athos@1260
    41
      lpx_delete_prob(lp);
athos@1260
    42
    }
athos@1260
    43
athos@1260
    44
    //MATRIX INDEPEDENT MANIPULATING FUNCTIONS
athos@1260
    45
athos@1260
    46
    /// \e
athos@1260
    47
    void setMinimize() { 
athos@1260
    48
      lpx_set_obj_dir(lp, LPX_MIN);
athos@1260
    49
    }
athos@1260
    50
    /// \e
athos@1260
    51
    void setMaximize() { 
athos@1260
    52
      lpx_set_obj_dir(lp, LPX_MAX);
athos@1260
    53
    }
athos@1260
    54
athos@1260
    55
    /// \e
athos@1260
    56
    /// Retrieve number of rows
athos@1260
    57
    int rowNum() const { return lpx_get_num_rows(lp); }
athos@1260
    58
    /// \e
athos@1260
    59
    /// Retrieve number of coloumns
athos@1260
    60
    int colNum() const { return lpx_get_num_cols(lp); }
athos@1260
    61
athos@1260
    62
  protected:
athos@1260
    63
    /// \e
athos@1260
    64
    int LpGlpk::_addCol() { 
athos@1260
    65
      int i=lpx_add_cols(lp, 1);
athos@1260
    66
      _setColLowerBound(i, -INF);
athos@1260
    67
      _setColUpperBound(i, INF);
athos@1260
    68
      return i;
athos@1260
    69
    }
athos@1260
    70
    /// \e
athos@1260
    71
    int LpGlpk::_addRow() { 
athos@1260
    72
      int i=lpx_add_rows(lp, 1);
athos@1260
    73
      return i;
athos@1260
    74
    }
athos@1260
    75
    /// \e
athos@1260
    76
    virtual void _setRowCoeffs(int i, 
athos@1260
    77
			       const std::vector<std::pair<int, double> >& coeffs) {
athos@1260
    78
      int mem_length=1+colNum();
athos@1260
    79
      int* indices = new int[mem_length];
athos@1260
    80
      double* doubles = new double[mem_length];
athos@1260
    81
      int length=0;
athos@1260
    82
      for (std::vector<std::pair<int, double> >::
athos@1260
    83
	     const_iterator it=coeffs.begin(); it!=coeffs.end(); ++it) {
athos@1260
    84
	++length;
athos@1260
    85
	indices[length]=it->first;
athos@1260
    86
	doubles[length]=it->second;
athos@1260
    87
      }
athos@1260
    88
      lpx_set_mat_row(lp, i, length, indices, doubles);
athos@1260
    89
      delete [] indices;
athos@1260
    90
      delete [] doubles;
athos@1260
    91
    }
athos@1260
    92
    /// \e
athos@1260
    93
    virtual void _getRowCoeffs(int i, 
athos@1260
    94
			       std::vector<std::pair<int, double> >& coeffs) {
athos@1260
    95
      int mem_length=1+colNum();
athos@1260
    96
      int* indices = new int[mem_length];
athos@1260
    97
      double* doubles = new double[mem_length];
athos@1260
    98
      int length=lpx_get_mat_row(lp, i, indices, doubles);
athos@1260
    99
      for (int i=1; i<=length; ++i) {
athos@1260
   100
	coeffs.push_back(std::make_pair(indices[i], doubles[i]));
athos@1260
   101
      }
athos@1260
   102
      delete [] indices;
athos@1260
   103
      delete [] doubles;
athos@1260
   104
    }
athos@1260
   105
    /// \e
athos@1260
   106
    virtual void _setColCoeffs(int i, 
athos@1260
   107
			       const std::vector<std::pair<int, double> >& coeffs) {
athos@1260
   108
      int mem_length=1+rowNum();
athos@1260
   109
      int* indices = new int[mem_length];
athos@1260
   110
      double* doubles = new double[mem_length];
athos@1260
   111
      int length=0;
athos@1260
   112
      for (std::vector<std::pair<int, double> >::
athos@1260
   113
	     const_iterator it=coeffs.begin(); it!=coeffs.end(); ++it) {
athos@1260
   114
	++length;
athos@1260
   115
	indices[length]=it->first;
athos@1260
   116
	doubles[length]=it->second;
athos@1260
   117
      }
athos@1260
   118
      lpx_set_mat_col(lp, i, length, indices, doubles);
athos@1260
   119
      delete [] indices;
athos@1260
   120
      delete [] doubles;
athos@1260
   121
    }
athos@1260
   122
    /// \e
athos@1260
   123
    virtual void _getColCoeffs(int i, 
athos@1260
   124
			       std::vector<std::pair<int, double> >& coeffs) {
athos@1260
   125
      int mem_length=1+rowNum();
athos@1260
   126
      int* indices = new int[mem_length];
athos@1260
   127
      double* doubles = new double[mem_length];
athos@1260
   128
      int length=lpx_get_mat_col(lp, i, indices, doubles);
athos@1260
   129
      for (int i=1; i<=length; ++i) {
athos@1260
   130
	coeffs.push_back(std::make_pair(indices[i], doubles[i]));
athos@1260
   131
      }
athos@1260
   132
      delete [] indices;
athos@1260
   133
      delete [] doubles;
athos@1260
   134
    }
athos@1260
   135
    /// \e
athos@1260
   136
    virtual void _eraseCol(int i) {
athos@1260
   137
      int cols[2];
athos@1260
   138
      cols[1]=i;
athos@1260
   139
      lpx_del_cols(lp, 1, cols);
athos@1260
   140
    }
athos@1260
   141
    virtual void _eraseRow(int i) {
athos@1260
   142
      int rows[2];
athos@1260
   143
      rows[1]=i;
athos@1260
   144
      lpx_del_rows(lp, 1, rows);
athos@1260
   145
    }
athos@1260
   146
athos@1260
   147
    void _setCoeff(int row, int col, double value) {
athos@1260
   148
      ///FIXME Of course this is not efficient at all, but GLPK knows not more.
athos@1260
   149
      /// First approach: get one row, apply changes and set it again
athos@1260
   150
athos@1260
   151
      int mem_length=1+colNum();
athos@1260
   152
      int* indices = new int[mem_length];
athos@1260
   153
      double* doubles = new double[mem_length];
athos@1260
   154
athos@1260
   155
athos@1260
   156
      int length=lpx_get_mat_row(lp, i, indices, doubles);
athos@1260
   157
athos@1260
   158
      //The following code does not suppose that the elements of the array indices are sorted
athos@1260
   159
      int i=1;
athos@1260
   160
      bool found=false;
athos@1260
   161
      while (i <= length && !found){
athos@1260
   162
	if (indices[i]=col){
athos@1260
   163
	  found = true;
athos@1260
   164
	  doubles[i]=value;
athos@1260
   165
	}
athos@1260
   166
	++i;
athos@1260
   167
      }
athos@1260
   168
      if (!found){
athos@1260
   169
	++length;
athos@1260
   170
	indices[length]=col;
athos@1260
   171
	doubles[length]=value;
athos@1260
   172
      }
athos@1260
   173
athos@1260
   174
// This is a piece of code that assumes that the array 'indices' is sorted. 
athos@1260
   175
// Not ready, I suppose. 
athos@1260
   176
//       //We need another arrays to put the data back, anyway
athos@1260
   177
//       int* new_indices = new int[length+1];
athos@1260
   178
//       double* new_doubles = new double[length+1];
athos@1260
   179
//       int offset;
athos@1260
   180
athos@1260
   181
//       int i=1;
athos@1260
   182
//       while (i <= length && indices[i]<col){
athos@1260
   183
// 	new_indiced[i]=indices[i];
athos@1260
   184
// 	new_doubles[i]=doubles[i];
athos@1260
   185
// 	++i;
athos@1260
   186
//       }
athos@1260
   187
//       if (i>length || indices[i]>col){
athos@1260
   188
// 	//Ha atugrottuk, vagy a vegen van
athos@1260
   189
// 	new_indices[i]=col;
athos@1260
   190
// 	new_doubles[i]=value;
athos@1260
   191
// 	offset = 1;
athos@1260
   192
//       }
athos@1260
   193
//       else{
athos@1260
   194
// 	//I.e.: indices[i]=col
athos@1260
   195
// 	new_doubles[i]=value;
athos@1260
   196
// 	offset = 0;
athos@1260
   197
// 	++i;
athos@1260
   198
//       }
athos@1260
   199
//       while (i <= length){
athos@1260
   200
// 	new_indices[i+offset]=indices[i];
athos@1260
   201
// 	new_values[i+offset]=values[i];
athos@1260
   202
//       }
athos@1260
   203
athos@1260
   204
      lpx_set_mat_row(lp, row, length, indices, doubles);
athos@1260
   205
      delete [] indices;
athos@1260
   206
      delete [] doubles;
athos@1260
   207
athos@1260
   208
//       lpx_set_mat_row(lp, row, length+offset, new_indices, new_doubles);
athos@1260
   209
//       delete [] new_indices;
athos@1260
   210
//       delete [] new_doubles;
athos@1260
   211
      
athos@1260
   212
athos@1260
   213
    }
athos@1260
   214
    double _getCoeff(int col, int row) {
athos@1260
   215
      /// FIXME not yet implemented
athos@1260
   216
      return 0.0;
athos@1260
   217
    }
athos@1260
   218
    virtual void _setColLowerBound(int i, double lo) {
athos@1260
   219
      if (lo==INF) {
athos@1260
   220
	//FIXME error
athos@1260
   221
      }
athos@1260
   222
      int b=lpx_get_col_type(lp, i);
athos@1260
   223
      double up=lpx_get_col_ub(lp, i);	
athos@1260
   224
      if (lo==-INF) {
athos@1260
   225
	switch (b) {
athos@1260
   226
	case LPX_FR:
athos@1260
   227
	case LPX_LO:
athos@1260
   228
	  lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
athos@1260
   229
	  break;
athos@1260
   230
	case LPX_UP:
athos@1260
   231
	  break;
athos@1260
   232
	case LPX_DB:
athos@1260
   233
	case LPX_FX:
athos@1260
   234
	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
athos@1260
   235
	  break;
athos@1260
   236
	default: ;
athos@1260
   237
	  //FIXME error
athos@1260
   238
	}
athos@1260
   239
      } else {
athos@1260
   240
	switch (b) {
athos@1260
   241
	case LPX_FR:
athos@1260
   242
	case LPX_LO:
athos@1260
   243
	  lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
athos@1260
   244
	  break;
athos@1260
   245
	case LPX_UP:	  
athos@1260
   246
	case LPX_DB:
athos@1260
   247
	case LPX_FX:
athos@1260
   248
	  if (lo==up) 
athos@1260
   249
	    lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
athos@1260
   250
	  else 
athos@1260
   251
	    lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
athos@1260
   252
	  break;
athos@1260
   253
	default: ;
athos@1260
   254
	  //FIXME error
athos@1260
   255
	}
athos@1260
   256
      }
athos@1260
   257
    }
athos@1260
   258
    virtual double _getColLowerBound(int i) {
athos@1260
   259
      int b=lpx_get_col_type(lp, i);
athos@1260
   260
      switch (b) {
athos@1260
   261
      case LPX_FR:
athos@1260
   262
	return -INF;
athos@1260
   263
      case LPX_LO:
athos@1260
   264
	return lpx_get_col_lb(lp, i);
athos@1260
   265
      case LPX_UP:
athos@1260
   266
	return -INF;
athos@1260
   267
      case LPX_DB:
athos@1260
   268
      case LPX_FX:
athos@1260
   269
	return lpx_get_col_lb(lp, i);
athos@1260
   270
      default: ;
athos@1260
   271
	//FIXME error
athos@1260
   272
	return 0.0;
athos@1260
   273
      }
athos@1260
   274
    }
athos@1260
   275
    virtual void _setColUpperBound(int i, double up) {
athos@1260
   276
      if (up==-INF) {
athos@1260
   277
	//FIXME error
athos@1260
   278
      }
athos@1260
   279
      int b=lpx_get_col_type(lp, i);
athos@1260
   280
      double lo=lpx_get_col_lb(lp, i);
athos@1260
   281
      if (up==INF) {
athos@1260
   282
	switch (b) {
athos@1260
   283
	case LPX_FR:
athos@1260
   284
	case LPX_LO:
athos@1260
   285
	  break;
athos@1260
   286
	case LPX_UP:
athos@1260
   287
	  lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
athos@1260
   288
	  break;
athos@1260
   289
	case LPX_DB:
athos@1260
   290
	case LPX_FX:
athos@1260
   291
	  lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
athos@1260
   292
	  break;
athos@1260
   293
	default: ;
athos@1260
   294
	  //FIXME error
athos@1260
   295
	}
athos@1260
   296
      } else {
athos@1260
   297
	switch (b) {
athos@1260
   298
	case LPX_FR:
athos@1260
   299
	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
athos@1260
   300
	case LPX_LO:
athos@1260
   301
	  if (lo==up) 
athos@1260
   302
	    lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
athos@1260
   303
	  else
athos@1260
   304
	    lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
athos@1260
   305
	  break;
athos@1260
   306
	case LPX_UP:
athos@1260
   307
	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
athos@1260
   308
	  break;
athos@1260
   309
	case LPX_DB:
athos@1260
   310
	case LPX_FX:
athos@1260
   311
	  if (lo==up) 
athos@1260
   312
	    lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
athos@1260
   313
	  else 
athos@1260
   314
	    lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
athos@1260
   315
	  break;
athos@1260
   316
	default: ;
athos@1260
   317
	  //FIXME error
athos@1260
   318
	}
athos@1260
   319
      }
athos@1260
   320
    }
athos@1260
   321
    virtual double _getColUpperBound(int i) {
athos@1260
   322
      int b=lpx_get_col_type(lp, i);
athos@1260
   323
      switch (b) {
athos@1260
   324
      case LPX_FR:
athos@1260
   325
      case LPX_LO:
athos@1260
   326
	return INF;
athos@1260
   327
      case LPX_UP:
athos@1260
   328
      case LPX_DB:
athos@1260
   329
      case LPX_FX:
athos@1260
   330
	return lpx_get_col_ub(lp, i);
athos@1260
   331
      default: ;
athos@1260
   332
	//FIXME error
athos@1260
   333
	return 0.0;
athos@1260
   334
      }
athos@1260
   335
    }
athos@1260
   336
    virtual void _setRowLowerBound(int i, double lo) {
athos@1260
   337
      if (lo==INF) {
athos@1260
   338
	//FIXME error
athos@1260
   339
      }
athos@1260
   340
      int b=lpx_get_row_type(lp, i);
athos@1260
   341
      double up=lpx_get_row_ub(lp, i);	
athos@1260
   342
      if (lo==-INF) {
athos@1260
   343
	switch (b) {
athos@1260
   344
	case LPX_FR:
athos@1260
   345
	case LPX_LO:
athos@1260
   346
	  lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
athos@1260
   347
	  break;
athos@1260
   348
	case LPX_UP:
athos@1260
   349
	  break;
athos@1260
   350
	case LPX_DB:
athos@1260
   351
	case LPX_FX:
athos@1260
   352
	  lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
athos@1260
   353
	  break;
athos@1260
   354
	default: ;
athos@1260
   355
	  //FIXME error
athos@1260
   356
	}
athos@1260
   357
      } else {
athos@1260
   358
	switch (b) {
athos@1260
   359
	case LPX_FR:
athos@1260
   360
	case LPX_LO:
athos@1260
   361
	  lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
athos@1260
   362
	  break;
athos@1260
   363
	case LPX_UP:	  
athos@1260
   364
	case LPX_DB:
athos@1260
   365
	case LPX_FX:
athos@1260
   366
	  if (lo==up) 
athos@1260
   367
	    lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
athos@1260
   368
	  else 
athos@1260
   369
	    lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
athos@1260
   370
	  break;
athos@1260
   371
	default: ;
athos@1260
   372
	  //FIXME error
athos@1260
   373
	}
athos@1260
   374
      }
athos@1260
   375
    }
athos@1260
   376
    virtual double _getRowLowerBound(int i) {
athos@1260
   377
      int b=lpx_get_row_type(lp, i);
athos@1260
   378
      switch (b) {
athos@1260
   379
      case LPX_FR:
athos@1260
   380
	return -INF;
athos@1260
   381
      case LPX_LO:
athos@1260
   382
	return lpx_get_row_lb(lp, i);
athos@1260
   383
      case LPX_UP:
athos@1260
   384
	return -INF;
athos@1260
   385
      case LPX_DB:
athos@1260
   386
      case LPX_FX:
athos@1260
   387
	return lpx_get_row_lb(lp, i);
athos@1260
   388
      default: ;
athos@1260
   389
	//FIXME error
athos@1260
   390
	return 0.0;
athos@1260
   391
      }
athos@1260
   392
    }
athos@1260
   393
    virtual void _setRowUpperBound(int i, double up) {
athos@1260
   394
      if (up==-INF) {
athos@1260
   395
	//FIXME error
athos@1260
   396
      }
athos@1260
   397
      int b=lpx_get_row_type(lp, i);
athos@1260
   398
      double lo=lpx_get_row_lb(lp, i);
athos@1260
   399
      if (up==INF) {
athos@1260
   400
	switch (b) {
athos@1260
   401
	case LPX_FR:
athos@1260
   402
	case LPX_LO:
athos@1260
   403
	  break;
athos@1260
   404
	case LPX_UP:
athos@1260
   405
	  lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
athos@1260
   406
	  break;
athos@1260
   407
	case LPX_DB:
athos@1260
   408
	case LPX_FX:
athos@1260
   409
	  lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
athos@1260
   410
	  break;
athos@1260
   411
	default: ;
athos@1260
   412
	  //FIXME error
athos@1260
   413
	}
athos@1260
   414
      } else {
athos@1260
   415
	switch (b) {
athos@1260
   416
	case LPX_FR:
athos@1260
   417
	  lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
athos@1260
   418
	case LPX_LO:
athos@1260
   419
	  if (lo==up) 
athos@1260
   420
	    lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
athos@1260
   421
	  else
athos@1260
   422
	    lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
athos@1260
   423
	  break;
athos@1260
   424
	case LPX_UP:
athos@1260
   425
	  lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
athos@1260
   426
	  break;
athos@1260
   427
	case LPX_DB:
athos@1260
   428
	case LPX_FX:
athos@1260
   429
	  if (lo==up) 
athos@1260
   430
	    lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
athos@1260
   431
	  else 
athos@1260
   432
	    lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
athos@1260
   433
	  break;
athos@1260
   434
	default: ;
athos@1260
   435
	  //FIXME error
athos@1260
   436
	}
athos@1260
   437
      }
athos@1260
   438
    }
athos@1260
   439
    virtual double _getRowUpperBound(int i) {
athos@1260
   440
      int b=lpx_get_row_type(lp, i);
athos@1260
   441
      switch (b) {
athos@1260
   442
      case LPX_FR:
athos@1260
   443
      case LPX_LO:
athos@1260
   444
	return INF;
athos@1260
   445
      case LPX_UP:
athos@1260
   446
      case LPX_DB:
athos@1260
   447
      case LPX_FX:
athos@1260
   448
	return lpx_get_row_ub(lp, i);
athos@1260
   449
      default: ;
athos@1260
   450
	//FIXME error
athos@1260
   451
	return 0.0;
athos@1260
   452
      }
athos@1260
   453
    }
athos@1260
   454
    /// \e
athos@1260
   455
    virtual double _getObjCoeff(int i) { 
athos@1260
   456
      return lpx_get_obj_coef(lp, i);
athos@1260
   457
    }
athos@1260
   458
    /// \e
athos@1260
   459
    virtual void _setObjCoeff(int i, double obj_coef) { 
athos@1260
   460
      lpx_set_obj_coef(lp, i, obj_coef);
athos@1260
   461
    }
athos@1260
   462
athos@1260
   463
  protected:
athos@1260
   464
    virtual double _getPrimal(int i) {
athos@1260
   465
      return lpx_get_col_prim(lp, i);
athos@1260
   466
    }
athos@1260
   467
athos@1260
   468
    //MIP
athos@1260
   469
  protected:
athos@1260
   470
    /// \e
athos@1260
   471
    void _setColCont(int i) { lpx_set_col_kind(lp, i, LPX_CV); }
athos@1260
   472
    /// \e
athos@1260
   473
    void _setColInt(int i) { lpx_set_col_kind(lp, i, LPX_IV); }
athos@1260
   474
    /// \e
athos@1260
   475
    double _getMIPPrimal(int i) { return lpx_mip_col_val(lp, i); }
athos@1260
   476
athos@1260
   477
athos@1260
   478
//   public:
athos@1260
   479
//     /// \e
athos@1260
   480
//     void solveSimplex() { lpx_simplex(lp); }
athos@1260
   481
//     /// \e
athos@1260
   482
//     void solvePrimalSimplex() { lpx_simplex(lp); }
athos@1260
   483
//     /// \e
athos@1260
   484
//     void solveDualSimplex() { lpx_simplex(lp); }
athos@1260
   485
//     /// \e
athos@1260
   486
//     double getObjVal() { return lpx_get_obj_val(lp); }
athos@1260
   487
//     /// \e
athos@1260
   488
//     int warmUp() { return lpx_warm_up(lp); }
athos@1260
   489
//     /// \e
athos@1260
   490
//     void printWarmUpStatus(int i) {
athos@1260
   491
//       switch (i) {
athos@1260
   492
//       case LPX_E_OK: cout << "LPX_E_OK" << endl; break;
athos@1260
   493
//       case LPX_E_EMPTY: cout << "LPX_E_EMPTY" << endl; break;	
athos@1260
   494
//       case LPX_E_BADB: cout << "LPX_E_BADB" << endl; break;
athos@1260
   495
//       case LPX_E_SING: cout << "LPX_E_SING" << endl; break;
athos@1260
   496
//       }
athos@1260
   497
//     }
athos@1260
   498
//     /// \e
athos@1260
   499
//     int getPrimalStatus() { return lpx_get_prim_stat(lp); }
athos@1260
   500
//     /// \e
athos@1260
   501
//     void printPrimalStatus(int i) {
athos@1260
   502
//       switch (i) {
athos@1260
   503
//       case LPX_P_UNDEF: cout << "LPX_P_UNDEF" << endl; break;
athos@1260
   504
//       case LPX_P_FEAS: cout << "LPX_P_FEAS" << endl; break;	
athos@1260
   505
//       case LPX_P_INFEAS: cout << "LPX_P_INFEAS" << endl; break;
athos@1260
   506
//       case LPX_P_NOFEAS: cout << "LPX_P_NOFEAS" << endl; break;
athos@1260
   507
//       }
athos@1260
   508
//     }
athos@1260
   509
//     /// \e
athos@1260
   510
//     int getDualStatus() { return lpx_get_dual_stat(lp); }
athos@1260
   511
//     /// \e
athos@1260
   512
//     void printDualStatus(int i) {
athos@1260
   513
//       switch (i) {
athos@1260
   514
//       case LPX_D_UNDEF: cout << "LPX_D_UNDEF" << endl; break;
athos@1260
   515
//       case LPX_D_FEAS: cout << "LPX_D_FEAS" << endl; break;	
athos@1260
   516
//       case LPX_D_INFEAS: cout << "LPX_D_INFEAS" << endl; break;
athos@1260
   517
//       case LPX_D_NOFEAS: cout << "LPX_D_NOFEAS" << endl; break;
athos@1260
   518
//       }
athos@1260
   519
//     }
athos@1260
   520
//     /// Returns the status of the slack variable assigned to row \c row.
athos@1260
   521
//     int getRowStat(const Row& row) { 
athos@1260
   522
//       return lpx_get_row_stat(lp, row_iter_map[row]); 
athos@1260
   523
//     }
athos@1260
   524
//     /// \e
athos@1260
   525
//     void printRowStatus(int i) {
athos@1260
   526
//       switch (i) {
athos@1260
   527
//       case LPX_BS: cout << "LPX_BS" << endl; break;
athos@1260
   528
//       case LPX_NL: cout << "LPX_NL" << endl; break;	
athos@1260
   529
//       case LPX_NU: cout << "LPX_NU" << endl; break;
athos@1260
   530
//       case LPX_NF: cout << "LPX_NF" << endl; break;
athos@1260
   531
//       case LPX_NS: cout << "LPX_NS" << endl; break;
athos@1260
   532
//       }
athos@1260
   533
//     }
athos@1260
   534
//     /// Returns the status of the variable assigned to column \c col.
athos@1260
   535
//     int getColStat(const Col& col) { 
athos@1260
   536
//       return lpx_get_col_stat(lp, col_iter_map[col]); 
athos@1260
   537
//     }
athos@1260
   538
//     /// \e
athos@1260
   539
//     void printColStatus(int i) {
athos@1260
   540
//       switch (i) {
athos@1260
   541
//       case LPX_BS: cout << "LPX_BS" << endl; break;
athos@1260
   542
//       case LPX_NL: cout << "LPX_NL" << endl; break;	
athos@1260
   543
//       case LPX_NU: cout << "LPX_NU" << endl; break;
athos@1260
   544
//       case LPX_NF: cout << "LPX_NF" << endl; break;
athos@1260
   545
//       case LPX_NS: cout << "LPX_NS" << endl; break;
athos@1260
   546
//       }
athos@1260
   547
//     }
athos@1260
   548
athos@1260
   549
//     // MIP
athos@1260
   550
//     /// \e
athos@1260
   551
//     void solveBandB() { lpx_integer(lp); }
athos@1260
   552
//     /// \e
athos@1260
   553
//     void setLP() { lpx_set_class(lp, LPX_LP); }
athos@1260
   554
//     /// \e
athos@1260
   555
//     void setMIP() { lpx_set_class(lp, LPX_MIP); }
athos@1260
   556
athos@1260
   557
athos@1260
   558
athos@1260
   559
  };
athos@1260
   560
  
athos@1260
   561
  /// @}
athos@1260
   562
athos@1260
   563
} //namespace lemon
athos@1260
   564
athos@1260
   565
#endif //LEMON_LP_SOLVER_GLPK_H