Skip to content

Mixins

Solution mixins that add tables and derived quantities to solution reports.

DecisionMixin

Adds a decision table (active routes only) to the solution summary.

Uses ClientDecisionVariable and filters to show only routes where \(y_{ij}^z > 0.5\).

HubLocationMixin

Provides hub and allocation intelligence for any HLP-based model.

Reads the [AllocationVariable][bilevelpy.models.vars.hlp_vars.AllocationVariable] from the solution to determine which nodes are selected as hubs and how non-hub nodes are assigned to them.

allocations_dict property

Maps nodes to their assigned hubs.

hubs property

Returns list of node indices where X[i,i] == 1.

InferredPricingMixin

Logic for models where price is not a Gurobi variable but is inferred post-solve from the active client decisions.

Iterates over routes and finds the marginal (highest-index) client with \(y_{ij}^z > 0.5\), then computes price as budget / weight.

LinearWeightMixin

Provides the transport weight \(a_{ij}^z\) for a given client route.

Used by InferredPricingMixin to compute the implied price from active client decisions.

PriceMixin

Adds a pricing table to the solution summary.

Extracts the PriceVariable values from the solution and formats them as a DataFrame table.

RecursiveDecisionMixin

Handles unrolling aggregated client decisions from recursive models (PC-HLP) back to the original dataset indices.

The PC-HLP model groups clients into merged segments, so Gurobi returns decisions for aggregated client keys. This mixin maps those decisions back to the original per-client indices so the solution summary shows individual client-level results.