0

I want to use a python Min-Cost Flow solver to be able to construct new networks. This means that I have an initial complete graph, with the vertices being either suppliers or having a demand. Using the algorithm should tell me, based on their costs, what edges will be used to settle all demands. Different to the existing problems, the cost of an edge when being used are not only described by a unit cost but also have an investment of this edge which is independent of the flow. I have been looking into the source code of networkx and or-tools but cannot figure out how to adapt these to implement the investment cost of the edges. Does someone have a better idea or can help me adapting the code?

Best Regards Justus

1 Answers1

1

You cannot solve this with a standard graph algorithm (eg: MinCostFlow). Instead you need to formulate it as a Mixed Integer Program. You can start with this example:

https://developers.google.com/optimization/assignment/assignment_mip

But you need to tweak it a little bit: You need two classes of decision variables: invest_var (binary) and flow_var (continuous). The objective will look like this:

min: sum(flow_cost[i,j]*flow_var[i,j]) + sum(invest_cost[i,j]*invest_var[i,j])
And you need to add an additional constraint for each link:
flow_var[i,j] <= BIG_INT * invest_var[i,j]

The purpose of these to constrain flow_var to 0 if invest_var is 0. Demand and Supply constraints will be similar as in the example. BIG_INT is a constant. You can set it as:

BIG_INT=max(flow_upper_bound[i,j])

Where flow_upper_bound is an upper bound on your flow_var variables.

Notice, that the problem now becomes a Mixed Integer Linear Program instead of just being a Linear Program.

BiscuitBaker
  • 1,421
  • 3
  • 23
  • 37
gergelybat
  • 98
  • 1
  • 3