Instead of the transactional data, we just use the coappearance matrix in our model!
Model Formulation
Decision Variables?
NoteWe have the following sets:
\(\mathcal{I}\) - Set of products indexed by \(i \in \{1,2,...,|\mathcal{I}|\}\)
\(\mathcal{K}\) - Set of warehouses indexed by \(k \in \{1,\dots,|\mathcal{K}|\}\)
ImportantOur objective is to:
Maximize the coappearance of products that are often part of the same customer orders. In more mathematical terms: Maximize the sum of all unique pair-wise values \(q_{i,j}\) of all SKUs stored in the same warehouse.
Question:What could be our decision variable/s?
Decision Variables
\(X_{i,k}\) - 1, if SKU \(i\in\mathcal{I}\) is stored in \(k\in\mathcal{K}\), 0 otherwise
ImportantOnly one variable per SKU and warehouse!
As we don’t need the customer order information, we only need to make a decision for each SKU and warehouse pair!
Decision Variable in Julia
Question:How could we formulate the variable in Julia?
usingJuMP, SCIP# SCIP is a non-commercial solver for quadratic modelswarehouses = ["Hamburg", "Berlin"] # Add warehouses as a vectorskus = ["A", "B", "C", "D"] # The four SKUs from our transactional datawarehouse_model =Model(SCIP.Optimizer)
@variable(warehouse_model, X[i in skus, k in warehouses], Bin)
2-dimensional DenseAxisArray{JuMP.VariableRef,2,...} with index sets:
Dimension 1, ["A", "B", "C", "D"]
Dimension 2, ["Hamburg", "Berlin"]
And data, a 4×2 Matrix{JuMP.VariableRef}:
X[A,Hamburg] X[A,Berlin]
X[B,Hamburg] X[B,Berlin]
X[C,Hamburg] X[C,Berlin]
X[D,Hamburg] X[D,Berlin]
Objective Function
NoteWe need the following:
\(X_{i,k}\) - 1, if SKU \(i\in\mathcal{I}\) is stored in \(k\in\mathcal{K}\), 0 otherwise
\(q_{i,j}\) - Coappearance of SKU \(i\in\mathcal{I}\) and \(j\in\mathcal{I}\)
ImportantOur objective is to:
Maximize the sum of all unique pair-wise values \(q_{i,j}\) of all SKUs stored in the same warehouse. Note, that this is a quadratic objective function!
Question:What could the objective function look like?
The quadratic terms are \(X_{i,k}\times X_{j,k}\). This objective function is based on the Quadratic Multiple Knapsack Problem (QMKP), formulated by Hiley and Julstrom (2006).
Objective Function in Julia
Question:How could we formulate this in Julia?
# We reuse the matrix Q = T' * T computed from our transactional data@objective(warehouse_model, Max,sum( X[skus[i], warehouses[k]] * X[skus[j], warehouses[k]] * Q[i,j]for i in2:length(skus)for j in1:i-1for k in1:length(warehouses) ))
Question:How could we add the second constraint in Julia?
Capacity Constraints in Julia
capacities =Dict("Hamburg"=>2, "Berlin"=>2) # Add capacities@constraint(warehouse_model, capacity[k in warehouses],sum(X[i, k] for i in skus) <= capacities[k])
\[
\begin{align*}
& \sum_{k \in \mathcal{K}} X_{i,k} \geq 1 && \forall i \in \mathcal{I}\\
& \sum_{i \in \mathcal{I}} X_{i,k} \leq c_{k} && \forall k \in \mathcal{K}\\
& X_{i,k} \in \{0,1\} && \forall i \in \mathcal{I}, k \in \mathcal{K}
\end{align*}
\]
QMK Model in Julia
set_attribute(warehouse_model, "display/verblevel", 0) # Hide solver outputoptimize!(warehouse_model)println("The optimal objective value is: ", objective_value(warehouse_model))println("The optimal solution is: ", value.(X))
The optimal objective value is: 6.0
The optimal solution is: 2-dimensional DenseAxisArray{Float64,2,...} with index sets:
Dimension 1, ["A", "B", "C", "D"]
Dimension 2, ["Hamburg", "Berlin"]
And data, a 4×2 Matrix{Float64}:
1.0 0.0
0.0 1.0
0.0 1.0
1.0 0.0
Question:What does this value tell us?
Interpreting the Solution
Total capacity (\(2+2\)) equals the number of SKUs
Hence, each SKU is stored exactly once
Optimal: A and D share a warehouse, so do B and C
NoteThe objective value is 6
It sums the coappearances of SKUs sharing a warehouse: \(q_{A,D} + q_{B,C} = 4 + 2 = 6\). It does not directly count the avoided split orders!
Model Characteristics
Characteristics
Is the model formulation linear/ non-linear?
What kind of variable domain do we have?
Do we know the split-orders based on the objective value?
Why couldn’t we use HiGHS as solver?
Choosing a solver
Identify problem structure, e.g. LP, MIP, NLP, MIQP, MIQCP, …
What is the size of the problem?
Is a commercial solver needed?
NoteCommercial Solvers
Commercial solvers are faster and more robust than open source solvers but also more expensive. During your studies, you can use most of them for free though! Nonetheless, we will only use open source solvers in this course.
Our model is a MIQP, as only the objective is quadratic. It is not a MIQCP, which would also allow quadratic constraints. MIQCP solvers, e.g. SCIP, subsume MIQPs and can thus solve our model.
SCIP: Best open-source for MIQP/MIQCP, limited scalability
Commercial solvers: Better but still fail on 10,000+ SKUs
Conclusion: Heuristics necessary for realistic problems!
Model Assumptions
Questions:On model assumptions
What assumptions have we made?
Problem with allocating SKUs to multiple warehouses?
What else might pose a problem in the real world?
NoteDuplicates can inflate the objective
With slack capacity, the model may store one SKU in several warehouses. A shared pair then counts once per warehouse, raising the objective without avoiding any further splits.
Model Limitations
Stock-outs: Model assumes perfect availability
Real stockouts create splits despite optimal allocation
Shipping costs: No consideration of distance or weight
Practical Limitations
Allocation changes:
Frequent reallocation disrupts operations
Physical inventory movements costly
Need for change minimization
Workload imbalance:
Optimal allocation may overload some warehouses
High-frequency SKUs cluster together
Trade-off: splits vs. balance
Impact
Can this be
applied?
Problem Size is Crucial
Up to 1,000 SKUs → commercial solvers
More than 1,000 SKUs → heuristics
For example, the CHI heuristic
NoteCHI-Heuristic
Detect dependencies between products and allocate them accordingly, as products within orders can have dependencies and products are bought with different frequencies!
CHI Heuristic
Statistical Independence
Question:When are two SKUs independent?
If purchasing one doesn’t affect purchasing the other:
\[P(A \cap B) = P(A) \times P(B)\]
Example: If \(A\) appears in 10% of orders and \(B\) in 20%:
Independent: Appear together in \(0.10 \times 0.20 = 2\%\) of orders
Dependent: Appear together in 5% of orders → customers buy them together!
Chi-Square Test Intuition
Use chi-square tests to detect if SKUs are dependent:
Calculate expected coappearances under independence
Compare with actual coappearances
If difference is significant → SKUs are dependent
Allocate dependent SKUs to same warehouse!
From Tests to Allocations
TipTwo-Phase Approach
Phase 1: Build allocation using dependencies Phase 2: Refine with local search
Result: Works on large instances, 50,000 SKUs in 10 minutes!
In Practice
Real-World Challenges
Question:What challenges might arise in practice?
New products: Allocate SKUs without historical data?
Dynamic inventory: SKUs appear and disappear
Different sizes: SKUs consume varying storage space
Computational limits: Problems with 50,000+ SKUs
Case: A Large Online Retailer
Question: Which of 100,000+ SKUs goes to which warehouse?
used a 5-week training window for allocation decisions
updated allocations weekly based on recent patterns
balanced stability vs. responsiveness
In the case study, SKUs were grouped by category-brand combinations to reduce the problem size while maintaining allocation quality. New SKUs inherit the allocation of their cluster!
Vlćek and Voigt (2024): CHI heuristic and case study
For more interesting literature to learn more about Julia, take a look at the literature list of this course.
References
Catalán, Andrés, and Marshall Fisher. 2012. “Assortment Allocation to Distribution Centers to Minimize Split Customer Orders.”SSRN Electronic Journal, ahead of print. https://doi.org/10.2139/ssrn.2166687.
Hiley, Amanda, and Bryant A. Julstrom. 2006. “The Quadratic Multiple Knapsack Problem and Three Heuristic Approaches to It.” In Proceedings of the 8th Annual Conference on Genetic and Evolutionary Computation, edited by M. Keijzer. Association for Computing Machinery. https://doi.org/10.1145/1143997.1144096.
Vlćek, Tobias, and Guido Voigt. 2024. Optimizing SKU-WarehouseAllocations to Minimize SplitParcels in E-CommerceEnvironments. Working paper, to be submitted to Manufacturing & Service Operations Management.
Zhu, Shan, Xiangpei Hu, Kai Huang, and Yufei Yuan. 2021. “Optimization of Product Category Allocation in Multiple Warehouses to Minimize Splitting of Online Supermarket Customer Orders.”European Journal of Operational Research 290 (2): 556–71. https://doi.org/10.1016/j.ejor.2020.08.024.
Computationally intensive with CPLEX, Zhu et al. (2021)↩︎
Greedy Randomized Adaptive Search Procedure, Zhu et al. (2021)↩︎
Based on numerical experiments with QMK instances. Times are averages over the instances solved to optimality; the percentage shows the share of instances solved within one hour, X = none solved within one hour.↩︎
QMKP is not applicable for instance in case study↩︎