Skip to content

Commit

Permalink
Merge pull request #30 from UDST/alternative-ratio-fix
Browse files Browse the repository at this point in the history
[v0.1.1] Adding 'alternative_ratio' parameter for 'utils.lcm_simulate()'
  • Loading branch information
smmaurer authored Jul 10, 2019
2 parents 1543941 + 200083d commit 3e481bf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# UrbanSim Defaults change log

#### 0.1.1 (2019-07-10)

- adds optional parameter to `utils.lcm_simulate()` for `alternative_ratio`

#### 0.1 (2019-06-19)

- initial release
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1'
release = '0.1.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='urbansim_defaults',
version='0.1',
version='0.1.1',
description='Installs and runs the urbansim defaults.',
author='UrbanSim, Inc.',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion urbansim_defaults/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = __version__ = '0.1'
version = __version__ = '0.1.1'
10 changes: 8 additions & 2 deletions urbansim_defaults/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ def lcm_estimate(cfg, choosers, chosen_fname, buildings, join_tbls, out_cfg=None

def lcm_simulate(cfg, choosers, buildings, join_tbls, out_fname,
supply_fname, vacant_fname,
enable_supply_correction=None, cast=False):
enable_supply_correction=None, cast=False,
alternative_ratio=2.0):
"""
Simulate the location choices for the specified choosers
Expand Down Expand Up @@ -344,6 +345,10 @@ def lcm_simulate(cfg, choosers, buildings, join_tbls, out_fname,
an identifier which segments buildings into submarkets
cast : boolean
Should the output be cast to match the existing column.
alternative_ratio : float, optional
Value to override the setting in urbansim.models.dcm.predict_from_cfg.
Above this ratio of alternatives to choosers (default of 2.0), the
alternatives will be sampled to improve computational performance
"""
cfg = misc.config(cfg)

Expand Down Expand Up @@ -448,7 +453,8 @@ def lcm_simulate(cfg, choosers, buildings, join_tbls, out_fname,
print " reducing locations to size of movers for performance gain"
movers = movers.head(int(vacant_units.sum()))

new_units, _ = yaml_to_class(cfg).predict_from_cfg(movers, units, cfg)
new_units, _ = yaml_to_class(cfg).predict_from_cfg(movers, units, cfg,
alternative_ratio=alternative_ratio)

# new_units returns nans when there aren't enough units,
# get rid of them and they'll stay as -1s
Expand Down

0 comments on commit 3e481bf

Please sign in to comment.