src/work/marci/lp/lp_solver_base.h
author alpar
Thu, 03 Feb 2005 16:08:56 +0000
changeset 1119 d3504fc075dc
parent 1112 b258584569f2
child 1143 4fb22cfa5759
permissions -rw-r--r--
Two incomplete additions:
- Exceptions
- bool map indication reached nodes (NullMap by default)
marci@1031
     1
// -*- c++ -*-
marci@1031
     2
#ifndef LEMON_LP_SOLVER_WRAPPER_H
marci@1031
     3
#define LEMON_LP_SOLVER_WRAPPER_H
marci@1031
     4
marci@1031
     5
///\ingroup misc
marci@1031
     6
///\file
marci@1031
     7
///\brief Dijkstra algorithm.
marci@1031
     8
marci@1031
     9
// #include <stdio.h>
marci@1031
    10
#include <stdlib.h>
marci@1097
    11
#include <iostream>
marci@1097
    12
#include <map>
marci@1104
    13
#include <limits>
marci@1031
    14
// #include <stdio>
marci@1031
    15
//#include <stdlib>
marci@1031
    16
extern "C" {
marci@1031
    17
#include "glpk.h"
marci@1031
    18
}
marci@1031
    19
marci@1031
    20
#include <iostream>
marci@1031
    21
#include <vector>
marci@1031
    22
#include <string>
marci@1031
    23
#include <list>
marci@1031
    24
#include <memory>
marci@1031
    25
#include <utility>
marci@1031
    26
marci@1031
    27
//#include <lemon/list_graph.h>
marci@1031
    28
#include <lemon/invalid.h>
marci@1099
    29
#include <expression.h>
marci@1031
    30
//#include <bfs_dfs.h>
marci@1031
    31
//#include <stp.h>
marci@1031
    32
//#include <lemon/max_flow.h>
marci@1031
    33
//#include <augmenting_flow.h>
marci@1031
    34
//#include <iter_map.h>
marci@1031
    35
marci@1031
    36
using std::cout;
marci@1031
    37
using std::cin;
marci@1031
    38
using std::endl;
marci@1031
    39
marci@1031
    40
namespace lemon {
marci@1031
    41
  
marci@1031
    42
  /// \addtogroup misc
marci@1031
    43
  /// @{
marci@1031
    44
marci@1031
    45
  /// \brief A partitioned vector with iterable classes.
marci@1031
    46
  ///
marci@1031
    47
  /// This class implements a container in which the data is stored in an 
marci@1031
    48
  /// stl vector, the range is partitioned into sets and each set is 
marci@1031
    49
  /// doubly linked in a list. 
marci@1031
    50
  /// That is, each class is iterable by lemon iterators, and any member of 
marci@1031
    51
  /// the vector can bo moved to an other class.
marci@1031
    52
  template <typename T>
marci@1031
    53
  class IterablePartition {
marci@1031
    54
  protected:
marci@1031
    55
    struct Node {
marci@1031
    56
      T data;
marci@1031
    57
      int prev; //invalid az -1
marci@1031
    58
      int next; 
marci@1031
    59
    };
marci@1031
    60
    std::vector<Node> nodes;
marci@1031
    61
    struct Tip {
marci@1031
    62
      int first;
marci@1031
    63
      int last;
marci@1031
    64
    };
marci@1031
    65
    std::vector<Tip> tips;
marci@1031
    66
  public:
marci@1031
    67
    /// The classes are indexed by integers from \c 0 to \c classNum()-1.
marci@1031
    68
    int classNum() const { return tips.size(); }
marci@1031
    69
    /// This lemon style iterator iterates through a class. 
marci@1031
    70
    class ClassIt;
marci@1031
    71
    /// Constructor. The number of classes is to be given which is fixed 
marci@1031
    72
    /// over the life of the container. 
marci@1031
    73
    /// The partition classes are indexed from 0 to class_num-1. 
marci@1031
    74
    IterablePartition(int class_num) { 
marci@1031
    75
      for (int i=0; i<class_num; ++i) {
marci@1031
    76
	Tip t;
marci@1031
    77
	t.first=t.last=-1;
marci@1031
    78
	tips.push_back(t);
marci@1031
    79
      }
marci@1031
    80
    }
marci@1031
    81
  protected:
marci@1031
    82
    void befuz(ClassIt it, int class_id) {
marci@1031
    83
      if (tips[class_id].first==-1) {
marci@1031
    84
	if (tips[class_id].last==-1) {
marci@1031
    85
	  nodes[it.i].prev=nodes[it.i].next=-1;
marci@1031
    86
	  tips[class_id].first=tips[class_id].last=it.i;
marci@1031
    87
	}
marci@1031
    88
      } else {
marci@1031
    89
	nodes[it.i].prev=tips[class_id].last;
marci@1031
    90
	nodes[it.i].next=-1;
marci@1031
    91
	nodes[tips[class_id].last].next=it.i;
marci@1031
    92
	tips[class_id].last=it.i;
marci@1031
    93
      }
marci@1031
    94
    }
marci@1031
    95
    void kifuz(ClassIt it, int class_id) {
marci@1031
    96
      if (tips[class_id].first==it.i) {
marci@1031
    97
	if (tips[class_id].last==it.i) {
marci@1031
    98
	  tips[class_id].first=tips[class_id].last=-1;
marci@1031
    99
	} else {
marci@1031
   100
	  tips[class_id].first=nodes[it.i].next;
marci@1031
   101
	  nodes[nodes[it.i].next].prev=-1;
marci@1031
   102
	}
marci@1031
   103
      } else {
marci@1031
   104
	if (tips[class_id].last==it.i) {
marci@1031
   105
	  tips[class_id].last=nodes[it.i].prev;
marci@1031
   106
	  nodes[nodes[it.i].prev].next=-1;
marci@1031
   107
	} else {
marci@1031
   108
	  nodes[nodes[it.i].next].prev=nodes[it.i].prev;
marci@1031
   109
	  nodes[nodes[it.i].prev].next=nodes[it.i].next;
marci@1031
   110
	}
marci@1031
   111
      }
marci@1031
   112
    }
marci@1031
   113
  public:
marci@1031
   114
    /// A new element with data \c t is pushed into the vector and into class 
marci@1031
   115
    /// \c class_id.
marci@1031
   116
    ClassIt push_back(const T& t, int class_id) { 
marci@1031
   117
      Node n;
marci@1031
   118
      n.data=t;
marci@1031
   119
      nodes.push_back(n);
marci@1031
   120
      int i=nodes.size()-1;
marci@1031
   121
      befuz(i, class_id);
marci@1031
   122
      return i;
marci@1031
   123
    }
marci@1031
   124
    /// A member is moved to an other class.
marci@1031
   125
    void set(ClassIt it, int old_class_id, int new_class_id) {
marci@1031
   126
      kifuz(it.i, old_class_id);
marci@1031
   127
      befuz(it.i, new_class_id);
marci@1031
   128
    }
marci@1031
   129
    /// Returns the data pointed by \c it.
marci@1031
   130
    T& operator[](ClassIt it) { return nodes[it.i].data; }
marci@1031
   131
    /// Returns the data pointed by \c it.
marci@1031
   132
    const T& operator[](ClassIt it) const { return nodes[it.i].data; }
marci@1031
   133
    ///.
marci@1031
   134
    class ClassIt {
marci@1031
   135
      friend class IterablePartition;
marci@1031
   136
    protected:
marci@1031
   137
      int i;
marci@1031
   138
    public:
marci@1031
   139
      /// Default constructor.
marci@1031
   140
      ClassIt() { }
marci@1031
   141
      /// This constructor constructs an iterator which points
marci@1031
   142
      /// to the member of th container indexed by the integer _i.
marci@1031
   143
      ClassIt(const int& _i) : i(_i) { }
marci@1031
   144
      /// Invalid constructor.
marci@1031
   145
      ClassIt(const Invalid&) : i(-1) { }
marci@1099
   146
      friend bool operator<(const ClassIt& x, const ClassIt& y);
marci@1099
   147
      friend std::ostream& operator<<(std::ostream& os, 
marci@1099
   148
				      const ClassIt& it);
marci@1031
   149
    };
marci@1099
   150
    friend bool operator<(const ClassIt& x, const ClassIt& y) {
marci@1099
   151
      return (x.i < y.i);
marci@1099
   152
    }
marci@1099
   153
    friend std::ostream& operator<<(std::ostream& os, 
marci@1099
   154
				    const ClassIt& it) {
marci@1099
   155
      os << it.i;
marci@1099
   156
      return os;
marci@1099
   157
    }
marci@1031
   158
    /// First member of class \c class_id.
marci@1031
   159
    ClassIt& first(ClassIt& it, int class_id) const {
marci@1031
   160
      it.i=tips[class_id].first;
marci@1031
   161
      return it;
marci@1031
   162
    }
marci@1031
   163
    /// Next member.
marci@1031
   164
    ClassIt& next(ClassIt& it) const {
marci@1031
   165
      it.i=nodes[it.i].next;
marci@1031
   166
      return it;
marci@1031
   167
    }
marci@1031
   168
    /// True iff the iterator is valid.
marci@1031
   169
    bool valid(const ClassIt& it) const { return it.i!=-1; }
marci@1031
   170
  };
marci@1031
   171
marci@1097
   172
marci@1031
   173
  /*! \e
marci@1111
   174
    \todo A[x,y]-t cserel. Jobboldal, baloldal csere.
marci@1111
   175
    \todo LEKERDEZESEK!!!
marci@1111
   176
    \todo DOKSI!!!! Doxygen group!!!
marci@1111
   177
    The aim of this class is to give a general surface to different 
marci@1111
   178
    solvers, i.e. it makes possible to write algorithms using LP's, 
marci@1111
   179
    in which the solver can be changed to an other one easily.
marci@1112
   180
    \nosubgrouping
marci@1111
   181
  */
marci@1048
   182
  template <typename _Value>
marci@1031
   183
  class LPSolverBase {
marci@1112
   184
    
marci@1113
   185
    /*! @name Uncategorized functions and types (public members)
marci@1112
   186
    */
marci@1112
   187
    //@{
marci@1031
   188
  public:
marci@1112
   189
marci@1112
   190
    //UNCATEGORIZED
marci@1112
   191
marci@1031
   192
    /// \e
marci@1048
   193
    typedef _Value Value;
marci@1048
   194
    /// \e
marci@1031
   195
    typedef IterablePartition<int>::ClassIt RowIt;
marci@1031
   196
    /// \e
marci@1031
   197
    typedef IterablePartition<int>::ClassIt ColIt;
marci@1074
   198
  public:
marci@1031
   199
    /// \e
marci@1031
   200
    IterablePartition<int> row_iter_map;
marci@1031
   201
    /// \e
marci@1031
   202
    IterablePartition<int> col_iter_map;
marci@1031
   203
    /// \e
marci@1074
   204
    const int VALID_CLASS;
marci@1031
   205
    /// \e
marci@1074
   206
    const int INVALID_CLASS;
marci@1104
   207
    /// \e 
marci@1104
   208
    static const _Value INF;
marci@1031
   209
  public:
marci@1031
   210
    /// \e
marci@1031
   211
    LPSolverBase() : row_iter_map(2), 
marci@1031
   212
		     col_iter_map(2), 
marci@1074
   213
		     VALID_CLASS(0), INVALID_CLASS(1) { }
marci@1031
   214
    /// \e
marci@1031
   215
    virtual ~LPSolverBase() { }
marci@1112
   216
    //@}
marci@1081
   217
marci@1112
   218
    /*! @name Medium level interface (public members)
marci@1112
   219
      These functions appear in the low level and also in the high level 
marci@1112
   220
      interfaces thus these each of these functions have to be implemented 
marci@1112
   221
      only once in the different interfaces.
marci@1112
   222
      This means that these functions have to be reimplemented for all of the 
marci@1112
   223
      different lp solvers. These are basic functions, and have the same 
marci@1112
   224
      parameter lists in the low and high level interfaces. 
marci@1112
   225
    */
marci@1112
   226
    //@{
marci@1112
   227
  public:
marci@1081
   228
marci@1112
   229
    //UNCATEGORIZED FUNCTIONS
marci@1112
   230
marci@1031
   231
    /// \e
marci@1031
   232
    virtual void setMinimize() = 0;
marci@1031
   233
    /// \e
marci@1031
   234
    virtual void setMaximize() = 0;
marci@1081
   235
marci@1112
   236
    //SOLVER FUNCTIONS
marci@1081
   237
marci@1112
   238
    /// \e
marci@1112
   239
    virtual void solveSimplex() = 0;
marci@1112
   240
    /// \e
marci@1112
   241
    virtual void solvePrimalSimplex() = 0;
marci@1112
   242
    /// \e
marci@1112
   243
    virtual void solveDualSimplex() = 0;
marci@1112
   244
    /// \e
marci@1112
   245
marci@1112
   246
    //SOLUTION RETRIEVING
marci@1112
   247
marci@1112
   248
    /// \e
marci@1112
   249
    virtual _Value getObjVal() = 0;
marci@1112
   250
marci@1112
   251
    //OTHER FUNCTIONS
marci@1112
   252
marci@1112
   253
    /// \e
marci@1112
   254
    virtual int rowNum() const = 0;
marci@1112
   255
    /// \e
marci@1112
   256
    virtual int colNum() const = 0;
marci@1112
   257
    /// \e
marci@1112
   258
    virtual int warmUp() = 0;
marci@1112
   259
    /// \e
marci@1112
   260
    virtual void printWarmUpStatus(int i) = 0;
marci@1112
   261
    /// \e
marci@1112
   262
    virtual int getPrimalStatus() = 0;
marci@1112
   263
    /// \e
marci@1112
   264
    virtual void printPrimalStatus(int i) = 0;
marci@1112
   265
    /// \e
marci@1112
   266
    virtual int getDualStatus() = 0;
marci@1112
   267
    /// \e
marci@1112
   268
    virtual void printDualStatus(int i) = 0;
marci@1112
   269
    /// Returns the status of the slack variable assigned to row \c row_it.
marci@1112
   270
    virtual int getRowStat(const RowIt& row_it) = 0;
marci@1112
   271
    /// \e
marci@1112
   272
    virtual void printRowStatus(int i) = 0;
marci@1112
   273
    /// Returns the status of the variable assigned to column \c col_it.
marci@1112
   274
    virtual int getColStat(const ColIt& col_it) = 0;
marci@1112
   275
    /// \e
marci@1112
   276
    virtual void printColStatus(int i) = 0;
marci@1112
   277
marci@1112
   278
    //@}
marci@1112
   279
marci@1112
   280
    /*! @name Low level interface (protected members)
marci@1112
   281
      Problem manipulating functions in the low level interface
marci@1112
   282
    */
marci@1112
   283
    //@{
marci@1074
   284
  protected:
marci@1112
   285
marci@1112
   286
    //MATRIX MANIPULATING FUNCTIONS
marci@1112
   287
marci@1031
   288
    /// \e
marci@1111
   289
    virtual int _addCol() = 0;
marci@1111
   290
    /// \e
marci@1074
   291
    virtual int _addRow() = 0;
marci@1031
   292
    /// \e
marci@1111
   293
    virtual void _eraseCol(int i) = 0;
marci@1111
   294
    /// \e
marci@1111
   295
    virtual void _eraseRow(int i) = 0;
marci@1081
   296
    /// \e
marci@1081
   297
    virtual void _setRowCoeffs(int i, 
marci@1104
   298
			       const std::vector<std::pair<int, _Value> >& coeffs) = 0;
marci@1081
   299
    /// \e
marci@1081
   300
    virtual void _setColCoeffs(int i, 
marci@1104
   301
			       const std::vector<std::pair<int, _Value> >& coeffs) = 0;
marci@1081
   302
  public:
marci@1081
   303
    /// \e
marci@1081
   304
    enum Bound { FREE, LOWER, UPPER, DOUBLE, FIXED };
marci@1081
   305
  protected:
marci@1081
   306
    /// \e
marci@1110
   307
    /// The lower bound of a variable (column) have to be given by an 
marci@1110
   308
    /// extended number of type _Value, i.e. a finite number of type 
marci@1110
   309
    /// _Value or -INF.
marci@1110
   310
    virtual void _setColLowerBound(int i, _Value value) = 0;
marci@1110
   311
    /// \e
marci@1111
   312
    /// The lower bound of a variable (column) is an 
marci@1111
   313
    /// extended number of type _Value, i.e. a finite number of type 
marci@1111
   314
    /// _Value or -INF.
marci@1111
   315
    virtual _Value _getColLowerBound(int i) = 0;
marci@1111
   316
    /// \e
marci@1110
   317
    /// The upper bound of a variable (column) have to be given by an 
marci@1110
   318
    /// extended number of type _Value, i.e. a finite number of type 
marci@1110
   319
    /// _Value or INF.
marci@1110
   320
    virtual void _setColUpperBound(int i, _Value value) = 0;
marci@1110
   321
    /// \e
marci@1110
   322
    /// The upper bound of a variable (column) is an 
marci@1110
   323
    /// extended number of type _Value, i.e. a finite number of type 
marci@1110
   324
    /// _Value or INF.
marci@1110
   325
    virtual _Value _getColUpperBound(int i) = 0;
marci@1110
   326
    /// \e
marci@1111
   327
    /// The lower bound of a linear expression (row) have to be given by an 
marci@1111
   328
    /// extended number of type _Value, i.e. a finite number of type 
marci@1111
   329
    /// _Value or -INF.
marci@1111
   330
    virtual void _setRowLowerBound(int i, _Value value) = 0;
marci@1081
   331
    /// \e
marci@1111
   332
    /// The lower bound of a linear expression (row) is an 
marci@1111
   333
    /// extended number of type _Value, i.e. a finite number of type 
marci@1111
   334
    /// _Value or -INF.
marci@1111
   335
    virtual _Value _getRowLowerBound(int i) = 0;
marci@1111
   336
    /// \e
marci@1111
   337
    /// The upper bound of a linear expression (row) have to be given by an 
marci@1111
   338
    /// extended number of type _Value, i.e. a finite number of type 
marci@1111
   339
    /// _Value or INF.
marci@1111
   340
    virtual void _setRowUpperBound(int i, _Value value) = 0;
marci@1111
   341
    /// \e
marci@1111
   342
    /// The upper bound of a linear expression (row) is an 
marci@1111
   343
    /// extended number of type _Value, i.e. a finite number of type 
marci@1111
   344
    /// _Value or INF.
marci@1111
   345
    virtual _Value _getRowUpperBound(int i) = 0;
marci@1081
   346
    /// \e
marci@1081
   347
    virtual void _setObjCoef(int i, _Value obj_coef) = 0;
marci@1081
   348
    /// \e
marci@1081
   349
    virtual _Value _getObjCoef(int i) = 0;
marci@1112
   350
    
marci@1112
   351
    //SOLUTION RETRIEVING
marci@1081
   352
marci@1111
   353
    /// \e
marci@1081
   354
    virtual _Value _getPrimal(int i) = 0;
marci@1112
   355
    //@}
marci@1112
   356
    
marci@1112
   357
    /*! @name High level interface (public members)
marci@1112
   358
      Problem manipulating functions in the high level interface
marci@1112
   359
    */
marci@1112
   360
    //@{
marci@1112
   361
  public:
marci@1081
   362
marci@1112
   363
    //MATRIX MANIPULATING FUNCTIONS
marci@1081
   364
marci@1074
   365
    /// \e
marci@1074
   366
    ColIt addCol() {
marci@1074
   367
      int i=_addCol();  
marci@1074
   368
      ColIt col_it;
marci@1074
   369
      col_iter_map.first(col_it, INVALID_CLASS);
marci@1074
   370
      if (col_iter_map.valid(col_it)) { //van hasznalhato hely
marci@1074
   371
	col_iter_map.set(col_it, INVALID_CLASS, VALID_CLASS);
marci@1074
   372
	col_iter_map[col_it]=i;
marci@1074
   373
      } else { //a cucc vegere kell inzertalni mert nincs szabad hely
marci@1074
   374
	col_it=col_iter_map.push_back(i, VALID_CLASS);
marci@1074
   375
      }
marci@1074
   376
      return col_it;
marci@1074
   377
    }
marci@1074
   378
    /// \e
marci@1111
   379
    RowIt addRow() {
marci@1111
   380
      int i=_addRow();
marci@1111
   381
      RowIt row_it;
marci@1111
   382
      row_iter_map.first(row_it, INVALID_CLASS);
marci@1111
   383
      if (row_iter_map.valid(row_it)) { //van hasznalhato hely
marci@1111
   384
	row_iter_map.set(row_it, INVALID_CLASS, VALID_CLASS);
marci@1111
   385
	row_iter_map[row_it]=i;
marci@1111
   386
      } else { //a cucc vegere kell inzertalni mert nincs szabad hely
marci@1111
   387
	row_it=row_iter_map.push_back(i, VALID_CLASS);
marci@1031
   388
      }
marci@1111
   389
      return row_it;
marci@1074
   390
    }
marci@1074
   391
    /// \e
marci@1074
   392
    void eraseCol(const ColIt& col_it) {
marci@1074
   393
      col_iter_map.set(col_it, VALID_CLASS, INVALID_CLASS);
marci@1074
   394
      int cols[2];
marci@1074
   395
      cols[1]=col_iter_map[col_it];
marci@1074
   396
      _eraseCol(cols[1]);
marci@1074
   397
      col_iter_map[col_it]=0; //glpk specifikus, de kell ez??
marci@1074
   398
      ColIt it;
marci@1074
   399
      for (col_iter_map.first(it, VALID_CLASS); 
marci@1074
   400
	   col_iter_map.valid(it); col_iter_map.next(it)) {
marci@1074
   401
	if (col_iter_map[it]>cols[1]) --col_iter_map[it];
marci@1074
   402
      }
marci@1031
   403
    }
marci@1031
   404
    /// \e
marci@1074
   405
    void eraseRow(const RowIt& row_it) {
marci@1074
   406
      row_iter_map.set(row_it, VALID_CLASS, INVALID_CLASS);
marci@1074
   407
      int rows[2];
marci@1074
   408
      rows[1]=row_iter_map[row_it];
marci@1074
   409
      _eraseRow(rows[1]);
marci@1074
   410
      row_iter_map[row_it]=0; //glpk specifikus, de kell ez??
marci@1074
   411
      RowIt it;
marci@1074
   412
      for (row_iter_map.first(it, VALID_CLASS); 
marci@1074
   413
	   row_iter_map.valid(it); row_iter_map.next(it)) {
marci@1074
   414
	if (row_iter_map[it]>rows[1]) --row_iter_map[it];
marci@1074
   415
      }
marci@1074
   416
    }
marci@1031
   417
    /// \e
marci@1111
   418
    template <typename Begin, typename End>
marci@1111
   419
    void setRowCoeffs(RowIt row_it, Begin begin, End end) {
marci@1111
   420
      std::vector<std::pair<int, double> > coeffs;
marci@1111
   421
      for ( ; begin!=end; ++begin) {
marci@1111
   422
	coeffs.push_back(std::
marci@1111
   423
			 make_pair(col_iter_map[begin->first], begin->second));
marci@1111
   424
      }
marci@1111
   425
      _setRowCoeffs(row_iter_map[row_it], coeffs);
marci@1111
   426
    }
marci@1111
   427
    /// \e
marci@1111
   428
    template <typename Begin, typename End>
marci@1111
   429
    void setColCoeffs(ColIt col_it, Begin begin, End end) {
marci@1111
   430
      std::vector<std::pair<int, double> > coeffs;
marci@1111
   431
      for ( ; begin!=end; ++begin) {
marci@1111
   432
	coeffs.push_back(std::
marci@1111
   433
			 make_pair(row_iter_map[begin->first], begin->second));
marci@1111
   434
      }
marci@1111
   435
      _setColCoeffs(col_iter_map[col_it], coeffs);
marci@1111
   436
    }
marci@1111
   437
    /// \e
marci@1110
   438
    void setColLowerBound(ColIt col_it, _Value lo) {
marci@1110
   439
      _setColLowerBound(col_iter_map[col_it], lo);
marci@1110
   440
    }
marci@1110
   441
    /// \e
marci@1111
   442
    _Value getColLowerBound(ColIt col_it) {
marci@1111
   443
      return _getColLowerBound(col_iter_map[col_it]);
marci@1111
   444
    }
marci@1111
   445
    /// \e
marci@1110
   446
    void setColUpperBound(ColIt col_it, _Value up) {
marci@1110
   447
      _setColUpperBound(col_iter_map[col_it], up);
marci@1110
   448
    }
marci@1110
   449
    /// \e
marci@1110
   450
    _Value getColUpperBound(ColIt col_it) {      
marci@1110
   451
      return _getColUpperBound(col_iter_map[col_it]);
marci@1110
   452
    }
marci@1110
   453
    /// \e
marci@1111
   454
    void setRowLowerBound(RowIt row_it, _Value lo) {
marci@1111
   455
      _setRowLowerBound(row_iter_map[row_it], lo);
marci@1081
   456
    }
marci@1031
   457
    /// \e
marci@1111
   458
    _Value getRowLowerBound(RowIt row_it) {
marci@1111
   459
      return _getRowLowerBound(row_iter_map[row_it]);
marci@1111
   460
    }
marci@1111
   461
    /// \e
marci@1111
   462
    void setRowUpperBound(RowIt row_it, _Value up) {
marci@1111
   463
      _setRowUpperBound(row_iter_map[row_it], up);
marci@1111
   464
    }
marci@1111
   465
    /// \e
marci@1111
   466
    _Value getRowUpperBound(RowIt row_it) {      
marci@1111
   467
      return _getRowUpperBound(row_iter_map[row_it]);
marci@1081
   468
    }
marci@1031
   469
    /// \e
marci@1081
   470
    void setObjCoef(const ColIt& col_it, _Value obj_coef) {
marci@1081
   471
      _setObjCoef(col_iter_map[col_it], obj_coef);
marci@1081
   472
    }
marci@1031
   473
    /// \e
marci@1081
   474
    _Value getObjCoef(const ColIt& col_it) {
marci@1081
   475
      return _getObjCoef(col_iter_map[col_it]);
marci@1081
   476
    }
marci@1081
   477
marci@1112
   478
    //SOLUTION RETRIEVING FUNCTIONS
marci@1112
   479
marci@1112
   480
    /// \e
marci@1112
   481
    _Value getPrimal(const ColIt& col_it) {
marci@1112
   482
      return _getPrimal(col_iter_map[col_it]);
marci@1112
   483
    }    
marci@1112
   484
marci@1112
   485
    //@}
marci@1112
   486
marci@1112
   487
    /*! @name User friend interface
marci@1112
   488
      Problem manipulating functions in the user friend interface
marci@1112
   489
    */
marci@1112
   490
    //@{
marci@1112
   491
marci@1112
   492
    //EXPRESSION TYPES
marci@1099
   493
marci@1099
   494
    /// \e
marci@1099
   495
    typedef Expr<ColIt, _Value> Expression;
marci@1099
   496
    /// \e
marci@1099
   497
    typedef Expr<RowIt, _Value> DualExpression;
marci@1112
   498
marci@1112
   499
    //MATRIX MANIPULATING FUNCTIONS
marci@1112
   500
marci@1099
   501
    /// \e
marci@1099
   502
    void setRowCoeffs(RowIt row_it, const Expression& expr) {
marci@1099
   503
      std::vector<std::pair<int, _Value> > row_coeffs;
marci@1099
   504
      for(typename Expression::Data::const_iterator i=expr.data.begin(); 
marci@1099
   505
	  i!=expr.data.end(); ++i) {
marci@1099
   506
	row_coeffs.push_back(std::make_pair
marci@1099
   507
			     (col_iter_map[(*i).first], (*i).second));
marci@1099
   508
      }
marci@1099
   509
      _setRowCoeffs(row_iter_map[row_it], row_coeffs);
marci@1099
   510
    }
marci@1099
   511
    /// \e
marci@1099
   512
    void setColCoeffs(ColIt col_it, const DualExpression& expr) {
marci@1099
   513
      std::vector<std::pair<int, _Value> > col_coeffs;
marci@1099
   514
      for(typename DualExpression::Data::const_iterator i=expr.data.begin(); 
marci@1099
   515
	  i!=expr.data.end(); ++i) {
marci@1099
   516
	col_coeffs.push_back(std::make_pair
marci@1099
   517
			     (row_iter_map[(*i).first], (*i).second));
marci@1099
   518
      }
marci@1099
   519
      _setColCoeffs(col_iter_map[col_it], col_coeffs);
marci@1099
   520
    }
marci@1099
   521
    /// \e
marci@1099
   522
    void setObjCoeffs(const Expression& expr) {
marci@1099
   523
      for(typename Expression::Data::const_iterator i=expr.data.begin(); 
marci@1099
   524
	  i!=expr.data.end(); ++i) {
marci@1099
   525
	setObjCoef((*i).first, (*i).second);
marci@1099
   526
      }
marci@1099
   527
    }
marci@1112
   528
    //@}
marci@1031
   529
  };
marci@1031
   530
  
marci@1104
   531
  template <typename _Value>
marci@1104
   532
  const _Value LPSolverBase<_Value>::INF=std::numeric_limits<_Value>::infinity();
marci@1104
   533
marci@1048
   534
marci@1111
   535
  /// \brief Wrapper for GLPK solver
marci@1031
   536
  /// 
marci@1111
   537
  /// This class implements a lemon wrapper for GLPK.
marci@1081
   538
  class LPGLPK : public LPSolverBase<double> {
marci@1031
   539
  public:
marci@1048
   540
    typedef LPSolverBase<double> Parent;
marci@1031
   541
marci@1031
   542
  public:
marci@1031
   543
    /// \e
marci@1031
   544
    LPX* lp;
marci@1031
   545
marci@1031
   546
  public:
marci@1031
   547
    /// \e
marci@1081
   548
    LPGLPK() : Parent(), 
marci@1031
   549
			lp(lpx_create_prob()) {
marci@1031
   550
      lpx_set_int_parm(lp, LPX_K_DUAL, 1);
marci@1031
   551
    }
marci@1031
   552
    /// \e
marci@1081
   553
    ~LPGLPK() {
marci@1031
   554
      lpx_delete_prob(lp);
marci@1031
   555
    }
marci@1081
   556
marci@1081
   557
    //MATRIX INDEPEDENT MANIPULATING FUNCTIONS
marci@1081
   558
marci@1031
   559
    /// \e
marci@1031
   560
    void setMinimize() { 
marci@1031
   561
      lpx_set_obj_dir(lp, LPX_MIN);
marci@1031
   562
    }
marci@1031
   563
    /// \e
marci@1031
   564
    void setMaximize() { 
marci@1031
   565
      lpx_set_obj_dir(lp, LPX_MAX);
marci@1031
   566
    }
marci@1081
   567
marci@1081
   568
    //LOW LEVEL INTERFACE, MATRIX MANIPULATING FUNCTIONS
marci@1081
   569
marci@1074
   570
  protected:
marci@1031
   571
    /// \e
marci@1074
   572
    int _addCol() { 
marci@1110
   573
      int i=lpx_add_cols(lp, 1);
marci@1110
   574
      _setColLowerBound(i, -INF);
marci@1110
   575
      _setColUpperBound(i, INF);
marci@1110
   576
      return i;
marci@1031
   577
    }
marci@1031
   578
    /// \e
marci@1074
   579
    int _addRow() { 
marci@1110
   580
      int i=lpx_add_rows(lp, 1);
marci@1110
   581
      return i;
marci@1074
   582
    }
marci@1074
   583
    /// \e
marci@1081
   584
    virtual void _setRowCoeffs(int i, 
marci@1104
   585
			       const std::vector<std::pair<int, double> >& coeffs) {
marci@1074
   586
      int mem_length=1+colNum();
marci@1074
   587
      int* indices = new int[mem_length];
marci@1074
   588
      double* doubles = new double[mem_length];
marci@1074
   589
      int length=0;
marci@1074
   590
      for (std::vector<std::pair<int, double> >::
marci@1074
   591
	     const_iterator it=coeffs.begin(); it!=coeffs.end(); ++it) {
marci@1074
   592
	++length;
marci@1074
   593
	indices[length]=it->first;
marci@1074
   594
	doubles[length]=it->second;
marci@1081
   595
// 	std::cout << "  " << indices[length] << " " 
marci@1081
   596
// 		  << doubles[length] << std::endl;
marci@1031
   597
      }
marci@1081
   598
//      std::cout << i << " " << length << std::endl;
marci@1074
   599
      lpx_set_mat_row(lp, i, length, indices, doubles);
marci@1074
   600
      delete [] indices;
marci@1074
   601
      delete [] doubles;
marci@1031
   602
    }
marci@1074
   603
    /// \e
marci@1081
   604
    virtual void _setColCoeffs(int i, 
marci@1104
   605
			       const std::vector<std::pair<int, double> >& coeffs) {
marci@1074
   606
      int mem_length=1+rowNum();
marci@1074
   607
      int* indices = new int[mem_length];
marci@1074
   608
      double* doubles = new double[mem_length];
marci@1074
   609
      int length=0;
marci@1074
   610
      for (std::vector<std::pair<int, double> >::
marci@1074
   611
	     const_iterator it=coeffs.begin(); it!=coeffs.end(); ++it) {
marci@1074
   612
	++length;
marci@1074
   613
	indices[length]=it->first;
marci@1074
   614
	doubles[length]=it->second;
marci@1074
   615
      }
marci@1074
   616
      lpx_set_mat_col(lp, i, length, indices, doubles);
marci@1074
   617
      delete [] indices;
marci@1074
   618
      delete [] doubles;
marci@1031
   619
    }
marci@1031
   620
    /// \e
marci@1074
   621
    virtual void _eraseCol(int i) {
marci@1031
   622
      int cols[2];
marci@1074
   623
      cols[1]=i;
marci@1031
   624
      lpx_del_cols(lp, 1, cols);
marci@1031
   625
    }
marci@1074
   626
    virtual void _eraseRow(int i) {
marci@1031
   627
      int rows[2];
marci@1074
   628
      rows[1]=i;
marci@1031
   629
      lpx_del_rows(lp, 1, rows);
marci@1031
   630
    }
marci@1110
   631
    virtual void _setColLowerBound(int i, double lo) {
marci@1110
   632
      if (lo==INF) {
marci@1110
   633
	//FIXME error
marci@1110
   634
      }
marci@1110
   635
      int b=lpx_get_col_type(lp, i);
marci@1110
   636
      double up=lpx_get_col_ub(lp, i);	
marci@1110
   637
      if (lo==-INF) {
marci@1110
   638
	switch (b) {
marci@1110
   639
	case LPX_FR:
marci@1110
   640
	case LPX_LO:
marci@1110
   641
	  lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
marci@1110
   642
	  break;
marci@1110
   643
	case LPX_UP:
marci@1110
   644
	  break;
marci@1110
   645
	case LPX_DB:
marci@1110
   646
	case LPX_FX:
marci@1110
   647
	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
marci@1110
   648
	  break;
marci@1110
   649
	default: ;
marci@1110
   650
	  //FIXME error
marci@1110
   651
	}
marci@1110
   652
      } else {
marci@1110
   653
	switch (b) {
marci@1110
   654
	case LPX_FR:
marci@1110
   655
	case LPX_LO:
marci@1110
   656
	  lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
marci@1110
   657
	  break;
marci@1110
   658
	case LPX_UP:	  
marci@1110
   659
	case LPX_DB:
marci@1110
   660
	case LPX_FX:
marci@1110
   661
	  if (lo==up) 
marci@1110
   662
	    lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
marci@1110
   663
	  else 
marci@1110
   664
	    lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
marci@1110
   665
	  break;
marci@1110
   666
	default: ;
marci@1110
   667
	  //FIXME error
marci@1110
   668
	}
marci@1110
   669
      }
marci@1110
   670
    }
marci@1111
   671
    virtual double _getColLowerBound(int i) {
marci@1111
   672
      int b=lpx_get_col_type(lp, i);
marci@1111
   673
      switch (b) {
marci@1111
   674
      case LPX_FR:
marci@1111
   675
	return -INF;
marci@1111
   676
      case LPX_LO:
marci@1111
   677
	return lpx_get_col_lb(lp, i);
marci@1111
   678
      case LPX_UP:
marci@1111
   679
	return -INF;
marci@1111
   680
      case LPX_DB:
marci@1111
   681
      case LPX_FX:
marci@1111
   682
	return lpx_get_col_lb(lp, i);
marci@1111
   683
      default: ;
marci@1111
   684
	//FIXME error
marci@1111
   685
	return 0.0;
marci@1111
   686
      }
marci@1111
   687
    }
marci@1110
   688
    virtual void _setColUpperBound(int i, double up) {
marci@1110
   689
      if (up==-INF) {
marci@1110
   690
	//FIXME error
marci@1110
   691
      }
marci@1110
   692
      int b=lpx_get_col_type(lp, i);
marci@1110
   693
      double lo=lpx_get_col_lb(lp, i);
marci@1110
   694
      if (up==INF) {
marci@1110
   695
	switch (b) {
marci@1110
   696
	case LPX_FR:
marci@1110
   697
	case LPX_LO:
marci@1110
   698
	  break;
marci@1110
   699
	case LPX_UP:
marci@1110
   700
	  lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
marci@1110
   701
	  break;
marci@1110
   702
	case LPX_DB:
marci@1110
   703
	case LPX_FX:
marci@1110
   704
	  lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
marci@1110
   705
	  break;
marci@1110
   706
	default: ;
marci@1110
   707
	  //FIXME error
marci@1110
   708
	}
marci@1110
   709
      } else {
marci@1110
   710
	switch (b) {
marci@1110
   711
	case LPX_FR:
marci@1110
   712
	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
marci@1110
   713
	case LPX_LO:
marci@1110
   714
	  if (lo==up) 
marci@1110
   715
	    lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
marci@1110
   716
	  else
marci@1110
   717
	    lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
marci@1110
   718
	  break;
marci@1110
   719
	case LPX_UP:
marci@1110
   720
	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
marci@1110
   721
	  break;
marci@1110
   722
	case LPX_DB:
marci@1110
   723
	case LPX_FX:
marci@1110
   724
	  if (lo==up) 
marci@1110
   725
	    lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
marci@1110
   726
	  else 
marci@1110
   727
	    lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
marci@1110
   728
	  break;
marci@1110
   729
	default: ;
marci@1110
   730
	  //FIXME error
marci@1110
   731
	}
marci@1110
   732
      }
marci@1110
   733
    }
marci@1110
   734
    virtual double _getColUpperBound(int i) {
marci@1110
   735
      int b=lpx_get_col_type(lp, i);
marci@1110
   736
      switch (b) {
marci@1110
   737
      case LPX_FR:
marci@1110
   738
      case LPX_LO:
marci@1110
   739
	return INF;
marci@1110
   740
      case LPX_UP:
marci@1110
   741
      case LPX_DB:
marci@1110
   742
      case LPX_FX:
marci@1110
   743
	return lpx_get_col_ub(lp, i);
marci@1110
   744
      default: ;
marci@1110
   745
	//FIXME error
marci@1110
   746
	return 0.0;
marci@1110
   747
      }
marci@1110
   748
    }
marci@1111
   749
    virtual void _setRowLowerBound(int i, double lo) {
marci@1111
   750
      if (lo==INF) {
marci@1111
   751
	//FIXME error
marci@1081
   752
      }
marci@1111
   753
      int b=lpx_get_row_type(lp, i);
marci@1111
   754
      double up=lpx_get_row_ub(lp, i);	
marci@1111
   755
      if (lo==-INF) {
marci@1111
   756
	switch (b) {
marci@1111
   757
	case LPX_FR:
marci@1111
   758
	case LPX_LO:
marci@1111
   759
	  lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
marci@1111
   760
	  break;
marci@1111
   761
	case LPX_UP:
marci@1111
   762
	  break;
marci@1111
   763
	case LPX_DB:
marci@1111
   764
	case LPX_FX:
marci@1111
   765
	  lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
marci@1111
   766
	  break;
marci@1111
   767
	default: ;
marci@1111
   768
	  //FIXME error
marci@1111
   769
	}
marci@1111
   770
      } else {
marci@1111
   771
	switch (b) {
marci@1111
   772
	case LPX_FR:
marci@1111
   773
	case LPX_LO:
marci@1111
   774
	  lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
marci@1111
   775
	  break;
marci@1111
   776
	case LPX_UP:	  
marci@1111
   777
	case LPX_DB:
marci@1111
   778
	case LPX_FX:
marci@1111
   779
	  if (lo==up) 
marci@1111
   780
	    lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
marci@1111
   781
	  else 
marci@1111
   782
	    lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
marci@1111
   783
	  break;
marci@1111
   784
	default: ;
marci@1111
   785
	  //FIXME error
marci@1111
   786
	}
marci@1081
   787
      }
marci@1111
   788
    }
marci@1111
   789
    virtual double _getRowLowerBound(int i) {
marci@1111
   790
      int b=lpx_get_row_type(lp, i);
marci@1111
   791
      switch (b) {
marci@1111
   792
      case LPX_FR:
marci@1111
   793
	return -INF;
marci@1111
   794
      case LPX_LO:
marci@1111
   795
	return lpx_get_row_lb(lp, i);
marci@1111
   796
      case LPX_UP:
marci@1111
   797
	return -INF;
marci@1111
   798
      case LPX_DB:
marci@1111
   799
      case LPX_FX:
marci@1111
   800
	return lpx_get_row_lb(lp, i);
marci@1111
   801
      default: ;
marci@1111
   802
	//FIXME error
marci@1111
   803
	return 0.0;
marci@1111
   804
      }
marci@1111
   805
    }
marci@1111
   806
    virtual void _setRowUpperBound(int i, double up) {
marci@1111
   807
      if (up==-INF) {
marci@1111
   808
	//FIXME error
marci@1111
   809
      }
marci@1111
   810
      int b=lpx_get_row_type(lp, i);
marci@1111
   811
      double lo=lpx_get_row_lb(lp, i);
marci@1111
   812
      if (up==INF) {
marci@1111
   813
	switch (b) {
marci@1111
   814
	case LPX_FR:
marci@1111
   815
	case LPX_LO:
marci@1111
   816
	  break;
marci@1111
   817
	case LPX_UP:
marci@1111
   818
	  lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
marci@1111
   819
	  break;
marci@1111
   820
	case LPX_DB:
marci@1111
   821
	case LPX_FX:
marci@1111
   822
	  lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
marci@1111
   823
	  break;
marci@1111
   824
	default: ;
marci@1111
   825
	  //FIXME error
marci@1111
   826
	}
marci@1111
   827
      } else {
marci@1111
   828
	switch (b) {
marci@1111
   829
	case LPX_FR:
marci@1111
   830
	  lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
marci@1111
   831
	case LPX_LO:
marci@1111
   832
	  if (lo==up) 
marci@1111
   833
	    lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
marci@1111
   834
	  else
marci@1111
   835
	    lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
marci@1111
   836
	  break;
marci@1111
   837
	case LPX_UP:
marci@1111
   838
	  lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
marci@1111
   839
	  break;
marci@1111
   840
	case LPX_DB:
marci@1111
   841
	case LPX_FX:
marci@1111
   842
	  if (lo==up) 
marci@1111
   843
	    lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
marci@1111
   844
	  else 
marci@1111
   845
	    lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
marci@1111
   846
	  break;
marci@1111
   847
	default: ;
marci@1111
   848
	  //FIXME error
marci@1111
   849
	}
marci@1111
   850
      }
marci@1111
   851
    }
marci@1111
   852
    virtual double _getRowUpperBound(int i) {
marci@1111
   853
      int b=lpx_get_row_type(lp, i);
marci@1111
   854
      switch (b) {
marci@1111
   855
      case LPX_FR:
marci@1111
   856
      case LPX_LO:
marci@1111
   857
	return INF;
marci@1111
   858
      case LPX_UP:
marci@1111
   859
      case LPX_DB:
marci@1111
   860
      case LPX_FX:
marci@1111
   861
	return lpx_get_row_ub(lp, i);
marci@1111
   862
      default: ;
marci@1111
   863
	//FIXME error
marci@1111
   864
	return 0.0;
marci@1111
   865
      }
marci@1111
   866
    }
marci@1031
   867
    /// \e
marci@1081
   868
    virtual double _getObjCoef(int i) { 
marci@1081
   869
      return lpx_get_obj_coef(lp, i);
marci@1031
   870
    }
marci@1031
   871
    /// \e
marci@1081
   872
    virtual void _setObjCoef(int i, double obj_coef) { 
marci@1081
   873
      lpx_set_obj_coef(lp, i, obj_coef);
marci@1031
   874
    }
marci@1081
   875
  public:
marci@1031
   876
    /// \e
marci@1031
   877
    void solveSimplex() { lpx_simplex(lp); }
marci@1031
   878
    /// \e
marci@1031
   879
    void solvePrimalSimplex() { lpx_simplex(lp); }
marci@1031
   880
    /// \e
marci@1031
   881
    void solveDualSimplex() { lpx_simplex(lp); }
marci@1031
   882
    /// \e
marci@1081
   883
  protected:
marci@1081
   884
    virtual double _getPrimal(int i) {
marci@1081
   885
      return lpx_get_col_prim(lp, i);
marci@1031
   886
    }
marci@1081
   887
  public:
marci@1031
   888
    /// \e
marci@1031
   889
    double getObjVal() { return lpx_get_obj_val(lp); }
marci@1031
   890
    /// \e
marci@1031
   891
    int rowNum() const { return lpx_get_num_rows(lp); }
marci@1031
   892
    /// \e
marci@1031
   893
    int colNum() const { return lpx_get_num_cols(lp); }
marci@1031
   894
    /// \e
marci@1031
   895
    int warmUp() { return lpx_warm_up(lp); }
marci@1031
   896
    /// \e
marci@1031
   897
    void printWarmUpStatus(int i) {
marci@1031
   898
      switch (i) {
marci@1031
   899
      case LPX_E_OK: cout << "LPX_E_OK" << endl; break;
marci@1031
   900
      case LPX_E_EMPTY: cout << "LPX_E_EMPTY" << endl; break;	
marci@1031
   901
      case LPX_E_BADB: cout << "LPX_E_BADB" << endl; break;
marci@1031
   902
      case LPX_E_SING: cout << "LPX_E_SING" << endl; break;
marci@1031
   903
      }
marci@1031
   904
    }
marci@1031
   905
    /// \e
marci@1031
   906
    int getPrimalStatus() { return lpx_get_prim_stat(lp); }
marci@1031
   907
    /// \e
marci@1031
   908
    void printPrimalStatus(int i) {
marci@1031
   909
      switch (i) {
marci@1031
   910
      case LPX_P_UNDEF: cout << "LPX_P_UNDEF" << endl; break;
marci@1031
   911
      case LPX_P_FEAS: cout << "LPX_P_FEAS" << endl; break;	
marci@1031
   912
      case LPX_P_INFEAS: cout << "LPX_P_INFEAS" << endl; break;
marci@1031
   913
      case LPX_P_NOFEAS: cout << "LPX_P_NOFEAS" << endl; break;
marci@1031
   914
      }
marci@1031
   915
    }
marci@1031
   916
    /// \e
marci@1031
   917
    int getDualStatus() { return lpx_get_dual_stat(lp); }
marci@1031
   918
    /// \e
marci@1031
   919
    void printDualStatus(int i) {
marci@1031
   920
      switch (i) {
marci@1031
   921
      case LPX_D_UNDEF: cout << "LPX_D_UNDEF" << endl; break;
marci@1031
   922
      case LPX_D_FEAS: cout << "LPX_D_FEAS" << endl; break;	
marci@1031
   923
      case LPX_D_INFEAS: cout << "LPX_D_INFEAS" << endl; break;
marci@1031
   924
      case LPX_D_NOFEAS: cout << "LPX_D_NOFEAS" << endl; break;
marci@1031
   925
      }
marci@1031
   926
    }
marci@1031
   927
    /// Returns the status of the slack variable assigned to row \c row_it.
marci@1031
   928
    int getRowStat(const RowIt& row_it) { 
marci@1031
   929
      return lpx_get_row_stat(lp, row_iter_map[row_it]); 
marci@1031
   930
    }
marci@1031
   931
    /// \e
marci@1031
   932
    void printRowStatus(int i) {
marci@1031
   933
      switch (i) {
marci@1031
   934
      case LPX_BS: cout << "LPX_BS" << endl; break;
marci@1031
   935
      case LPX_NL: cout << "LPX_NL" << endl; break;	
marci@1031
   936
      case LPX_NU: cout << "LPX_NU" << endl; break;
marci@1031
   937
      case LPX_NF: cout << "LPX_NF" << endl; break;
marci@1031
   938
      case LPX_NS: cout << "LPX_NS" << endl; break;
marci@1031
   939
      }
marci@1031
   940
    }
marci@1031
   941
    /// Returns the status of the variable assigned to column \c col_it.
marci@1031
   942
    int getColStat(const ColIt& col_it) { 
marci@1031
   943
      return lpx_get_col_stat(lp, col_iter_map[col_it]); 
marci@1031
   944
    }
marci@1031
   945
    /// \e
marci@1031
   946
    void printColStatus(int i) {
marci@1031
   947
      switch (i) {
marci@1031
   948
      case LPX_BS: cout << "LPX_BS" << endl; break;
marci@1031
   949
      case LPX_NL: cout << "LPX_NL" << endl; break;	
marci@1031
   950
      case LPX_NU: cout << "LPX_NU" << endl; break;
marci@1031
   951
      case LPX_NF: cout << "LPX_NF" << endl; break;
marci@1031
   952
      case LPX_NS: cout << "LPX_NS" << endl; break;
marci@1031
   953
      }
marci@1031
   954
    }
marci@1031
   955
  };
marci@1031
   956
  
marci@1031
   957
  /// @}
marci@1031
   958
marci@1031
   959
} //namespace lemon
marci@1031
   960
marci@1031
   961
#endif //LEMON_LP_SOLVER_WRAPPER_H