I think I'm facing a Milp problem but I'm not sure.
The problem in a simplified form is:
There are 3 suppliers of materials (trucks) for 3 cities. The real problem is 30 Suppliers and 100 cities...
Supliers capacity: a:1; b:2; c:3.
Cities Demand: a:2; b:3; c:1
Distances Supplier(Cities):
- a(a:2;b:4;c:6)
- b(a:4;b:2;c:4)
- c(a:6;b:4;c:2)
like this with each Capacity and Demand
Sa1 - Ca2
Sb2 - Cb3
Sc3 - Cc1
The goal its optimize the suply but there is one (devil) condition:
- Just one supplier per city.
Whitout the contidion the problem is a simple problem to solve with basic Linear Programming.
With the condition I think that could be solved with Mixed Integer Linear Programming - MILP.
But not figure it out how to solve this with MILP Method and Pulp (python module).
If someone can help me
Thanks!
My first try
from scipy.optimize import linprog
c = [2,4,6,4,2,4,6,4,2]
Ae = [[1,1,1,0,0,0,0,0,0],
[0,0,0,1,1,1,0,0,0],
[0,0,0,0,0,0,1,1,1],
[1,0,0,1,0,0,1,0,0],
[0,1,0,0,1,0,0,1,0],
[0,0,1,0,0,1,0,0,1],
]
be = [1,2,3,2,3,1]
x0_bounds = (0,None)
x1_bounds = (0,None)
x2_bounds = (0,None)
x3_bounds = (0,None)
x4_bounds = (0,None)
x5_bounds = (0,None)
x6_bounds = (0,None)
x7_bounds = (0,None)
x8_bounds = (0,None)
sol = linprog(c, A_eq= Ae, b_eq = be, bounds = ((x0_bounds,x1_bounds,x2_bounds,x3_bounds,x4_bounds,x5_bounds,x6_bounds,x7_bounds,x8_bounds)) )
print(sol)
fun: 18.0
message: 'Optimization terminated successfully.'
nit: 10
slack: array([], dtype=float64)
status: 0
success: True
x: array([1., 0., 0., 0., 2., 0., 1., 1., 1.])
Process finished with exit code 0