BIN PACKING WITH LOWER
AND UPPER CAPACITY
CONSTRAINT
OPTIMIZATION GROUP 14
1
01 02 03
OUR
THE PROBLEM APPROACHES RESULT
Overview of the Our solutions to the Result obtained
problem problem after testing
solutions
2
01
PROBLEM
3
01. THE PROBLEM
Bin packing with lower and
upper capacity constraint
● N orders: 1, 2, …, N of quantity d(i) and cost c(i)
● K vehicles: 1, 2, …, K with lower capacity c1(k) and upper capacity
c2(k)
● Compute a solution such that:
1. Each order is served by at most one vehicle
2. Each vehicle k must has capacity between c1(k) and c2(k)
3. Total cost of served orders is maximal
4
02
OUR
APPROACHES
5
ALGORITHMS
1 2 3
META
EXACT HEURISTIC HEURISTIC
CP, MIP GREEDY, LOCAL SIMULATED
SEARCH ANNEALING
6
EXACT ALGORITHMS
1. ILP MODEL
Sets: Decision variables:
Constraints:
Parameters:
Objective function to be maximize:
7
EXACT ALGORITHMS
1. CP MODEL (FIXX)
Sets: Decision variables:
Parameters: Constraints:
Objective function to be maximize:
8
Simulated annealing
- Simulated Annealing is an
optimization algorithm inspired by
the annealing process in
metallurgy, where metal is heated
and then cooled slowly to
increase hardness and reduce
defects.
- Algorithm implementation
steps:
1. Starting from an initial point
2. Searching for neighboring
solutions
3. Comparing fitness
4. Cooling down the temperature
(T)
5. Stopping when stable
You can delete this slide when you’re done editing the
presentation.
Simulated annealing
Modelling
- N : Number of orders
- K : Number of vehicles Constraints:
- orders: List of orders, where each order has Vehicles[ j ][ 0 ]<=vehicle_loads[ j ] <= vehicles[ j ][
a weight and a cost. 1]
Structure: [(weight, cost), ...] For vehicle_loads[ j ] is weight of all items on vehicle
- vehicles: List of vehicles, where each j:
vehicle has a minimum and maximum load vehicle_loads[ j ] = ∑ orders[ i ][ 0 ] if solution[ i ] !
capacity. =0
Structure: [(min_load, max_load), ...].
- solution: a list represent for order status Objective Function:
We define that solution[ i ] = j means that max(∑ items[ i ][ 1 ] if solution[ i ] != 0)
order i is in the vehicle j,
i = 1, 2, 3, ….., N
j = 0, 1, 2, ……, K
and solution[ i ] = 0 means that order i
is not in any vehicle
Simulated annealing
Step 1 : Generate initial state by
random
Step 2 : Searching for neighboring
solutions
Simulated annealing
Step 3 :Solve simulated annealing
Weakness of this approach
The first solution of the algorithm is randomly generated
and is prone to stop at a local minimum:
Find all the neighbors is waste of time because we
randomly select orders to change to produce a valid
solution
Improved the algorithm
Using greedy to generate the initial state.
Use memory to store calculated solutions to reduce time.
Improved the algorithm
Using greedy to generate the initial state
Our goal is to find the highest total value for all orders
on all vehicles.
=> we will sort all the orders by their value. Then we
will put the orders into the vehicle that have at least
enough space to fit the orders in.
Use memory to store calculated solutions to
reduce time
Use dictionary to store and look up the calculated
value of the objective function during algorithm
execution.
Tabu search
- This algorithm extends local
search methods by using a "tabu"
cache to prevent backtracking on
already tried solutions or
"uninteresting" solution regions.
- Algorithm implementation
steps:
1. Starting from an initial point
2. Searching for neighboring
solutions
3. Choose the best neighbor
solution:
4. Update the best result
5. Manage Tabu List
You can delete this slide when you’re done editing the
presentation.
Tabu search
Modelling
- N : Number of orders
- K : Number of vehicles Constraints:
- orders: List of orders, where each order has Vehicles[ j ][ 0 ]<=vehicle_loads[ j ] <= vehicles[ j ][ 1
a weight and a cost. ]
Structure: [(weight, cost), ...] For vehicle_loads[ j ] is weight of all items on vehicle j:
- vehicles: List of vehicles, where each
vehicle has a minimum and maximum load vehicle_loads[ j ] = ∑ orders[ i ][ 0 ] if solution[ i ] !
capacity. =0
Structure: [(min_load, max_load), ...].
- solution: a list represent for order status If the vehicle has a load outside the permitted range,
We define that solution[ i ] = j means that the problem will be fined, specifically:
order i is in the vehicle j, penalty(j) = (vehicle_loads[ j ] – vehicle [ j ]
i = 1, 2, 3, ….., N [ 0 ]) **2 if vehicle_loads[ j ] < vehicle [ j ] [ 0 ]
j = 0, 1, 2, ……, K penalty(j) = - inf
and solution[ i ] = 0 means that order i if vehicle_loads[ j ] > vehicle [ j ] [ 1 ]
is not in any vehicle The fine will reduce the overall cost, aiming to limit
- tabu_list : is a list of solutions that have overloading or underloading of vehicles.
Tabu search
Step 1 : Generate initial state by
random
Step 2 : Searching for neighboring
solutions
Tabu search
Step 3 :Solve tabu search
Weakness of this approach
The first solution of the algorithm is randomly generated
and is prone to stop at a local minimum
It is difficult to compare two solutions with the same value
to see which one is better.
Improved the algorithm
Using greedy to generate the initial state.
Use memory to store calculated solutions to reduce time.
Improved the algorithm
Using greedy to generate the initial state
Our goal is to find the highest total value for all orders
on all vehicles.
=> we will sort all the orders by their value. Then we
will put the orders into the vehicle that have at least
enough space to fit the orders in.
Use memory to store calculated solutions to
reduce time
Use dictionary to store and look up the calculated
value of the objective function during algorithm
execution.
03
Meta heuristic
Simulated annealing
Tabu search
Iterated Local Search
Step 1: Generate initial state by random
Step 2: Find the neighbors
Iterated Local Search
Step 3: Solve Iterated Local Search
Weakness of this approach
When stuck at local maxima, the algorithm restarts randomly
cannot ensure to find a good enough state
too strong perturbation => inconsistency
Find all the neighbors is waste of time because we only
choose the neighbor that have better value.
Improved the algorithm
Using greedy to generate the initial state.
Change the strategy to find neighbor.
Improved the algorithm
Using greedy to generate the initial state and restart when stuck
at local maxima
The goal of the problem is to maximize the total value of items on all trucks.
=> sort the items by value and put them on the trucks if not violate the
upper bound.
To ensure the randomness, after generate state by greedy, we choose
a number of items and change their trucks or removed them.
Using a parameter “perturb_rate” to determine number of items will
be changed
Number of items will be changes = N * perturb_rate
Change the strategy to find neighbor.
Only check for the items which are not in any trucks.
2 ways to choose the best_neighbor :
Choose the neighbor that has the maximum value
=> more time consuming but can get better value
Choose the first neighbor that has the better value than current
best_value
=> quickly, minimize the solution space but may miss the good state
Adjust the parameter
For small test case( N < 50):
- Iteration <= 1000 and perturb_rate in range(0.2, 0.4)
For large test case( N > 50):
- Iteration >> and perturb_rate <= 0.2
HEURISTIC ALGORITHMS
3. BEAM SEARCH
• Instead of choosing the best result,
with beam search choose k-th best
results
MAIN IDEA AND
GREEDY
ALGORITHM
MODELING
MAIN IDEA AND MODELING
1) Greedy approach 1: Optimize total value (cost)
• The main goal is to optimize the total cost ∑c[i], as required
by the problem.
• Focus on order value c[i] and build algorithms based on
how to sort orders according to three criteria, specifically as
follows:
MAIN IDEA AND MODELING
1) Greedy approach 1: Optimize total value (cost)
- Criterion 1: Sort orders according to decreasing c[i]
value.
+) Basis: to prioritize orders with the highest value, thereby
optimizing the solution according to the target function.
+) Weakness: it is easy to fail with testcases with small
capacity trucks, because we ignore the quantity
consideration.
MAIN IDEA AND MODELING
1) Greedy approach 1: Optimize total value (cost)
- Criterion 2: Sort orders by “efficiency”, defined by
efficiency =
+) Basis: The higher the efficiency, the cost of the order is
much greater than the quantity, thereby taking advantage of
the load.
+) Weakness: it is easy to ignore orders with large value but
small performance.
MAIN IDEA AND MODELING
1) Greedy approach 1: Optimize total value (cost)
- Criterion 3: define an indicator of "importance" of the
order :
Importance = ⋅ (with x > 1)
+) Weakness: The importance index depends on x,
which is susceptible to bias with test cases with
disproportionate cost / quantity.
MAIN IDEA AND MODELING
1) Greedy approach 1: Optimize total value (cost)
• Combine all 3 of these criteria to form an
aggregation algorithm, in order to achieve the
result with the largest target function value ∑c[i].
+) Criterion 1: Sort orders by decreasing value.
+) Criterion 2: Order sorting by “efficiency”.
+) Criterion 3: Sort orders according to the "importance" index.
MODELING – FIRST APPROACH
1) Greedy approach 1: Optimize total value (cost)
- Try each arrangement (we don’t rearrange the
trucks):
1. Sort by c[i].
2. Sort by “efficiency”
3. Sort by "importance" index.
*) For each arrangement, arrange the orders into
the trucks in the default order of the testcases.
MODELING – FIRST APPROACH
1) Greedy approach 1: Optimize total value (cost)
- Put the order up one by one until the upper capacity value
is exceeded (the goal is to take as much as possible until it
exceeds the allowable upper load). Switch to another truck and
continue to arrange the next orders in the sorted array.
- After arranging a truck, go back and check if it has
exceeded the lower capacity requirement. If it don't pass, we
have to leave this truck. (This is the core weakness of the
algorithm)
MAIN IDEA AND MODELING
2) Greedy Approach 2: Maximize the number of
orders shipped
• The main goal is to try to ship as many orders as possible,
while still complying with the truck's capacity constraints.
• Weaknesses: Shipping more orders doesn't always mean
the largest total cost in some testcases.
MAIN IDEA AND MODELING
2) Greedy Approach 2: Maximize the number of
orders shipped
Step 1. Rank the orders with the highest c[i] value first to
optimize your contribution to the total value.
Step 2. Allocate each order to a "best" truck, where "best" is
defined as a truck that has:
- As much capacity to be loaded as possible (higher
upperbound).
- The remaining capacity is best suited to the order.
MAIN IDEA AND MODELING
2) Greedy Approach 2: Maximize the number of
orders shipped
Step 3. Ensure the trucks meet the lowerbound
capacity conditions by adjusting after loading.
MAIN IDEA AND MODELING
2) Greedy Approach 2: Maximize the number of
orders shipped
2.1. Preparation steps
2.2. Placing orders and handling orders that are not
suitable for the trucks being loaded
2.3. Handling of trucks that do not exceed the lower
capacity value
MAIN IDEA AND MODELING
2.1) Preparation
- Sort orders by decreasing c[i] (cost) value.
- Arrange the trucks in order of priority:
Priority 1: Greater upper proximal load.
Priority 2: Wider payload range. (i.e. the truck with a larger
valid capacity width is preferred)
MAIN IDEA AND MODELING
2.2) Placing orders, handling orders that are not
suitable for the trucks being stacked
- Browse through each order in turn.
- For each order, browse through the list of trucks
(sorted) to find the "best" truck that can hold the order
and still satisfy the load constraints.
- If you can't fit your order into any truck, put it in a
"queue" (we'll use that later)
MAIN IDEA AND MODELING
2.3) Handling of vehicles that do not exceed the lower
capacity value
- Step 1: Try to get orders from the “queue" to fill the gap
and make sure the truck can reaches the lower capacity
value.
- Step 2: If it fails, allocate the unloaded orders to the trucks
that still have valid space to load.
- Step 3: Remove orders that cannot be placed if you cannot
find a place to place them through the above two steps.
TIME
COMPLEXITY
TIME COMPLEXITY – FIRST APPROACH
1. Sorting Orders: O(n log n) - Sorts orders three
times using different criteria, but the dominant
complexity remains O(n log n).
2. Assigning Orders: O(n) - amortized linear
complexity due to each good being considered at
most once.
TIME COMPLEXITY – FIRST APPROACH
3. Constraint Check & Backtracking: O(n)
amortized linear complexity due to the bound on
backtracking operations.
TIME COMPLEXITY – FIRST APPROACH
Summary : When n is large, the dominant
factor is the sorting step, making the
overall time complexity
O(n log n)
TIME COMPLEXITY – SECOND
1. Orders sorting: APPROACH
O(N log N) - use sort on the
array containing the order information.
2. Trucks sorting: O(K log K) - use sort on the
array containing the truck load information.
TIME COMPLEXITY – SECOND
APPROACH
3. Assign orders to trucks: O(N*K) – nested loops,
in the worst case, each order is compared to each
truck.
4. Removal of unqualified trucks: O(K*M), where M
is the average number of orders per truck. This
section examines each truck and browses the
orders that have been assigned to it. Since M <= N,
this complexity does not exceed O(N*K).
TIME COMPLEXITY – SECOND
APPROACH
Summary : When N and K are large, we
consider this complexity to be approximate
O(N * K)