2

Is there a package which implements a min cost flow algorithm in R?

The igraphpackage seems only to have max flows (via the graph.maxflow() function), and nothing else here or on rseek.org looks helpful.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Stephan Kolassa
  • 7,953
  • 2
  • 28
  • 48
  • Perhaps you should show how you might use igraph functions if you were looking for max flows? – IRTFM Nov 07 '12 at 21:28
  • I edited the question to indicate that max flows can be found via `graph.maxflow()`, although I don't really see how this would help. From the structure of the problem, I know that a flow exists and that it has a fixed value (this is not a min cost max flow problem, just a min cost flow problem). – Stephan Kolassa Nov 07 '12 at 21:50
  • I started out thinking this was analogous to a resistor network with voltage sources and current sinks, but it becomes clear that a different sort of problem is generally being solved with the methods in the igraph package. At the moment it would seem that 0 is usually the minimum. I wonder if you might get better answers with a specific task. – IRTFM Nov 07 '12 at 22:43
  • Well, the min cost flow problem usually entails minimum flows into one or more sinks in the network, so the minimum cost flow will not be the zero flow. I will think about being more specific... – Stephan Kolassa Nov 08 '12 at 07:18

2 Answers2

0

Perhaps you could return all flows and then sort by value?

Package sna has a flowbet() function for flow between.

metasequoia
  • 7,014
  • 5
  • 41
  • 54
  • Hm. A min cost flow problem is something different than a max flow problem, so `flowbet()` does not seem to help. Returning "all flows" is not really an option as there are uncountably many flows unless we restrict flows to be integer valued... and even then we would run into a combinatorial explosion. Any other ideas? – Stephan Kolassa Nov 07 '12 at 20:09
0

I was struggling with this as well and posted a question with a reproducible min-cost-flow problem here. While I did not receive a definite answer from the community, I did post the approach that I ended up implementing. It involved a data.frame of edges with a $cost and a $capacity property, which I then used to generate appropriate constraints for an lpSolve optimisation. Check it out, hope it helps!

JanLauGe
  • 2,297
  • 2
  • 16
  • 40