Oracle paper
Oracle Paper — reference implementation for price-setting problems in logistics.
This package provides four solution approaches for the Price-Setting Bilevel Hub Location Problem (PS-BHLP), built on top of BilevelPy:
PS_HLP— Big-M linearizationPC_HLP— Fast Lagrange with recursive client aggregationPPC_HLP— Standard Lagrange decomposition with precedence constraintsPS_BHLP— Bilevel formulation (requires Julia)
BilevelDataCol
¶
Bases: StrEnum
Extra column names used in bilevel hub location datasets.
These columns sit alongside the standard
[DataCol][bilevelpy.core.columns.DataCol] columns and carry the
additional data that the bilevel models need: per-client budgets,
transport weights, Lagrange multipliers, and aggregated keys for
the recursive (PC-HLP) formulation.
Attributes:
| Name | Type | Description |
|---|---|---|
CLIENT_KEY |
Unique integer key assigned to each client. |
|
CLIENT_ID_ROUTE |
Zero-based index \(z\) of a client on route \((i,j)\). |
|
CLIENT_ROUTE |
The \((i,j)\) route tuple the client belongs to. |
|
CLIENT_RATIO |
Budget-to-weight ratio \(b_{ij}^z / a_{ij}^z\). |
|
BUDGET |
Client budget \(b_{ij}^z\) (willingness to pay). |
|
TRANSPORT_WEIGHT_CLIENT |
Client demand weight \(a_{ij}^z\). |
|
LAGRANGE |
Lagrange multiplier \(\lambda_{ij}^z\) for the PPC-HLP model. |
|
RECURSIVE_LAGRANGE |
Lagrange multiplier after recursive merging (PC-HLP). |
|
CLIENT_KEYS |
Mapping \((i,j,z) \to\) list of original client keys that were merged into this aggregated client. |
|
SUMMED_LINEAR_WEIGHTS |
Sum of \(a_{ij}^z\) over all clients merged into an aggregated recursive client. |
|
SUMMED_BUDGETS |
Sum of \(b_{ij}^z\) over all clients merged into an aggregated recursive client. |
OraclePaperModelNames
¶
Registry of [ModelMetaData][bilevelpy.models.meta.ModelMetaData]
instances for all four models studied in the paper.
Each attribute is a [ModelMetaData][bilevelpy.models.meta.ModelMetaData]
carrying a short value (used for equality checks) and a
display_name (shown in UIs and reports).
Attributes:
| Name | Type | Description |
|---|---|---|
PS_HLP |
Big-M price-setting model (price is a Gurobi variable). |
|
PC_HLP |
Fast Lagrange model with recursive client aggregation. |
|
PPC_HLP |
Standard Lagrange decomposition with precedence constraints. |
|
PS_BHLP |
Bilevel formulation solved via Julia + BilevelJuMP. |
PC_HLP(n_hubs, alpha, data)
¶
Bases: BaseModel
Fast Lagrange Model — recursive client-aggregated formulation.
Unlike PS_HLP, this model uses aggregated client keys \((i,j,z)\) where \(z\) indexes a group of original clients. Clients are grouped by route \((i,j)\), ranked, and Lagrange multipliers \(\lambda_{ij}^z\) are computed recursively over segments. Price is not a Gurobi variable — it is inferred post-solve from the budget/weight ratio of the marginal client.
Variables:
| Symbol | Reproduces | Variable | Domain |
|---|---|---|---|
| \(x_{ik}\) | — | [AllocationVariable][bilevelpy.models.vars.hlp_vars.AllocationVariable] |
\(\{0,1\}\) |
| \(y_{ij}^z\) | — | RecursiveClientDecisionVariable |
\(\{0,1\}\) |
| \(X_{ijkm}^z\) | \(y_{ij}^z \cdot x_{ik} \cdot x_{jm}\) | RecursiveLinearXYVariable |
\(\{0,1\}\) |
Constraints:
| Constraint | Reference |
|---|---|
| HLP base | [NumberOfHubs][bilevelpy.models.constraints.hlp_constraints.NumberOfHubsConstraint], [SingleAllocation][bilevelpy.models.constraints.hlp_constraints.SingleAllocationConstraint], [AssignmentRestriction][bilevelpy.models.constraints.hlp_constraints.AssignmentRestrictionConstraint] |
| \(y = \sum X\), \(X \leq x\) | RecursiveLinearizationConstraint |
Objective (maximizes Lagrange-adjusted profit):
where \(K\) is the set of aggregated client keys and \(\lambda_{ij}^z\) are the recursive Lagrange multipliers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_hubs
|
int
|
Number of hubs to open (\(p\)). |
required |
alpha
|
float
|
Cost scaling factor (\(\alpha\)). |
required |
data
|
MultiEntityDataset
|
Dataset with recursive Lagrange multipliers and grouped client keys. |
required |
Source code in src/oracle_paper/models/pc_hlp.py
PPC_HLP(n_hubs, alpha, data)
¶
Bases: BaseModel
Lagrange Model — standard Lagrange multiplier decomposition.
Uses Lagrange multipliers \(\lambda_{ij}^z\) to decompose the bilevel problem. Price is inferred post-solve (no price variable). Includes a precedence constraint ordering client decisions.
Variables:
| Symbol | Reproduces | Variable | Domain |
|---|---|---|---|
| \(x_{ik}\) | — | [AllocationVariable][bilevelpy.models.vars.hlp_vars.AllocationVariable] |
\(\{0,1\}\) |
| \(y_{ij}^z\) | — | ClientDecisionVariable |
\(\{0,1\}\) |
| \(X_{ijkm}^z\) | \(y_{ij}^z \cdot x_{ik} \cdot x_{jm}\) | LinearXYVariable |
\(\{0,1\}\) |
Constraints:
| Constraint | Reference |
|---|---|
| HLP base | [NumberOfHubs][bilevelpy.models.constraints.hlp_constraints.NumberOfHubsConstraint], [SingleAllocation][bilevelpy.models.constraints.hlp_constraints.SingleAllocationConstraint], [AssignmentRestriction][bilevelpy.models.constraints.hlp_constraints.AssignmentRestrictionConstraint] |
| \(y = \sum X\), \(X \leq x\) | LinearizationConstraint |
| \(y_{ij}^z \geq y_{ij}^{z+1}\) | [PrecendenceConstraint][oracle_paper.constraints.precedence_constraint.PrecendenceConstraint] |
Objective (maximizes Lagrange-adjusted profit):
Precedence constraint:
Ensures clients on the same route are accepted in ranked order (highest budget/weight ratio first).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_hubs
|
int
|
Number of hubs to open (\(p\)). |
required |
alpha
|
float
|
Cost scaling factor (\(\alpha\)). |
required |
data
|
MultiEntityDataset
|
Dataset with Lagrange multipliers and client data. |
required |
Source code in src/oracle_paper/models/ppc_hlp.py
PS_BHLP(n_hubs, alpha, data)
¶
Bases: BaseModel
PS-BHLP solved via Julia Big-M reformulation.
Requires Julia ≥ 1.10 with JuMP, Gurobi, BilevelJuMP, and JSON on PATH.
Source code in src/oracle_paper/models/ps_bhlp.py
PS_HLP(n_hubs, alpha, data)
¶
Bases: BaseModel
Price-Setting Hub Location Problem with Big-M linearization.
The leader (hub operator) sets prices \(p_{ij}\) and allocates hubs \(x_{ik}\). The follower (clients) chooses routes \(y_{ij}^z\) to maximize their utility.
Variables:
| Symbol | Reproduces | Variable | Domain |
|---|---|---|---|
| \(x_{ik}\) | — | [AllocationVariable][bilevelpy.models.vars.hlp_vars.AllocationVariable] |
\(\{0,1\}\) |
| \(y_{ij}^z\) | — | ClientDecisionVariable |
\(\{0,1\}\) |
| \(X_{ijkm}^z\) | \(y_{ij}^z \cdot x_{ik} \cdot x_{jm}\) | LinearXYVariable |
\(\{0,1\}\) |
| \(p_{ij}\) | — | PriceVariable |
\(\mathbb{R}_{\geq 0}\) |
Constraints:
| Constraint | Reference |
|---|---|
| Exactly \(p\) hubs open | [NumberOfHubsConstraint][bilevelpy.models.constraints.hlp_constraints.NumberOfHubsConstraint] |
| Each node to one hub | [SingleAllocationConstraint][bilevelpy.models.constraints.hlp_constraints.SingleAllocationConstraint] |
| Only assigned to open hubs | [AssignmentRestrictionConstraint][bilevelpy.models.constraints.hlp_constraints.AssignmentRestrictionConstraint] |
| \(y = \sum X\), \(X \leq x\) | LinearizationConstraint |
| Price-revenue coupling | BigMConstraint |
Objective (leader maximizes profit):
where \(\tilde{c}_{ij}(x) = \sum_{k,m \in V} X_{ijkm}^z \bigl(\alpha\, c_{ik} + \alpha\, c_{km} + c_{mj}\bigr)\) is the transport cost through hubs \(k,m\).
Big-M constraint (couples price and decision):
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_hubs
|
int
|
Number of hubs to open (\(p\)). |
required |
alpha
|
float
|
Cost scaling factor (\(\alpha\)). |
required |
data
|
MultiEntityDataset
|
Dataset with client weights, budgets, and transport costs. |
required |
Source code in src/oracle_paper/models/ps_hlp.py
get_transport_cost_sum(i, j, z)
¶
Compute the transport cost \(\tilde{c}_{ij}(x)\) for a route.