Limbo 3.5.4
Loading...
Searching...
No Matches
test_DualMinCostFlow.cpp
Go to the documentation of this file.
1
7
8#include <iostream>
10
14void test(std::string const& filename, int alg)
15{
16 typedef limbo::solvers::LinearModel<int, int> model_type;
17 model_type optModel;
18 optModel.read(filename);
19
20 // print problem
21 optModel.print(std::cout);
22
23 // solve
24 limbo::solvers::MinCostFlowSolver<int, int>* minCostFlowSolver = NULL;
25 switch (alg)
26 {
27 case 0:
28 minCostFlowSolver = new limbo::solvers::CostScaling<int, int>();
29 break;
30 case 1:
31 minCostFlowSolver = new limbo::solvers::CapacityScaling<int, int>();
32 break;
33 case 2:
34 minCostFlowSolver = new limbo::solvers::NetworkSimplex<int, int>();
35 break;
36 case 3:
37 default:
38 minCostFlowSolver = new limbo::solvers::CycleCanceling<int, int>();
39 break;
40 }
42 limbo::solvers::SolverProperty status = solver(minCostFlowSolver);
43 //limbo::solvers::SolverProperty status = solver();
44 std::cout << "Problem solved " << limbo::solvers::toString(status) << "\n";
45 delete minCostFlowSolver;
46
47 // print solutions
48 optModel.printSolution(std::cout);
49 // print problem
50 optModel.print(std::cout);
51
52 // print graph with solution information
53 solver.printGraph(true);
54}
55
63int main(int argc, char** argv)
64{
65 if (argc > 1)
66 {
67 int alg = 0;
68 if (argc > 2)
69 alg = atoi(argv[2]);
70 // test file API
71 test(argv[1], alg);
72 }
73 else
74 std::cout << "at least 1 argument required\n";
75
76 return 0;
77}
Solve a special case of linear programming with dual min-cost flow. A better implementation of LpDual...
Capacity scaling algorithm for min-cost flow.
Cost scaling algorithm for min-cost flow.
Cycle canceling algorithm for min-cost flow.
LP solved with min-cost flow. A better implementation of limbo::solvers::lpmcf::LpDualMcf.
void printGraph(bool writeSol) const
print graph
model to describe an optimization problem
Definition Solvers.h:1161
void read(std::string const &filename)
read lp format
Definition Solvers.h:1464
A base class of min-cost flow solver.
Network simplex algorithm for min-cost flow.
SolverProperty
Some enums used in solver.
Definition Solvers.h:30
std::string toString(SolverProperty sp)
Convert limbo::solvers::SolverProperty to std::string.
Definition Solvers.h:44
int main()
void test(std::string const &filename, int alg)
test file API