Lagrange
LagrangeCalculator()
¶
Bases: TrackableProcessor
Compute Lagrange multipliers \(\lambda_{ij}^z\) for the PPC-HLP model.
For each route \((i,j)\), the calculator sorts clients by their budget-to-weight ratio and computes the Lagrange multiplier sequence using the recursive formula:
The result is stored in
BilevelDataCol.LAGRANGE.
Uses the track_metric
decorator to measure computation time automatically.
Source code in src/oracle_paper/data/calculator/base.py
calculate_lagrange(dict_a, dict_b)
staticmethod
¶
Compute the Lagrange multiplier sequence for one route's clients.
$\(\lambda_k = b_k + \sum_{t=0}^{k-1} a_t \cdot \Delta_k\)$ where \(\Delta_k = b_k/a_k - b_{k-1}/a_{k-1}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dict_a
|
dict[int, float]
|
Client weights \(\{z: a_{ij}^z\}\) sorted by \(z\). |
required |
dict_b
|
dict[int, float]
|
Client budgets \(\{z: b_{ij}^z\}\) sorted by \(z\). |
required |
Returns:
| Type | Description |
|---|---|
dict[int, float]
|
Mapping \(\{z: \lambda_{ij}^z\}\) of Lagrange multipliers. |
Source code in src/oracle_paper/data/calculator/lagrange.py
process(dataset)
¶
Compute Lagrange multipliers and add them to the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
MultiEntityDataset
|
Dataset with client weights and budgets (modified in-place). |
required |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If required entities are missing. |