4.2 Minimum-Cost Flow Problem
Preamble: Install Pyomo and a solver
The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object SOLVER for later use.
Problem description
In the context of logistics optimization, a company aims to identify the most cost-effective strategy for transporting goods from its production facilities to its retail locations across an entire continent.
This problem can be naturally formulated using a graph. Each node of this network represents a manufacturing facility, a distribution center, or a retail outlet. Correspondingly, node is characterized by having a supply , a demand , or just serving as a transshipment point with . Each directed arc represents a possible mode of transport (rail, airway, road) between locations and , with an associated maximum capacity and cost per unit of good sent using edge . Note that multiple edges are possible between the same pair of nodes , modeling different means of transport available between those locations, each with a specific cost and maximum capacity. The goal is to identify the cheapest way of transporting goods from the supply nodes to the demand nodes, while respecting the capacity constraints of the arcs and the supply/demand constraints of the nodes.
Mathematical formulation
For every edge , we introduce a decision variable describing the non-negative amount of goods sent from node to node via edge . These quantities are usually referred to as flows. The Minimum-Cost Flow (MCF) problem aims to find the set of flows with the minimum cost through the network such that the available supply is used to satisfy the demand. It can be formulated as follows:
The first set of constraints, usually referred to as flow conservation or balance constraints, expressing the fact that the net balance of the goods arriving at node minus those departing from node should be exactly equal to the supply/demand set for that node.
Let us now solve the MCF problem for the following small network instance, specified using dictionaries.
We first introduce an auxiliary function to draw the network and its features.
In the next cell, we formulate the MCF problem using Pyomo, solve it, and visualize the solution.
, , , , , , , , , , , , , , , ,