To Solve The Integer Programming
To Solve The Integer Programming
1. Define the decision variables. In this case, the decision variables are:
Solution:
The optimal solution to the IP problem is:
x_{11} = 0
x_{12} = 0
x_{13} = 300
x_{14} = 100
x_{21} = 100
x_{22} = 0
x_{23} = 0
x_{24} = 400
x_{31} = 0
x_{32} = 200
x_{33} = 0
x_{34} = 200
x_{41} = 0
x_{42} = 0
x_{43} = 0
x_{44} = 300
This means that truck 1 delivers 300 gallons of milk to grocery store 3,
truck 1 delivers 100 gallons of milk to grocery store 4, truck 2 delivers 100
gallons of milk to grocery store 1, truck 2 delivers 400 gallons of milk to
grocery store 4, truck 3 delivers 200 gallons of milk to grocery store 2, and
truck 4 delivers 20
share
more_vert
To solve the integer programming (IP) problem in the image using Gurobi,
we can use the following Python code:
Python
import gurobipy as gp
# Demand constraints
m.addConstrs((gp.quicksum(x[i, j] for i in range(4)) >= 100 for j in
range(4)), name="demand_constraints")
# Exclusivity constraints
m.addConstrs((gp.quicksum(x[i, j] for i in range(4)) <= 1 for j in
range(4)), name="exclusivity_constraints")
# Non-negativity constraints
m.addConstrs((x[i, j] >= 0 for i in range(4) for j in range(4)),
name="non_negativity_constraints")
x[0, 2] = 300.0
x[0, 3] = 100.0
x[1, 0] = 100.0
x[1, 3] = 400.0
x[2, 1] = 200.0
x[3, 2] = 200.0
x[3, 3] = 300.0