1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/work/marci/lp/lp_solver_wrapper_2.h Mon Dec 06 11:56:10 2004 +0000
1.3 @@ -0,0 +1,547 @@
1.4 +// -*- c++ -*-
1.5 +#ifndef LEMON_LP_SOLVER_WRAPPER_H
1.6 +#define LEMON_LP_SOLVER_WRAPPER_H
1.7 +
1.8 +///\ingroup misc
1.9 +///\file
1.10 +///\brief Dijkstra algorithm.
1.11 +
1.12 +// #include <stdio.h>
1.13 +#include <stdlib.h>
1.14 +// #include <stdio>
1.15 +//#include <stdlib>
1.16 +extern "C" {
1.17 +#include "glpk.h"
1.18 +}
1.19 +
1.20 +#include <iostream>
1.21 +#include <vector>
1.22 +#include <string>
1.23 +#include <list>
1.24 +#include <memory>
1.25 +#include <utility>
1.26 +
1.27 +//#include <sage_graph.h>
1.28 +//#include <lemon/list_graph.h>
1.29 +//#include <lemon/graph_wrapper.h>
1.30 +#include <lemon/invalid.h>
1.31 +//#include <bfs_dfs.h>
1.32 +//#include <stp.h>
1.33 +//#include <lemon/max_flow.h>
1.34 +//#include <augmenting_flow.h>
1.35 +//#include <iter_map.h>
1.36 +
1.37 +using std::cout;
1.38 +using std::cin;
1.39 +using std::endl;
1.40 +
1.41 +namespace lemon {
1.42 +
1.43 +
1.44 + /// \addtogroup misc
1.45 + /// @{
1.46 +
1.47 + /// \brief A partitioned vector with iterable classes.
1.48 + ///
1.49 + /// This class implements a container in which the data is stored in an
1.50 + /// stl vector, the range is partitioned into sets and each set is
1.51 + /// doubly linked in a list.
1.52 + /// That is, each class is iterable by lemon iterators, and any member of
1.53 + /// the vector can bo moved to an other class.
1.54 + template <typename T>
1.55 + class IterablePartition {
1.56 + protected:
1.57 + struct Node {
1.58 + T data;
1.59 + int prev; //invalid az -1
1.60 + int next;
1.61 + };
1.62 + std::vector<Node> nodes;
1.63 + struct Tip {
1.64 + int first;
1.65 + int last;
1.66 + };
1.67 + std::vector<Tip> tips;
1.68 + public:
1.69 + /// The classes are indexed by integers from \c 0 to \c classNum()-1.
1.70 + int classNum() const { return tips.size(); }
1.71 + /// This lemon style iterator iterates through a class.
1.72 + class ClassIt;
1.73 + /// Constructor. The number of classes is to be given which is fixed
1.74 + /// over the life of the container.
1.75 + /// The partition classes are indexed from 0 to class_num-1.
1.76 + IterablePartition(int class_num) {
1.77 + for (int i=0; i<class_num; ++i) {
1.78 + Tip t;
1.79 + t.first=t.last=-1;
1.80 + tips.push_back(t);
1.81 + }
1.82 + }
1.83 + protected:
1.84 + void befuz(ClassIt it, int class_id) {
1.85 + if (tips[class_id].first==-1) {
1.86 + if (tips[class_id].last==-1) {
1.87 + nodes[it.i].prev=nodes[it.i].next=-1;
1.88 + tips[class_id].first=tips[class_id].last=it.i;
1.89 + }
1.90 + } else {
1.91 + nodes[it.i].prev=tips[class_id].last;
1.92 + nodes[it.i].next=-1;
1.93 + nodes[tips[class_id].last].next=it.i;
1.94 + tips[class_id].last=it.i;
1.95 + }
1.96 + }
1.97 + void kifuz(ClassIt it, int class_id) {
1.98 + if (tips[class_id].first==it.i) {
1.99 + if (tips[class_id].last==it.i) {
1.100 + tips[class_id].first=tips[class_id].last=-1;
1.101 + } else {
1.102 + tips[class_id].first=nodes[it.i].next;
1.103 + nodes[nodes[it.i].next].prev=-1;
1.104 + }
1.105 + } else {
1.106 + if (tips[class_id].last==it.i) {
1.107 + tips[class_id].last=nodes[it.i].prev;
1.108 + nodes[nodes[it.i].prev].next=-1;
1.109 + } else {
1.110 + nodes[nodes[it.i].next].prev=nodes[it.i].prev;
1.111 + nodes[nodes[it.i].prev].next=nodes[it.i].next;
1.112 + }
1.113 + }
1.114 + }
1.115 + public:
1.116 + /// A new element with data \c t is pushed into the vector and into class
1.117 + /// \c class_id.
1.118 + ClassIt push_back(const T& t, int class_id) {
1.119 + Node n;
1.120 + n.data=t;
1.121 + nodes.push_back(n);
1.122 + int i=nodes.size()-1;
1.123 + befuz(i, class_id);
1.124 + return i;
1.125 + }
1.126 + /// A member is moved to an other class.
1.127 + void set(ClassIt it, int old_class_id, int new_class_id) {
1.128 + kifuz(it.i, old_class_id);
1.129 + befuz(it.i, new_class_id);
1.130 + }
1.131 + /// Returns the data pointed by \c it.
1.132 + T& operator[](ClassIt it) { return nodes[it.i].data; }
1.133 + /// Returns the data pointed by \c it.
1.134 + const T& operator[](ClassIt it) const { return nodes[it.i].data; }
1.135 + ///.
1.136 + class ClassIt {
1.137 + friend class IterablePartition;
1.138 + protected:
1.139 + int i;
1.140 + public:
1.141 + /// Default constructor.
1.142 + ClassIt() { }
1.143 + /// This constructor constructs an iterator which points
1.144 + /// to the member of th container indexed by the integer _i.
1.145 + ClassIt(const int& _i) : i(_i) { }
1.146 + /// Invalid constructor.
1.147 + ClassIt(const Invalid&) : i(-1) { }
1.148 + };
1.149 + /// First member of class \c class_id.
1.150 + ClassIt& first(ClassIt& it, int class_id) const {
1.151 + it.i=tips[class_id].first;
1.152 + return it;
1.153 + }
1.154 + /// Next member.
1.155 + ClassIt& next(ClassIt& it) const {
1.156 + it.i=nodes[it.i].next;
1.157 + return it;
1.158 + }
1.159 + /// True iff the iterator is valid.
1.160 + bool valid(const ClassIt& it) const { return it.i!=-1; }
1.161 + };
1.162 +
1.163 + /*! \e
1.164 + */
1.165 + class LPSolverBase {
1.166 + public:
1.167 + /// \e
1.168 + typedef IterablePartition<int>::ClassIt RowIt;
1.169 + /// \e
1.170 + typedef IterablePartition<int>::ClassIt ColIt;
1.171 + protected:
1.172 + /// \e
1.173 + IterablePartition<int> row_iter_map;
1.174 + /// \e
1.175 + IterablePartition<int> col_iter_map;
1.176 + /// \e
1.177 + const int VALID_ID;
1.178 + /// \e
1.179 + const int INVALID_ID;
1.180 + public:
1.181 + /// \e
1.182 + LPSolverBase() : row_iter_map(2),
1.183 + col_iter_map(2),
1.184 + VALID_ID(0), INVALID_ID(1) { }
1.185 + /// \e
1.186 + virtual ~LPSolverBase() { }
1.187 + /// \e
1.188 + virtual void setMinimize() = 0;
1.189 + /// \e
1.190 + virtual void setMaximize() = 0;
1.191 + /// \e
1.192 + virtual RowIt addRow() = 0;
1.193 + /// \e
1.194 + virtual ColIt addCol() = 0;
1.195 + /// temporally, glpk style indexing
1.196 + virtual void setRowCoeffs(RowIt row_it, int num,
1.197 + int* indices, double* doubles) = 0;
1.198 + //pair<RowIt, double>-bol kell megadni egy std range-et
1.199 + /// \e
1.200 + template <typename Begin, typename End>
1.201 + void setRowCoeffs(RowIt row_it, Begin begin, End end) {
1.202 + int mem_length=1+colNum();
1.203 + int* indices = new int[mem_length];
1.204 + double* doubles = new double[mem_length];
1.205 + int length=0;
1.206 + for ( ; begin!=end; ++begin) {
1.207 + ++length;
1.208 + indices[length]=col_iter_map[begin->first];
1.209 + doubles[length]=begin->second;
1.210 + }
1.211 + setRowCoeffs(row_it, length, indices, doubles);
1.212 + delete [] indices;
1.213 + delete [] doubles;
1.214 + }
1.215 + /// temporally, glpk style indexing
1.216 + virtual void setColCoeffs(ColIt col_it, int num,
1.217 + int* indices, double* doubles) = 0;
1.218 + //pair<ColIt, double>-bol kell megadni egy std range-et
1.219 + /// \e
1.220 + template <typename Begin, typename End>
1.221 + void setColCoeffs(ColIt col_it, Begin begin, End end) {
1.222 + int mem_length=1+rowNum();
1.223 + int* indices = new int[mem_length];
1.224 + double* doubles = new double[mem_length];
1.225 + int length=0;
1.226 + for ( ; begin!=end; ++begin) {
1.227 + ++length;
1.228 + indices[length]=row_iter_map[begin->first];
1.229 + doubles[length]=begin->second;
1.230 + }
1.231 + setColCoeffs(col_it, length, indices, doubles);
1.232 + delete [] indices;
1.233 + delete [] doubles;
1.234 + }
1.235 + /// \e
1.236 + virtual void eraseCol(const ColIt& col_it) = 0;
1.237 + /// \e
1.238 + virtual void eraseRow(const RowIt& row_it) = 0;
1.239 + /// \e
1.240 + virtual void setColBounds(const ColIt& col_it, int bound_type,
1.241 + double lo, double up) =0;
1.242 + /// \e
1.243 + virtual double getObjCoef(const ColIt& col_it) = 0;
1.244 + /// \e
1.245 + virtual void setRowBounds(const RowIt& row_it, int bound_type,
1.246 + double lo, double up) = 0;
1.247 + /// \e
1.248 + virtual void setObjCoef(const ColIt& col_it, double obj_coef) = 0;
1.249 + /// \e
1.250 + virtual void solveSimplex() = 0;
1.251 + /// \e
1.252 + virtual void solvePrimalSimplex() = 0;
1.253 + /// \e
1.254 + virtual void solveDualSimplex() = 0;
1.255 + /// \e
1.256 + virtual double getPrimal(const ColIt& col_it) = 0;
1.257 + /// \e
1.258 + virtual double getObjVal() = 0;
1.259 + /// \e
1.260 + virtual int rowNum() const = 0;
1.261 + /// \e
1.262 + virtual int colNum() const = 0;
1.263 + /// \e
1.264 + virtual int warmUp() = 0;
1.265 + /// \e
1.266 + virtual void printWarmUpStatus(int i) = 0;
1.267 + /// \e
1.268 + virtual int getPrimalStatus() = 0;
1.269 + /// \e
1.270 + virtual void printPrimalStatus(int i) = 0;
1.271 + /// \e
1.272 + virtual int getDualStatus() = 0;
1.273 + /// \e
1.274 + virtual void printDualStatus(int i) = 0;
1.275 + /// Returns the status of the slack variable assigned to row \c row_it.
1.276 + virtual int getRowStat(const RowIt& row_it) = 0;
1.277 + /// \e
1.278 + virtual void printRowStatus(int i) = 0;
1.279 + /// Returns the status of the variable assigned to column \c col_it.
1.280 + virtual int getColStat(const ColIt& col_it) = 0;
1.281 + /// \e
1.282 + virtual void printColStatus(int i) = 0;
1.283 + };
1.284 +
1.285 + /// \brief Wrappers for LP solvers
1.286 + ///
1.287 + /// This class implements a lemon wrapper for glpk.
1.288 + /// Later other LP-solvers will be wrapped into lemon.
1.289 + /// The aim of this class is to give a general surface to different
1.290 + /// solvers, i.e. it makes possible to write algorithms using LP's,
1.291 + /// in which the solver can be changed to an other one easily.
1.292 + class LPSolverWrapper : public LPSolverBase {
1.293 + public:
1.294 + typedef LPSolverBase Parent;
1.295 +
1.296 + // class Row {
1.297 + // protected:
1.298 + // int i;
1.299 + // public:
1.300 + // Row() { }
1.301 + // Row(const Invalid&) : i(0) { }
1.302 + // Row(const int& _i) : i(_i) { }
1.303 + // operator int() const { return i; }
1.304 + // };
1.305 + // class RowIt : public Row {
1.306 + // public:
1.307 + // RowIt(const Row& row) : Row(row) { }
1.308 + // };
1.309 +
1.310 + // class Col {
1.311 + // protected:
1.312 + // int i;
1.313 + // public:
1.314 + // Col() { }
1.315 + // Col(const Invalid&) : i(0) { }
1.316 + // Col(const int& _i) : i(_i) { }
1.317 + // operator int() const { return i; }
1.318 + // };
1.319 + // class ColIt : public Col {
1.320 + // ColIt(const Col& col) : Col(col) { }
1.321 + // };
1.322 +
1.323 + public:
1.324 + /// \e
1.325 + LPX* lp;
1.326 +
1.327 + public:
1.328 + /// \e
1.329 + LPSolverWrapper() : LPSolverBase(),
1.330 + lp(lpx_create_prob()) {
1.331 + lpx_set_int_parm(lp, LPX_K_DUAL, 1);
1.332 + }
1.333 + /// \e
1.334 + ~LPSolverWrapper() {
1.335 + lpx_delete_prob(lp);
1.336 + }
1.337 + /// \e
1.338 + void setMinimize() {
1.339 + lpx_set_obj_dir(lp, LPX_MIN);
1.340 + }
1.341 + /// \e
1.342 + void setMaximize() {
1.343 + lpx_set_obj_dir(lp, LPX_MAX);
1.344 + }
1.345 + /// \e
1.346 + ColIt addCol() {
1.347 + int i=lpx_add_cols(lp, 1);
1.348 + ColIt col_it;
1.349 + col_iter_map.first(col_it, INVALID_ID);
1.350 + if (col_iter_map.valid(col_it)) { //van hasznalhato hely
1.351 + col_iter_map.set(col_it, INVALID_ID, VALID_ID);
1.352 + col_iter_map[col_it]=i;
1.353 + //col_id_to_lp_col_id[col_iter_map[col_it]]=i;
1.354 + } else { //a cucc vegere kell inzertalni mert nincs szabad hely
1.355 + //col_id_to_lp_col_id.push_back(i);
1.356 + //int j=col_id_to_lp_col_id.size()-1;
1.357 + col_it=col_iter_map.push_back(i, VALID_ID);
1.358 + }
1.359 + // edge_index_map.set(e, i);
1.360 + // lpx_set_col_bnds(lp, i, LPX_DB, 0.0, 1.0);
1.361 + // lpx_set_obj_coef(lp, i, cost[e]);
1.362 + return col_it;
1.363 + }
1.364 + /// \e
1.365 + RowIt addRow() {
1.366 + int i=lpx_add_rows(lp, 1);
1.367 + RowIt row_it;
1.368 + row_iter_map.first(row_it, INVALID_ID);
1.369 + if (row_iter_map.valid(row_it)) { //van hasznalhato hely
1.370 + row_iter_map.set(row_it, INVALID_ID, VALID_ID);
1.371 + row_iter_map[row_it]=i;
1.372 + } else { //a cucc vegere kell inzertalni mert nincs szabad hely
1.373 + row_it=row_iter_map.push_back(i, VALID_ID);
1.374 + }
1.375 + return row_it;
1.376 + }
1.377 + using Parent::setRowCoeffs;
1.378 + void setRowCoeffs(RowIt row_it, int length,
1.379 + int* indices, double* doubles) {
1.380 + lpx_set_mat_row(lp, row_iter_map[row_it], length, indices, doubles);
1.381 + }
1.382 + using Parent::setColCoeffs;
1.383 + void setColCoeffs(ColIt col_it, int length,
1.384 + int* indices, double* doubles) {
1.385 + lpx_set_mat_col(lp, col_iter_map[col_it], length, indices, doubles);
1.386 + }
1.387 + // //pair<RowIt, double>-bol kell megadni egy std range-et
1.388 + // /// \e
1.389 + // template <typename Begin, typename End>
1.390 + // void setColCoeffs(const ColIt& col_it,
1.391 + // Begin begin, End end) {
1.392 + // int mem_length=1+lpx_get_num_rows(lp);
1.393 + // int* indices = new int[mem_length];
1.394 + // double* doubles = new double[mem_length];
1.395 + // int length=0;
1.396 + // for ( ; begin!=end; ++begin) {
1.397 + // ++length;
1.398 + // indices[length]=row_iter_map[begin->first];
1.399 + // doubles[length]=begin->second;
1.400 + // }
1.401 + // lpx_set_mat_col(lp, col_iter_map[col_it], length, indices, doubles);
1.402 + // delete [] indices;
1.403 + // delete [] doubles;
1.404 + // }
1.405 + // //pair<ColIt, double>-bol kell megadni egy std range-et
1.406 + // /// \e
1.407 + // template <typename Begin, typename End>
1.408 + // void setRowCoeffs(const RowIt& row_it,
1.409 + // Begin begin, End end) {
1.410 + // int mem_length=1+lpx_get_num_cols(lp);
1.411 + // int* indices = new int[mem_length];
1.412 + // double* doubles = new double[mem_length];
1.413 + // int length=0;
1.414 + // for ( ; begin!=end; ++begin) {
1.415 + // ++length;
1.416 + // indices[length]=col_iter_map[begin->first];
1.417 + // doubles[length]=begin->second;
1.418 + // }
1.419 + // lpx_set_mat_row(lp, row_iter_map[row_it], length, indices, doubles);
1.420 + // delete [] indices;
1.421 + // delete [] doubles;
1.422 + // }
1.423 + /// \e
1.424 + void eraseCol(const ColIt& col_it) {
1.425 + col_iter_map.set(col_it, VALID_ID, INVALID_ID);
1.426 + int cols[2];
1.427 + cols[1]=col_iter_map[col_it];
1.428 + lpx_del_cols(lp, 1, cols);
1.429 + col_iter_map[col_it]=0; //glpk specifikus
1.430 + ColIt it;
1.431 + for (col_iter_map.first(it, VALID_ID);
1.432 + col_iter_map.valid(it); col_iter_map.next(it)) {
1.433 + if (col_iter_map[it]>cols[1]) --col_iter_map[it];
1.434 + }
1.435 + }
1.436 + /// \e
1.437 + void eraseRow(const RowIt& row_it) {
1.438 + row_iter_map.set(row_it, VALID_ID, INVALID_ID);
1.439 + int rows[2];
1.440 + rows[1]=row_iter_map[row_it];
1.441 + lpx_del_rows(lp, 1, rows);
1.442 + row_iter_map[row_it]=0; //glpk specifikus
1.443 + RowIt it;
1.444 + for (row_iter_map.first(it, VALID_ID);
1.445 + row_iter_map.valid(it); row_iter_map.next(it)) {
1.446 + if (row_iter_map[it]>rows[1]) --row_iter_map[it];
1.447 + }
1.448 + }
1.449 + /// \e
1.450 + void setColBounds(const ColIt& col_it, int bound_type,
1.451 + double lo, double up) {
1.452 + lpx_set_col_bnds(lp, col_iter_map[col_it], bound_type, lo, up);
1.453 + }
1.454 + /// \e
1.455 + double getObjCoef(const ColIt& col_it) {
1.456 + return lpx_get_obj_coef(lp, col_iter_map[col_it]);
1.457 + }
1.458 + /// \e
1.459 + void setRowBounds(const RowIt& row_it, int bound_type,
1.460 + double lo, double up) {
1.461 + lpx_set_row_bnds(lp, row_iter_map[row_it], bound_type, lo, up);
1.462 + }
1.463 + /// \e
1.464 + void setObjCoef(const ColIt& col_it, double obj_coef) {
1.465 + lpx_set_obj_coef(lp, col_iter_map[col_it], obj_coef);
1.466 + }
1.467 + /// \e
1.468 + void solveSimplex() { lpx_simplex(lp); }
1.469 + /// \e
1.470 + void solvePrimalSimplex() { lpx_simplex(lp); }
1.471 + /// \e
1.472 + void solveDualSimplex() { lpx_simplex(lp); }
1.473 + /// \e
1.474 + double getPrimal(const ColIt& col_it) {
1.475 + return lpx_get_col_prim(lp, col_iter_map[col_it]);
1.476 + }
1.477 + /// \e
1.478 + double getObjVal() { return lpx_get_obj_val(lp); }
1.479 + /// \e
1.480 + int rowNum() const { return lpx_get_num_rows(lp); }
1.481 + /// \e
1.482 + int colNum() const { return lpx_get_num_cols(lp); }
1.483 + /// \e
1.484 + int warmUp() { return lpx_warm_up(lp); }
1.485 + /// \e
1.486 + void printWarmUpStatus(int i) {
1.487 + switch (i) {
1.488 + case LPX_E_OK: cout << "LPX_E_OK" << endl; break;
1.489 + case LPX_E_EMPTY: cout << "LPX_E_EMPTY" << endl; break;
1.490 + case LPX_E_BADB: cout << "LPX_E_BADB" << endl; break;
1.491 + case LPX_E_SING: cout << "LPX_E_SING" << endl; break;
1.492 + }
1.493 + }
1.494 + /// \e
1.495 + int getPrimalStatus() { return lpx_get_prim_stat(lp); }
1.496 + /// \e
1.497 + void printPrimalStatus(int i) {
1.498 + switch (i) {
1.499 + case LPX_P_UNDEF: cout << "LPX_P_UNDEF" << endl; break;
1.500 + case LPX_P_FEAS: cout << "LPX_P_FEAS" << endl; break;
1.501 + case LPX_P_INFEAS: cout << "LPX_P_INFEAS" << endl; break;
1.502 + case LPX_P_NOFEAS: cout << "LPX_P_NOFEAS" << endl; break;
1.503 + }
1.504 + }
1.505 + /// \e
1.506 + int getDualStatus() { return lpx_get_dual_stat(lp); }
1.507 + /// \e
1.508 + void printDualStatus(int i) {
1.509 + switch (i) {
1.510 + case LPX_D_UNDEF: cout << "LPX_D_UNDEF" << endl; break;
1.511 + case LPX_D_FEAS: cout << "LPX_D_FEAS" << endl; break;
1.512 + case LPX_D_INFEAS: cout << "LPX_D_INFEAS" << endl; break;
1.513 + case LPX_D_NOFEAS: cout << "LPX_D_NOFEAS" << endl; break;
1.514 + }
1.515 + }
1.516 + /// Returns the status of the slack variable assigned to row \c row_it.
1.517 + int getRowStat(const RowIt& row_it) {
1.518 + return lpx_get_row_stat(lp, row_iter_map[row_it]);
1.519 + }
1.520 + /// \e
1.521 + void printRowStatus(int i) {
1.522 + switch (i) {
1.523 + case LPX_BS: cout << "LPX_BS" << endl; break;
1.524 + case LPX_NL: cout << "LPX_NL" << endl; break;
1.525 + case LPX_NU: cout << "LPX_NU" << endl; break;
1.526 + case LPX_NF: cout << "LPX_NF" << endl; break;
1.527 + case LPX_NS: cout << "LPX_NS" << endl; break;
1.528 + }
1.529 + }
1.530 + /// Returns the status of the variable assigned to column \c col_it.
1.531 + int getColStat(const ColIt& col_it) {
1.532 + return lpx_get_col_stat(lp, col_iter_map[col_it]);
1.533 + }
1.534 + /// \e
1.535 + void printColStatus(int i) {
1.536 + switch (i) {
1.537 + case LPX_BS: cout << "LPX_BS" << endl; break;
1.538 + case LPX_NL: cout << "LPX_NL" << endl; break;
1.539 + case LPX_NU: cout << "LPX_NU" << endl; break;
1.540 + case LPX_NF: cout << "LPX_NF" << endl; break;
1.541 + case LPX_NS: cout << "LPX_NS" << endl; break;
1.542 + }
1.543 + }
1.544 + };
1.545 +
1.546 + /// @}
1.547 +
1.548 +} //namespace lemon
1.549 +
1.550 +#endif //LEMON_LP_SOLVER_WRAPPER_H
2.1 --- a/src/work/marci/lp/max_flow_by_lp.cc Mon Dec 06 00:30:44 2004 +0000
2.2 +++ b/src/work/marci/lp/max_flow_by_lp.cc Mon Dec 06 11:56:10 2004 +0000
2.3 @@ -10,7 +10,7 @@
2.4 #include <lemon/preflow.h>
2.5 #include <augmenting_flow.h>
2.6 //#include <preflow_res.h>
2.7 -#include <lp_solver_wrapper.h>
2.8 +//#include <lp_solver_wrapper_2.h>
2.9 #include <min_cost_gen_flow.h>
2.10
2.11 // Use a DIMACS max flow file as stdin.
2.12 @@ -179,7 +179,7 @@
2.13 MinCostGenFlow<Graph, int, Excess, LCap>
2.14 min_cost(g, excess, lcap, cap, flow, cost);
2.15 min_cost.feasible();
2.16 - min_cost.run();
2.17 + min_cost.runByLP();
2.18
2.19 std::cout << "elapsed time: " << ts << std::endl;
2.20 std::cout << "flow value: "<< flow[e] << std::endl;
3.1 --- a/src/work/marci/lp/min_cost_gen_flow.h Mon Dec 06 00:30:44 2004 +0000
3.2 +++ b/src/work/marci/lp/min_cost_gen_flow.h Mon Dec 06 11:56:10 2004 +0000
3.3 @@ -14,7 +14,7 @@
3.4 //#include <augmenting_flow.h>
3.5 //#include <preflow_res.h>
3.6 #include <work/marci/merge_node_graph_wrapper.h>
3.7 -#include <work/marci/lp/lp_solver_wrapper.h>
3.8 +#include <work/marci/lp/lp_solver_wrapper_2.h>
3.9
3.10 namespace lemon {
3.11
3.12 @@ -211,10 +211,11 @@
3.13 return (expected>=min_cost_flow.flowValue());
3.14 }
3.15 void runByLP() {
3.16 - LPSolverWrapper lp;
3.17 + typedef LPSolverWrapper LPSolver;
3.18 + LPSolver lp;
3.19 lp.setMinimize();
3.20 - typedef LPSolverWrapper::ColIt ColIt;
3.21 - typedef LPSolverWrapper::RowIt RowIt;
3.22 + typedef LPSolver::ColIt ColIt;
3.23 + typedef LPSolver::RowIt RowIt;
3.24 typedef typename Graph::template EdgeMap<ColIt> EdgeIndexMap;
3.25 EdgeIndexMap edge_index_map(g);
3.26 PrimalMap<typename Graph::Edge, EdgeIndexMap> lp_flow(lp, edge_index_map);