traveler.steps.simple_choice#

class traveler.steps.simple_choice(name, utility_func, altnames, param, on=None, result_name=None, chunk_size=10_000, nest_spec=None)[source]#

Bases: Step

A multinomial or nested logit choice model.

Pass nest_spec to 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_func and any named nest coefficients.

  • on (type[StoredTable], optional) – Chooser table used when choosers is 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, and alternatives entries. Coefficients may be numbers or keys in param. If omitted, use multinomial logit.

Methods#

analytic_share(store, *[, choosers, param])

Calculate the analytic share of each alternative.

analytic_share_loss(store, *[, choosers, ...])

Compute squared loss between modeled and target shares.

analytic_share_loss_grad(store, *[, ...])

Differentiate analytic-share loss with respect to parameters.

calibrate_analytic_share(store, *[, ...])

Calibrate selected parameters to match target alternative shares.

initialize_for_store(store)

Initialize store-dependent alternatives for the choice model.

logsum(store, *[, choosers, param])

Compute logsum accessibility values for choosers.

probability(store, *[, choosers, param])

Calculate the choice probabilities using a simple choice model.

run_on(store)

Simulate choices and assign them to the configured table.

simulate_choice(store, *[, choosers, param])

Make a choice using a simple choice model.

utility(store, *[, choosers, param, debug, ...])

Compute utility values for the choice alternatives.