I'm trying to solve multi commodity multi source network flow optimization problem using Python-PuLP. Here is how my problem looks like:
The numbers on the arcs represent the order of priority a particular node should receive supply from. For example, D1 should get first serviced by W2, then W1, and W3 respectively.
Variables:
- W = set of all Warehouses (W1, W2, W3)
- D = set of all DCs (D1, D2, D3)
- C = set of all Commodities (C1, C2)
- N = set of all nodes (W1, W2, W3, D1, D2, D3)
- Arcs = set of all connections (w, d) for w $\subset$ W and d $\subset$ D
Current assumptions:
- All commodities have the same Warehouse-DC connection priorities.
- Transport trucks have unlimited capacities and same cost.
- QUESTION 1 - I would like to know how to include this in the design since I'm currently using the priority in the arcs to identify from which source the commodity should be shipped.
Currently I'm trying to use a for-loop to find solutions for all commodities. I believe there is an elegant way to depict the same problem.
QUESTION 2 - How can I use the optimization design to include many commodities. Eventually I will want to add additional constraints on how much I can transport per arc.
for c in C:
Decision variables:
route -> Arcs
route_used = 1 iff route is selected, 0 otherwise
Objective:
min $\sum (RouteSelected[(w,d),1]*cost[(w,d)])$
QUESTION 3 - I have not chosen another objective to ensure the maximum fulfilment to all DCs. Should I first run an iteration to solve for maximum fulfilment and then run for minimum of the route selected as defined above? Is there a better way to define this as multi-objective together?
Bounds:
for w, d in route:
route[(w, d)] >= 0
route[(w, d)] <= min(Supply[w], Demand[d]
Constraints:
1. Flow conservation constraint
if Total Supply < Total Demand:
for n in nodes:
(Supply[n] + sum(route[(w, d)]) for w, d in Arcs and d==n) <=
(Demand[n] + sum(route[(w, d)]) for w, d in Arcs and w==n)
else:
for n in nodes:
(Supply[n] + sum(route[(w, d)]) for w, d in Arcs and d==n) >=
(Demand[n] + sum(route[(w, d)]) for w, d in Arcs and w==n)
2. Specific DC priority
When the total supply is less than the total demand, I want to service the demand at a specific DC first irrespective of my objective function. For example, let’s consider DC D1
if Total Supply < Total Demand:
QUESTION 4a - I want to satisfy the maximum possible demand for D1 from all my connected warehouses. How do I define that?
QUESTION 4b - Assuming we always run into situations where supply < demand, how should I let the optimizer know the order of fulfilment. For example, solve for DC1, then DC3, followed by DC2? Or is this inherently used by the choice of optimizer I use?