Changeset 1144:1cfabf245433 in lemon-0.x for src/work/marci/lp/max_flow_expression.cc
- Timestamp:
- 02/10/05 19:53:30 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1545
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/lp/max_flow_expression.cc
r1143 r1144 47 47 LPSolver lp; 48 48 lp.setMaximize(); 49 typedef LPSolver::Col It ColIt;50 typedef LPSolver::Row It RowIt;51 typedef Graph::EdgeMap<Col It> EdgeIndexMap;52 typedef Graph::NodeMap<Row It> NodeIndexMap;49 typedef LPSolver::Col Col; 50 typedef LPSolver::Row Row; 51 typedef Graph::EdgeMap<Col> EdgeIndexMap; 52 typedef Graph::NodeMap<Row> NodeIndexMap; 53 53 EdgeIndexMap edge_index_map(g); 54 54 NodeIndexMap node_index_map(g); … … 57 57 // nonnegativity of flow and capacity function 58 58 for (Graph::EdgeIt e(g); e!=INVALID; ++e) { 59 Col It col_it=lp.addCol();60 edge_index_map.set(e, col _it);59 Col col=lp.addCol(); 60 edge_index_map.set(e, col); 61 61 // interesting property in GLPK: 62 62 // if you change the order of the following two lines, the 63 63 // two runs of GLPK are extremely different 64 lp.setColLowerBound(col _it, 0);65 lp.setColUpperBound(col _it, cap[e]);64 lp.setColLowerBound(col, 0); 65 lp.setColUpperBound(col, cap[e]); 66 66 } 67 67 … … 78 78 // flow conservation constraints 79 79 if ((n!=s) && (n!=t)) { 80 RowIt row_it=lp.addRow(); 81 node_index_map.set(n, row_it); 82 lp.setRowCoeffs(row_it, expr); 83 lp.setRowLowerBound(row_it, 0.0); 84 lp.setRowUpperBound(row_it, 0.0); 85 // cout << expr << endl; 86 // { 87 // LPSolver::Expression expr; 88 // lp.getRowCoeffs(node_index_map[n], expr); 89 // cout << expr << endl; 90 // } 80 node_index_map.set(n, lp.addRow(expr == 0.0)); 91 81 } 92 82 } 93 83 lp.solveSimplex(); 94 // cout << "num of nodes: " << countNodes(g) << endl;95 // cout << "num of edges: " << countEdges(g) << endl;96 // cout << "num of rows: " << lp.rowNum() << endl;97 // cout << "num of rows: " << lp.int_row_map.size() << endl;98 // for (int i=0; i<lp.int_row_map.size(); ++i) {99 // cout << lp.int_row_map[i] << " " << endl;100 // }101 // cout << "num of columns: " << lp.colNum() << endl;102 // cout << "num of columns: " << lp.int_col_map.size() << endl;103 // for (int i=0; i<lp.int_col_map.size(); ++i) {104 // cout << lp.int_col_map[i] << " " << endl;105 // }106 84 cout << "elapsed time: " << ts << endl; 107 // Graph::NodeIt n(g);108 // ++n;109 // for(Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) {110 // cout << edge_index_map[e] << endl;111 // }112 // for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) {113 // cout << edge_index_map[e] << endl;114 // }115 // LPSolver::DualExpression expr;116 // lp.getRowCoeffs(node_index_map[n], expr);117 // cout << expr << endl;118 85 }
Note: See TracChangeset
for help on using the changeset viewer.