Introduction:

In today’s globalized world, efficient transportation plays a crucial role in ensuring that school supplies reach educational institutions reliably and cost-effectively. This blog post introduces a transportation optimization problem that addresses the supply of school supplies kits from four U.S. cities to four Asian cities and eight schools. We’ll delve into the code that models and solves this optimization problem using Gurobi, a powerful optimization tool.

Setting the Stage

Before we dive into the code, let’s understand the problem at hand. We have the following key components:

Sets:

  • I: U.S. cities (Los Angeles, Chicago, Houston, Miami)
  • J: Asian cities (Tokyo, Beijing, Seoul, Bangkok)
  • K: Schools (School1, School2, School3, School4, School5, School6, School7, School8)

Parameters:

  • Cost Matrix (c): The cost of shipping from each U.S. city to each Asian city.
  • Quality Values (q): The quality ratings for each U.S. city.
  • Cost Matrix (p): The cost of shipping from each Asian city to each school.
  • Supply (s): The supply of school supply kits in each U.S. city.
  • Demand (d): The demand for school supply kits in each Asian city.
  • School Requirements (r): The required kits for each school.
  • Freight Size Limit (L): The maximum freight size.
  • Capacity Constraint (N): Capacity constraint for each U.S. city to Asian cities.

Model Definition

The core of our optimization problem is defined in the code using Gurobi:

# Define the Gurobi model
model = gp.Model('SchoolSuppliesKitTransport')

# Define the decision variables
x = {}
for i in I:
    for j in J:
        for k in K:
            x[i, j, k] = model.addVar(lb=0, vtype=gp.GRB.INTEGER, name=f'x_{i}_{j}_{k}')

# Update the model to include the variables
model.update()

# Set the objective function
model.setObjective(gp.quicksum((c[I.index(i), J.index(j)]  + p[J.index(j), K.index(k)]) * x[i, j, k] for i in I for j in J for k in K), gp.GRB.MINIMIZE)

In this model, we define decision variables, set the objective function to minimize the total cost of transportation, and add constraints for supply, capacity, and quality. Here’s a breakdown of these constraints:

Constraints

  1. Supply Constraints:
for i in I:
    model.addConstr(gp.quicksum(x[i, j, k] for j in J for k in K) == s[i], name=f'Supply_{i}')

These constraints ensure that the supply of kits from U.S. cities is met.

  1. Capacity Constraints:
for j in J:
    model.addConstr(gp.quicksum(x[i, j, k] for i in I for k in K) <= d[j], name=f'Capacity_{j}')

These constraints guarantee that demand in Asian cities does not exceed their capacity.

  1. Maximum Kits from U.S. to Asian Locations Constraint:
for i in I:
    for j in J:
        model.addConstr(gp.quicksum(x[i, j, k] for k in K) <= N, name=f'MaxKits_US_{i}_{j}')

These constraints limit the number of kits transported from U.S. cities to Asian cities.

  1. Minimum Capacity Usage Constraint:
for j in J:
    model.addConstr(gp.quicksum(x[i, j, k] for i in I for k in K) >= 0.8 * d[j], name=f'MinCapacity_{j}')

These constraints ensure that Asian cities utilize at least 80% of their capacity.

  1. Maximum Kits to Schools Constraint:
for i in I:
    for j in J:
        for k in K:
            model.addConstr(x[i, j, k] <= L, name=f'MaxKits_{i}_{j}_{k}')

These constraints set a limit on the number of kits that can be transported to each school.

  1. Minimum Kits to Schools Constraint:
for k in K:
    model.addConstr(gp.quicksum(x[i, j, k] for i in I for j in J) >= 0.85 * r[k], name=f'MinKits_{k}')

These constraints ensure that at least 85% of each school’s requirements are met.

  1. Quality Constraints:
for j in J:
    model.addConstr(
        gp.quicksum(x[i, j, k] * q[i] for i in I for k in K) >= 8.55 * gp.quicksum(x[i, j, k]  for i in I for k in K),
        name=f'Quality_{j}'
    )

These constraints take quality into account, ensuring that the weighted quality exceeds a certain threshold for each Asian city.

Solving and Printing Results

Finally, we solve the optimization model and print the results:

# Solve the optimization model
model.optimize()

# Print the results
if model.status == gp.GRB.OPTIMAL:
    print("Optimal Solution Found:")
    for i in I:
        for j in J:
            for k in K:
                quantity = x[i, j, k].x
                if quantity > 0:
                    print(f'Ship {quantity} kits from {i} to {j} to {k}')
    print(f'Total Cost: ${model.objVal}')
else:
    print("No optimal solution found.")

The code finds the optimal solution and displays the transportation plan and total cost.

Analyzing the Optimal Solution

After running the optimization model, the output reveals an “Optimal Solution Found.” This means that the model has successfully determined the most cost-efficient way to distribute school supply kits from U.S. cities to Asian cities and schools. Let’s delve into the details of this optimal solution and understand the implications of the transportation plan:

  1. Optimal Kit Shipments:

    • From Los Angeles:
      • 76 kits are shipped to Tokyo, specifically to School1.
      • 125 kits are shipped to Tokyo, specifically to School3.
      • 49 kits are shipped to Seoul, specifically to School2.
      • 62 kits are shipped to Bangkok, specifically to School1.
      • 125 kits are shipped to Bangkok, specifically to School4.
      • 63 kits are shipped to Bangkok, specifically to School8.
    • From Chicago:
      • 125 kits are shipped to Beijing, specifically to School7.
      • 88 kits are shipped to Seoul, specifically to School2.
      • 85 kits are shipped to Seoul, specifically to School5.
      • 77 kits are shipped to Seoul, specifically to School6.
    • From Houston:
      • 58 kits are shipped to Tokyo, specifically to School1.
      • 125 kits are shipped to Tokyo, specifically to School3.
      • 78 kits are shipped to Beijing, specifically to School8.
      • 125 kits are shipped to Bangkok, specifically to School4.
      • 39 kits are shipped to Bangkok, specifically to School8.
    • From Miami:
      • 116 kits are shipped to Tokyo, specifically to School3.
      • 39 kits are shipped to Beijing, specifically to School4.
      • 105 kits are shipped to Beijing, specifically to School7.
      • 53 kits are shipped to Beijing, specifically to School8.
      • 37 kits are shipped to Seoul, specifically to School2.
  2. Total Cost: $15,960.90

    The total cost associated with this optimal distribution plan is approximately $15,960.90. This represents the minimum cost required to meet the supply and demand while adhering to the constraints set in the model.

Key Takeaways

  • The optimal solution ensures that all supply and demand requirements are met, taking into account various constraints such as capacity, quality, and kit size limits.

  • The model has effectively allocated kits from U.S. cities to Asian cities and schools in a way that minimizes the overall transportation cost.

  • By considering the quality constraints, the solution aims to ensure that the transported kits meet certain quality standards, which is an important aspect of the problem.

  • The transportation plan can guide real-world decision-making in terms of logistics and supply chain management, helping organizations minimize costs and optimize their distribution processes.

In conclusion, the optimal solution found in this transportation and distribution problem is not only cost-effective but also ensures that school supply kits reach their intended destinations efficiently, meeting both supply and demand while considering quality and capacity constraints. This demonstrates the power of mixed-integer linear programming in solving complex logistics and supply chain optimization challenges.

Output From Python

Optimal Solution Found:
Ship 76.0 kits from Los Angeles to Tokyo to School1
Ship 125.0 kits from Los Angeles to Tokyo to School3
Ship 49.0 kits from Los Angeles to Seoul to School2
Ship 62.0 kits from Los Angeles to Bangkok to School1
Ship 125.0 kits from Los Angeles to Bangkok to School4
Ship 63.0 kits from Los Angeles to Bangkok to School8
Ship 125.0 kits from Chicago to Beijing to School7
Ship 88.0 kits from Chicago to Seoul to School2
Ship 85.0 kits from Chicago to Seoul to School5
Ship 77.0 kits from Chicago to Seoul to School6
Ship 58.0 kits from Houston to Tokyo to School1
Ship 125.0 kits from Houston to Tokyo to School3
Ship 78.0 kits from Houston to Beijing to School8
Ship 125.0 kits from Houston to Bangkok to School4
Ship 39.0 kits from Houston to Bangkok to School8
Ship 116.0 kits from Miami to Tokyo to School3
Ship 39.0 kits from Miami to Beijing to School4
Ship 105.0 kits from Miami to Beijing to School7
Ship 53.0 kits from Miami to Beijing to School8
Ship 37.0 kits from Miami to Seoul to School2
Total Cost: $15960.90

Conclusion

Optimizing school supplies kit transportation involves balancing cost, quality, and various constraints. With Gurobi, we can efficiently model and solve such complex transportation problems. By using this code as a template, we can adapt it to address similar supply chain optimization challenges in various real-world scenarios.