Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
ec8ae75
notebook dev, adds nest coefficient in logit.py
May 3, 2022
c973be8
prototype work - return leaf and node (exp max) utilities, nest spec
May 4, 2022
a4a7630
adds choice based on walking nest levels
May 4, 2022
c6b609a
prototype simple_simulate
May 4, 2022
5dc1a44
baby steps towards validation
May 4, 2022
83a86f5
scale of leaf utility
May 4, 2022
5a7ad3c
pull out cruft
May 4, 2022
5e8bf16
towards validation of probs for single trip
May 5, 2022
a31d97f
probs trip set up
May 5, 2022
ab8a212
probs validation clean up
May 5, 2022
fd5ca14
fixes scale of nest utilities
May 5, 2022
f2cea72
two level still off
May 6, 2022
4883c33
recursive utility calculation fix
May 6, 2022
b60702b
clean up
May 6, 2022
7c21407
adds nested utility scale
May 6, 2022
932d5ad
scaling in recursive nest utilities
May 6, 2022
1286183
output clean up
May 6, 2022
c95f68d
fixes bug in choice for tree
May 8, 2022
9f4d262
check
May 8, 2022
6c17d89
caching nest level names and alternatives
May 8, 2022
7984392
removes trace in runtime tests
May 8, 2022
ebf64c6
larch notebook to calculate probs a different way
May 9, 2022
e02b46a
compare to larch probs
May 9, 2022
4ee74ea
clean up
May 9, 2022
4d0d823
inspecting a couple of test cases
May 9, 2022
fba8728
nest scales in asim seem to be all between 0 and 1, so not like in la…
May 10, 2022
e821b57
nest scaling comment
May 10, 2022
7bfb80a
adds comment regarding potential random choice runtime improvement
May 15, 2022
42901bf
adds goodness of fit test and loop over all trips
May 16, 2022
3700a9e
some validation metrics
May 16, 2022
75c16a2
validation
May 16, 2022
8668383
nicer comparison
May 16, 2022
921983f
adds more convergence analysis
May 17, 2022
7694563
simple siumlate mnl frozen rand ind util
Jun 15, 2022
0c6f4c8
nested now with alternative numbers, not names, change structure to b…
Jun 15, 2022
f725ca6
pass through frozen_impl flag
Jun 15, 2022
1a786f2
implement flag in settings, apply to all simple simulate models
Jun 15, 2022
1d4ca9a
froxen rand ind util in interaction simulate
Jun 15, 2022
f3e1610
add setting to interaction_simulate call
Jun 15, 2022
9ac51c9
usage of interaction_sample_simulate
Jun 15, 2022
e65635d
interaction sample notebook
Jun 16, 2022
9950f84
interaction_sample dev work
Jun 16, 2022
36789a3
interaction_sample dev work
Jun 16, 2022
64c4e6e
fixes alternative index as chosen value
Jun 16, 2022
e3e4326
interaction sample frozen rand indiv util
Jun 16, 2022
00208e7
adds interaction_sample at the module level, not individual model
Jun 17, 2022
005b131
adds interaction_sample at the module level, not individual model
Jun 17, 2022
bbce6aa
nested index instead of name
Jun 19, 2022
7fbba93
fies frozen_rand setting call
Jun 19, 2022
8c1d1ed
pass arguments in
Jun 19, 2022
9685aca
make place of call consistent
Jun 19, 2022
19d1222
remove debug print statement
Jun 19, 2022
61a314f
move reporting in make choices
Jun 19, 2022
8c16765
make choice indexing for nested logit consistent with mnl and cumsum MC
Jun 19, 2022
087ec0e
use fru in models that use logit.make_choices w/o simulate wrapper
Jun 19, 2022
c26c80c
no fru for probabilitic lookup tables
Jun 19, 2022
d14fac3
memory saving work - delete dfs wherever possible
Jun 20, 2022
f890799
fake rand tracing
Jun 20, 2022
043a0bd
working through all make_choices calls to implement memory saving hac…
Jun 20, 2022
f9b1e2e
working through all make_choices calls to implement memory saving hac…
Jun 20, 2022
4b5cad2
working through all make_choices calls to implement memory saving hac…
Jun 20, 2022
b48dd71
working through all make_choices calls to implement memory saving hac…
Jun 20, 2022
17792f5
working through all make_choices calls to implement memory saving hac…
Jun 20, 2022
affe2b6
remove usage of choose_individual_max_utility
Jun 20, 2022
6b38f12
remove usage of choose_individual_max_utility
Jun 20, 2022
0387c35
remove usage of choose_individual_max_utility
Jun 20, 2022
8ac91f1
remove usage of choose_individual_max_utility
Jun 20, 2022
eea84ca
remove usage of choose_individual_max_utility
Jun 20, 2022
cb807d1
remove usage of choose_individual_max_utility
Jun 20, 2022
f0cc563
interaction_sample util based w/p probs
Jun 20, 2022
417e90f
wrong method in cdap
Jun 20, 2022
4f825ae
style fixes
Jun 20, 2022
7a6cc29
need probs in interaction_sample - try it the quick way
Jun 20, 2022
f0143e9
remove false comparison
Jun 20, 2022
f6d81d6
bug fix
Jun 20, 2022
b449593
bug fix
Jun 20, 2022
dbc809a
add utility based choice option for transit virtual pathbuilder
Jun 20, 2022
4c6a524
custom chooser
Jun 20, 2022
2ec41b1
mem tracing in interaction_sample
Jun 20, 2022
47601e3
bug fix
Jun 20, 2022
e0555d4
interaction_sample memory saving implementation
Jun 20, 2022
2568b72
memory work
Jun 20, 2022
78630be
spelling
Jun 20, 2022
c6d75d1
delete after last ref, not before
Jun 20, 2022
7a66a67
set index
Jun 20, 2022
7df4c8d
to numpy once
Jun 20, 2022
d6f4f97
remove comment
Jun 20, 2022
26a7090
interaction sample dev
Jun 21, 2022
313bcd0
remove scale and location params from ev1 quartile fct
Jun 21, 2022
6451abd
use numpy's gumbel to draw from ev1
Jun 24, 2022
3973bcd
clean up
Jun 24, 2022
c0d1ca1
gumbel by hand by inverse cdf
Jun 24, 2022
6b0b4e9
memory logging
Jun 27, 2022
9a17395
resolves merge conflicts with main v1.2
Jan 31, 2023
b86093f
Merge branch 'master' into janzill/utilit_based_choices_2025
Mar 29, 2025
792d183
merge bug
Mar 29, 2025
08d013a
more merge bugs
Mar 29, 2025
75bb84d
more merge fixes, example runs through
Mar 29, 2025
c6feaef
log eet setting on start up
Mar 29, 2025
114b747
some variation checks, dev notebooks, to delete
Apr 2, 2025
e1e9d08
seeding corr test
Apr 2, 2025
14441a6
corr
Apr 2, 2025
73b8c32
sign on logsum
Apr 2, 2025
f5f365f
removes notebook folder
Apr 2, 2025
0f54cec
compute_setting overrides for eet, currently only for interaction_sam…
Apr 6, 2025
11d86a1
Adds subcomponent-specific eet setting
Apr 6, 2025
30ddb3e
default compute settings set before, no need to check if none
Apr 6, 2025
5105b17
Merge remote-tracking branch 'origin/master' into janzill/utilit_base…
Apr 6, 2025
c6d60c6
comment clean up
Apr 11, 2025
6a0987d
identifies eet todos
Apr 11, 2025
5637fb0
test SOA MC for disagg access
Apr 11, 2025
6f8958b
lint
Apr 11, 2025
9d12b08
comments
May 24, 2025
9a0fb66
more comments
May 24, 2025
0fa183e
jtp custom chooser for EET
May 25, 2025
9900f48
lint
May 25, 2025
892c3fb
move interaction sample without sampling out of MC loop to enable for…
May 25, 2025
d6ecb0d
update comments
May 25, 2025
3793ec2
fix no sampling in interaction_sample
May 25, 2025
fc68697
fix _interaction_sample return doc
May 25, 2025
28142cd
fix bool conversion of None for eet compute settings in sub-components
May 25, 2025
5de1d23
compute settings in disaggreagte accessibility w/o hack
May 25, 2025
2a563ff
lint
May 25, 2025
ef0be21
fix nest_spec is None bug
May 26, 2025
1f815e8
remove comment
May 26, 2025
41d49ff
clean up comments
May 26, 2025
582c998
comment clean up
May 26, 2025
49fcaa5
Merge remote-tracking branch 'origin/master' into janzill/utilit_base…
May 29, 2025
c40b989
avoid choosing alternatives corresponding to padded utilities in inte…
May 29, 2025
5636cd9
lint
May 29, 2025
94e629a
patch other instance of padded_utility for eet
May 29, 2025
e102a9e
adds validate utility method to align with unavailable choices in MC …
May 29, 2025
66cdac9
consistently treat utilities that would lead to zero choices in MC si…
May 30, 2025
3b48a07
lint
May 30, 2025
6f31c76
fix allow_zero_probs for prob calculation in EET interaction_sample
May 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
nested now with alternative numbers, not names, change structure to b…
…e more consistent with current impl
  • Loading branch information
Jan Zill committed Jun 15, 2022
commit 0c6f4c8eb5a81505469dab3b6d531a4361682054
35 changes: 26 additions & 9 deletions activitysim/core/logit.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,8 @@ def choose_from_tree(nest_utils, all_alternatives, logit_nest_groups, nest_alter
# alternatives and set the corresponding entry to 1 for each row, set all other alternatives at this level to zero.
# Once the tree is walked (all alternatives have been processed), take the product of the alternatives in each
# leaf's alternative list. Then pick the only alternative with entry 1, all others must be 0.
def make_choices_ru_frozen(nested_utilities, nest_spec, trace_label=None, trace_choosers=None):
def make_choices_ru_frozen_nl(nested_utilities, nest_spec):
""" walk down the nesting tree and make choice at each level, which is the root of the next level choice."""
trace_label = tracing.extend_trace_label(trace_label, 'make_choices_ru_frozen')
nest_utils_for_choice = add_ev1_random(nested_utilities)

all_alternatives = set(nest.name for nest in each_nest(nest_spec, type='leaf'))
Expand All @@ -243,22 +242,34 @@ def make_choices_ru_frozen(nested_utilities, nest_spec, trace_label=None, trace_
)
assert not choices.isnull().any(), "No choice for XXX - implement reporting"
choices = pd.Series(choices, index=nest_utils_for_choice.index)

# TODO [janzill Jun2022]: REMOVE HACK, make this numpy and positional indexes from the beginning
choices = choices.map({v: k for k,v in enumerate(nest_utils_for_choice.columns)})

return choices


# TODO: integrate with nested impl above
# TODO: make everything in nested and here numpy from beginning to make choices consistent with previous impl (
# want column index and not alternative name)
def make_choices_ru_frozen_mnl(utilities, trace_label=None):
trace_label = tracing.extend_trace_label(trace_label, 'make_choices_ru_frozen_mnl')
# TODO [janzill Jun2022]: integrate with nested impl above
# TODO [janzill Jun2022]: make everything in nested and here numpy from beginning to make choices consistent with
# previous impl (want column index and not alternative name)
def make_choices_ru_frozen_mnl(utilities):
utilities_incl_unobs = add_ev1_random(utilities)
choices = np.argmax(utilities_incl_unobs.to_numpy(), axis=1)
assert not np.isnan(choices).any(), "No choice for XXX - implement reporting"
choices = pd.Series(choices, index=utilities_incl_unobs.index)
return choices

def make_choices_ru_frozen(utilities, nest_spec=None, trace_label=None):
trace_label = tracing.extend_trace_label(trace_label, 'make_choices_ru_frozen_mnl')
if nest_spec is None:
choices = make_choices_ru_frozen_mnl(utilities)
else:
choices = make_choices_ru_frozen_nl(utilities, nest_spec)
return choices


def make_choices(probs, trace_label=None, trace_choosers=None, allow_bad_probs=False):
def make_choices(probs, utilities=None, nest_spec=None, trace_label=None, trace_choosers=None, allow_bad_probs=False,
choose_individual_max_utility=False):
"""
Make choices for each chooser from among a set of alternatives.

Expand Down Expand Up @@ -286,8 +297,14 @@ def make_choices(probs, trace_label=None, trace_choosers=None, allow_bad_probs=F
"""
trace_label = tracing.extend_trace_label(trace_label, 'make_choices')

# probs should sum to 1 across each row
if choose_individual_max_utility:
choices = make_choices_ru_frozen(utilities, nest_spec, trace_label)
# TODO: rands
rands = pd.Series(np.zeros_like(utilities.index.values), index=utilities.index)
return choices, rands


# probs should sum to 1 across each row
BAD_PROB_THRESHOLD = 0.001
bad_probs = \
probs.sum(axis=1).sub(np.ones(len(probs.index))).abs() \
Expand Down
Loading