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

Getting into sync with ActivitySim/develop #8

Merged
merged 6 commits into from
Jun 27, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: Bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: Feature
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
2 changes: 1 addition & 1 deletion .github/workflows/core_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:
- prototype_mtc_extended
- placeholder_sandag
- prototype_sandag_xborder
- prototype_semcog
- production_semcog
- prototype_mwcog
- placeholder_multiple_zone
fail-fast: false
Expand Down
13 changes: 9 additions & 4 deletions HOW_TO_RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@

00. Run black to ensure that the codebase passes all style checks.
This check should only take a few seconds. These checks are also done on
Travis and are platform independent, so they should not be necessary to
GitHub Actions and are platform independent, so they should not be necessary to
replicate locally, but are listed here for completeness.
```sh
black --check --diff .
```

00. Run the regular test suite on Windows. Travis tests are done on Linux,
but most users are on Windows, and the test suite should also be run
on Windows to ensure that it works on that platform as well. If you
00. Run the regular test suite on Windows. Most GitHub Actions tests are done on Linux,
Linux (it's faster to start up and run a new clean VM for testing) but most
users are on Windows, and the test suite should also be run on Windows to
ensure that it works on that platform as well. If you
are not preparing this release on Windows, you should be sure to run
at least through this step on a Windows machine before finalizing a
release.
Expand Down Expand Up @@ -135,6 +136,10 @@
```sh
gh release create v1.2.3
```
The process of creating and tagging a release will automatically
trigger various GitHub Actions scripts to build, test, and publish the
new release to PyPI and conda forge, assuming there are no errors.

For a development pre-release, include the `--prerelease` argument.
As the project's policy is that only formally released code is merged
to the main branch, any pre-release should also be built against a
Expand Down
1 change: 1 addition & 0 deletions activitysim/abm/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
joint_tour_frequency,
joint_tour_participation,
joint_tour_scheduling,
joint_tour_frequency_composition,
location_choice,
mandatory_scheduling,
mandatory_tour_frequency,
Expand Down
71 changes: 59 additions & 12 deletions activitysim/abm/models/cdap.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def cdap_simulate(persons_merged, persons, households, chunk_size, trace_hh_id):
file_name=model_settings["FIXED_RELATIVE_PROPORTIONS_SPEC"]
)

add_joint_tour_utility = model_settings.get("ADD_JOINT_TOUR_UTILITY", False)

if add_joint_tour_utility:
# Rules and coefficients for generating cdap joint tour specs for different household sizes
joint_tour_coefficients_file_name = model_settings.get(
"JOINT_TOUR_COEFFICIENTS", "cdap_joint_tour_coefficients.csv"
)
cdap_joint_tour_coefficients = pd.read_csv(
config.config_file_path(joint_tour_coefficients_file_name), comment="#"
)

persons_merged = persons_merged.to_frame()

# add tour-based chunk_id so we can chunk all trips in tour together
Expand All @@ -101,11 +112,27 @@ def cdap_simulate(persons_merged, persons, households, chunk_size, trace_hh_id):
# (also when multiprocessing locutor might not see all household sizes)
logger.info("Pre-building cdap specs")
for hhsize in range(2, cdap.MAX_HHSIZE + 1):
spec = cdap.build_cdap_spec(cdap_interaction_coefficients, hhsize, cache=True)
spec = cdap.build_cdap_spec(
cdap_interaction_coefficients,
hhsize,
cache=True,
joint_tour_alt=add_joint_tour_utility,
)
if inject.get_injectable("locutor", False):
spec.to_csv(
config.output_file_path("cdap_spec_%s.csv" % hhsize), index=True
)
if add_joint_tour_utility:
# build cdap joint tour spec
# joint_spec_dependency = spec.loc[[c for c in spec.index if c.startswith(('M_p', 'N_p', 'H_p'))]]
joint_spec = cdap.build_cdap_joint_spec(
cdap_joint_tour_coefficients, hhsize, cache=True
)
if inject.get_injectable("locutor", False):
joint_spec.to_csv(
config.output_file_path("cdap_joint_spec_%s.csv" % hhsize),
index=True,
)

if estimator:
estimator.write_model_settings(model_settings, "cdap.yaml")
Expand All @@ -127,17 +154,32 @@ def cdap_simulate(persons_merged, persons, households, chunk_size, trace_hh_id):

logger.info("Running cdap_simulate with %d persons", len(persons_merged.index))

choices = cdap.run_cdap(
persons=persons_merged,
person_type_map=person_type_map,
cdap_indiv_spec=cdap_indiv_spec,
cdap_interaction_coefficients=cdap_interaction_coefficients,
cdap_fixed_relative_proportions=cdap_fixed_relative_proportions,
locals_d=constants,
chunk_size=chunk_size,
trace_hh_id=trace_hh_id,
trace_label=trace_label,
)
if add_joint_tour_utility:
choices, hh_joint = cdap.run_cdap(
persons=persons_merged,
person_type_map=person_type_map,
cdap_indiv_spec=cdap_indiv_spec,
cdap_interaction_coefficients=cdap_interaction_coefficients,
cdap_fixed_relative_proportions=cdap_fixed_relative_proportions,
locals_d=constants,
chunk_size=chunk_size,
trace_hh_id=trace_hh_id,
trace_label=trace_label,
add_joint_tour_utility=add_joint_tour_utility,
)
else:
choices = cdap.run_cdap(
persons=persons_merged,
person_type_map=person_type_map,
cdap_indiv_spec=cdap_indiv_spec,
cdap_interaction_coefficients=cdap_interaction_coefficients,
cdap_fixed_relative_proportions=cdap_fixed_relative_proportions,
locals_d=constants,
chunk_size=chunk_size,
trace_hh_id=trace_hh_id,
trace_label=trace_label,
add_joint_tour_utility=add_joint_tour_utility,
)

if estimator:
estimator.write_choices(choices)
Expand All @@ -161,6 +203,11 @@ def cdap_simulate(persons_merged, persons, households, chunk_size, trace_hh_id):

# - annotate households table
households = households.to_frame()

if add_joint_tour_utility:
hh_joint = hh_joint.reindex(households.index)
households["has_joint_tour"] = hh_joint

expressions.assign_columns(
df=households,
model_settings=model_settings.get("annotate_households"),
Expand Down
Loading