biogeme.expressions.log_sampled_nested module¶
Arithmetic expressions accepted by Biogeme: sampled nested logit.
- class biogeme.expressions.log_sampled_nested.LogSampledNested(utilities, log_probabilities, alternative_ids, mev_utilities, mev_weights, mev_alternative_ids, nests, choice=0)[source]¶
Bases:
ExpressionLog probability for a sampled nested logit model.
This expression is designed for the sampling-of-alternatives framework.
It represents the same expression currently generated by
GenerateModel.get_nested_logit:\[\log P(0 \mid S) = K_0 - \log \sum_{i \in S} \exp(K_i),\]where the corrected kernel is
\[K_i = V_i - \omega_i + M_i,\]and, if alternative \(i\) belongs to nest \(m\),
\[M_i = (\mu_m - 1) V_i + \left(\frac{1}{\mu_m} - 1\right) \log \sum_{j \in S^{MEV}_m} w_j \exp(\mu_m V_j).\]Here \(\omega_i\) is the log sampling probability correction and \(w_j\) is the MEV sampling weight.
The expression avoids constructing a large tree of
ConditionalSum,ConditionalTermTuple,BelongsTo,exp, andlogexpressions.- Parameters:
utilities (dict[int, ExpressionOrNumeric])
log_probabilities (dict[int, ExpressionOrNumeric])
alternative_ids (dict[int, ExpressionOrNumeric])
mev_utilities (dict[int, ExpressionOrNumeric])
mev_weights (dict[int, ExpressionOrNumeric])
mev_alternative_ids (dict[int, ExpressionOrNumeric])
nests (NestsForNestedLogit | OldNestsForNestedLogit)
choice (ExpressionOrNumeric)
- get_value()[source]¶
Evaluate the sampled nested logit log probability using NumPy.
- Return type:
float
- logit_choice_avail()[source]¶
Return availability structures appearing in this expression.
- Return type:
list[LogitTuple]