An experimental LPSolverWrapper class which uses glpk. For a short
demo, max flow problems are solved with it. This demo does not
demonstrates, but the main aims of this class are row and column
generation capabilities, i.e. to be a core for easily
implementable branch-and-cut a column generetion algorithms.
5 #include <sage_graph.h>
6 #include <hugo/smart_graph.h>
7 #include <hugo/dimacs.h>
8 #include <hugo/time_measure.h>
9 //#include <graph_wrapper.h>
10 #include <hugo/max_flow.h>
11 //#include <preflow_res.h>
12 #include <for_each_macros.h>
16 // Use a DIMACS max flow file as stdin.
17 // read_dimacs_demo < dimacs_max_flow_file
20 int main(int, char **) {
22 typedef SageGraph MutableGraph;
24 typedef SmartGraph Graph;
25 // typedef ListGraph Graph;
26 typedef Graph::Node Node;
27 typedef Graph::EdgeIt EdgeIt;
32 Graph::EdgeMap<int> cap(g);
33 //readDimacsMaxFlow(std::cin, g, s, t, cap);
34 readDimacs(std::cin, g, cap, s, t);
36 Graph::EdgeMap<int> flow(g); //0 flow
37 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
38 max_flow_test(g, s, t, cap, flow);
41 std::cout << "preflow ..." << std::endl;
42 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
44 max_flow_test.preflowPhase1(MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::ZERO_FLOW);
45 std::cout << "elapsed time: " << ts << std::endl;
46 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
50 std::cout << "preflow ..." << std::endl;
51 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
53 max_flow_test.preflowPhase1(MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::ZERO_FLOW);
54 std::cout << "elapsed time: " << ts << std::endl;
55 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;