Bin Packing
BinPackingProblem
OperationsResearchModels.BinPacking.BinPackingProblem — Type
BinPackingProblem represents a bin packing problem with item sizes and bin capacities.
Fields
item_sizes::Vector{T1 <: Real}: The sizes of the items.bin_capacity::Vector{T2 <: Real}: The capacities of the bins.
The Solver
OperationsResearchModels.solve — Method
solve(problem::BinPackingProblem)::BinPackingResultSolve a bin packing problem.
Description
Suppose we have a set of items with given sizes and a set of bins with given capacities. The goal is to assign each item to a bin such that the total size of items in each bin does not exceed its capacity, and the number of used bins is minimized. For example we have items with sizes [2, 3, 2, 3] and bins with capacities [5, 5]. The optimal assignment would be to place the first two items in the first bin and the last two items in the second bin.
Arguments
problem::BinPackingProblem: The bin packing problem to solve.
Returns
BinPackingResult: The result of the bin packing problem.
Example
problem = BinPackingProblem([2, 3, 2, 3], [5, 5])
result = solve(problem)
println("Used bins: ", result.used_bins)
println("Bin assignments: ", result.bin_assignments)
# Expected output:
# Used bins: [1, 2]
# Bin assignments: [1, 1, 2, 2] or [2, 2, 1, 1]BinPackingResult
OperationsResearchModels.BinPacking.BinPackingResult — Type
BinPackingResult represents the result of a bin packing problem.
Fields
used_bins::Vector{Int}: The indices of the bins that are used.bin_assignments::Vector{Int}: The bin assignment for each item.model::JuMP.Model: The JuMP model used to solve the problem.