biogeme.expressions.log_cross_nested module¶
Arithmetic expressions accepted by Biogeme: cross-nested logit.
- class biogeme.expressions.log_cross_nested.LogCrossNested(util, av, nests, choice, mu=None, _log_recommendation=True)[source]¶
Bases:
ExpressionLog probability of the cross-nested logit model.
This expression computes the CNL probability directly, instead of expanding it through generic WeightedLogSumExp and LogLogit nodes.
It implements:
\[H_i = \log \sum_m \alpha_{im}^{\mu_m} \exp(\mu_m V_i) B_m^{(1-\mu_m)/\mu_m}\]where
\[B_m = \sum_j a_j \alpha_{jm}^{\mu_m} \exp(\mu_m V_j).\]The log probability is then
\[H_y - \log \sum_j a_j \exp(H_j).\]If the optional global homogeneity parameter
muis provided, the explicit-mu CNL formulation is used. IfmuisNone, the standard formulation is used.- Parameters:
util (dict[int, ExpressionOrNumeric])
av (dict[int, ExpressionOrNumeric] | None)
nests (NestsForCrossNestedLogit | OldNestsForCrossNestedLogit)
choice (ExpressionOrNumeric)
mu (ExpressionOrNumeric | None)
_log_recommendation (bool)
- logit_choice_avail()[source]¶
Return availability structures appearing in this expression.
- Return type:
list[LogitTuple]
- recursive_construct_jax_function(numerically_safe)[source]¶
Generate a compact JAX function for CNL log probability.
- Return type:
Callable[[Array,Array,Array,Array],Array]- Parameters:
numerically_safe (bool)
- recursive_construct_pymc_model_builder()[source]¶
Return a vectorized, log-domain PyTensor builder for CNL.
- Return type:
- uses_sparse_memberships = False¶