traveler.demo.tour_mode.simple_choice#
- class traveler.demo.tour_mode.simple_choice(name, utility_func, altnames, param, on=None, result_name=None, chunk_size=10_000, nest_spec=None)[source]#
Bases:
StepA multinomial or nested logit choice model.
Pass
nest_specto use nested logit. When it is omitted, the model keeps the original multinomial-logit behavior.- Parameters:
name (str) – Stable step name, also used to derive chooser random-number keys.
utility_func (Callable) – Function returning one utility array per alternative.
altnames (tuple[str, ...] | tuple[int, ...] | str) – Ordered elemental alternatives, or an existing categorical group for MNL.
param (Parameters | dict[str, float]) – Parameters supplied to
utility_funcand any named nest coefficients.on (type[StoredTable], optional) – Chooser table used when
choosersis not passed explicitly.result_name (str, optional) – Column written by
run_on().chunk_size (int, optional) – Number of choosers evaluated in each multithreaded chunk.
nest_spec (dict, optional) – ActivitySim-style nesting tree. Each nest has
name,coefficient, andalternativesentries. Coefficients may be numbers or keys inparam. If omitted, use multinomial logit.
Methods#
|
Calculate the analytic share of each alternative. |
|
Compute squared loss between modeled and target shares. |
|
Differentiate analytic-share loss with respect to parameters. |
|
Calibrate selected parameters to match target alternative shares. |
|
Initialize store-dependent alternatives for the choice model. |
|
Compute logsum accessibility values for choosers. |
|
Calculate the choice probabilities using a simple choice model. |
|
Simulate choices and assign them to the configured table. |
|
Make a choice using a simple choice model. |
|
Compute utility values for the choice alternatives. |