Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_DualMinCostFlow.cpp
Go to the documentation of this file.
1 
8 #include <iostream>
10 
14 void 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 
63 int 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 }
Capacity scaling algorithm for min-cost flow.
SolverProperty
Some enums used in solver.
Definition: Solvers.h:29
Network simplex algorithm for min-cost flow.
int main(int argc, char **argv)
main function
Cycle canceling algorithm for min-cost flow.
std::string toString(SolverProperty sp)
Convert limbo::solvers::SolverProperty to std::string.
Definition: Solvers.h:44
Cost scaling algorithm for min-cost flow.
void read(std::string const &filename)
read lp format
Definition: Solvers.h:1464
model to describe an optimization problem
Definition: Solvers.h:80
void test(std::string const &filename, int alg)
test file API
Solve a special case of linear programming with dual min-cost flow. A better implementation of LpDual...
LP solved with min-cost flow. A better implementation of limbo::solvers::lpmcf::LpDualMcf.
A base class of min-cost flow solver.