Solving the Tanker Assignment Challenge with Linear Programming - Simple version
This is a continuation of my series on using AI for product development. You can refer to my previous post, My Journey into AI: How I Started Using AI for Product Development, My objective is to optimally assign tankers to segments within berths at a port, ensuring that the total capacity of assigned segments closely matches the tanker's capacity without significant over-assignment. I'll use the PuLP library, a popular linear programming package in Python, to model and solve this problem.
Introduction
The tanker assignment challenge is a common problem in the maritime industry. Efficiently allocating tankers to berths and their respective segments is crucial for maximizing port utilization and minimizing idle times. By leveraging linear programming, we can create a model that helps in making these assignments more efficient and effective.
Approach
To solve the tanker assignment problem using linear programming, I follow a systematic approach that progresses from a simple version to more complex scenarios. This structured methodology allows me to build a solid foundation and incrementally add complexity. Here's how I proceed:
Step 1 - Decision Variables: Define binary decision variables indicating whether a tanker is assigned to a specific segment.
Step 2 - Objective Function: Create an objective function that minimizes the total difference between the tankers' capacities and the assigned segments' capacities.
领英推荐
Step 3- Constraints: Ensure that each tanker is assigned to exactly one segment and that the capacity of assigned segments does not exceed the tanker's capacity.
Data sample input
tankers = ["Tanker1","Tanker2","Tanker3","Tanker4","Tanker5" ,"Tanker6","Tanker7","Tanker8","Tanker9","Tanker10"]
tanker_capacities = {"Tanker1": 200000, "Tanker2": 200, "Tanker3": 100, "Tanker4": 100,"Tanker5":100,"Tanker6":100,"Tanker7":100,"Tanker8":100,"Tanker9":100,"Tanker10":100}
berths = ["Berth1", "Berth2"]
segments = {"Berth1": ["Segment1", "Segment2"],
"Berth2": ["Segment1", "Segment2", "Segment3"]}
Data
Assignments:
Tanker Berth Segment
0 Tanker2 Berth2 Segment2
1 Tanker2 Berth2 Segment3
2 Tanker3 Berth2 Segment1
3 Tanker7 Berth1 Segment2
4 Tanker10 Berth1 Segment1
Full git with detail explanation https://github.com/kimlongap1/tanker-assignment/tree/main/simple-version
Conclusion
In this blog, we've demonstrated how to tackle a tanker assignment problem using linear programming with Python's PuLP library. By carefully defining our decision variables, objective function, and constraints, we've developed a model that optimizes tanker assignments to port segments, ensuring efficient utilization of both tanker and segment capacities. This approach can be adapted to various resource allocation problems, showcasing the power and flexibility of linear programming in operational research.
Associate Director at Generali Life Insurance Viet Nam
8 个月D?o này nghiên c?u AI à Phú?