Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-binary incidence #127

Merged
merged 2 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions docs/software.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,5 @@ Release Notes
* v0.3.4 - add survey weighting use case
* v0.3.5 - add Python 3.5+ support
* v0.4 - transfer to ActivitySim.org
* v0.4.1 - package updates
* v0.4.2 - validation script in Python
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* v0.4.2 - validation script in Python
* v0.4.2 - allow non-binary incidences and updates to fix validation notebook

2 changes: 1 addition & 1 deletion populationsim/balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def np_balancer(
yy + relaxed_constraint / float(importance))

# update HH weights
weights_final[incidence[c] > 0] *= gamma[c]
weights_final *= pow(gamma[c], incidence[c])

# clip weights to upper and lower bounds
weights_final = np.clip(weights_final, weights_lower_bound, weights_upper_bound)
Expand Down
2 changes: 1 addition & 1 deletion populationsim/simul_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def np_simul_balancer(
yy + (relaxed_constraint / float(importance)))

# update HH weights
sub_weights[z][incidence[c] > 0] *= gamma[z, c]
sub_weights[z] *= pow(gamma[z, c], incidence[c])

# clip weights to upper and lower bounds
sub_weights[z] = np.clip(sub_weights[z], weights_lower_bound, weights_upper_bound)
Expand Down
7 changes: 5 additions & 2 deletions populationsim/steps/sub_balancing.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,12 @@ def sub_balancing(settings, crosswalk, control_spec, incidence_table):
# only want ones for which there are (non-zero) controls
parent_ids = parent_controls_df.index.intersection(parent_ids)

for parent_id in parent_ids:
num_parent_ids = len(parent_ids)
for idx, parent_id in enumerate(parent_ids, start=1):

logger.info("balancing seed %s, %s %s" % (seed_id, parent_geography, parent_id))
log_msg = "balancing {}/{} seed {}, {} {}"
log_msg = log_msg.format(idx, num_parent_ids, seed_id, parent_geography, parent_id)
logger.info(log_msg)

initial_weights = weights_df[weights_df[parent_geography] == parent_id]
initial_weights = initial_weights.set_index(settings.get('household_id_col'))
Expand Down
4 changes: 2 additions & 2 deletions populationsim/tests/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def teardown_function(func):


TAZ_COUNT = 36
TAZ_100_HH_COUNT = 25
TAZ_100_HH_COUNT = 33
TAZ_100_HH_REPOP_COUNT = 26


Expand All @@ -51,7 +51,7 @@ def test_full_run1():
'meta_control_factoring',
'final_seed_balancing',
'integerize_final_seed_weights',
'sub_balancing.geography = TRACT',
'sub_balancing.geography=TRACT',
'sub_balancing.geography=TAZ',
'expand_households',
'summarize',
Expand Down
38 changes: 19 additions & 19 deletions scripts/validation.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='populationsim',
version='0.4.1',
version='0.4.2',
description='Population Synthesis',
author='contributing authors',
author_email='[email protected]',
Expand Down