ActivitySim / activitysim

An Open Platform for Activity-Based Travel Modeling
https://activitysim.github.io
BSD 3-Clause "New" or "Revised" License
189 stars 96 forks source link

Assertion error when running with sharrow on Development branch. #755

Open stefancoe opened 9 months ago

stefancoe commented 9 months ago

Describe the bug Code crashes on line 29 in land_use.py: assert df.index[0]==0

To Reproduce Steps to reproduce the behavior:

  1. @jpn-- You should be able to reproduce this with the data I shared with you in August. I have included the log file.

activitysim.log

stefancoe commented 8 months ago

@jpn-- testing the generic_whale branch, this is the commit that casues the issue: https://github.com/camsys/activitysim/commit/8435976c3d912679a3bed0aa37ffa444adaf4dfe

Any suggestions?

jpn-- commented 8 months ago

A (partial) suggestion, to get code at least started running:

  1. Add recode_pipeline_columns: true to settings.yaml in configs_sh_compile and configs_sh for your model. The default setting for this was moved from true to false to more widely support backwards compatibility, but having a zero-based index on the land use table is required for sharrow compatibility.
  2. Run from the code in PR #751 , which now includes a fix for the next error that this will trigger in your model, further down the line.

In my testing, you'll still end up with a crash later on in the model, I am working on fixing that as well.

stefancoe commented 8 months ago

Thanks @jpn-- ! Are you getting the new crash in non_mandatory_tour_frequency?

jpn-- commented 8 months ago

No, I am presently getting up to this error in non_mandatory_tour_destination:

[00:55.35] ERROR: ===== ERROR IN non_mandatory_tour_destination =====
[00:55.35] ERROR: Boolean array size 4796 is used to index array with shape (2398, 7).
Traceback (most recent call last):
  File "./activitysim/activitysim/core/workflow/steps.py", line 46, in wrapper
    return func(*args, **kwargs)
  File "./activitysim/activitysim/abm/models/non_mandatory_destination.py", line 75, in non_mandatory_tour_destination
    choices_df, save_sample_df = tour_destination.run_tour_destination(
  File "./activitysim/activitysim/abm/models/util/tour_destination.py", line 833, in run_tour_destination
    location_sample_df = run_destination_sample(
  File "./activitysim/activitysim/abm/models/util/tour_destination.py", line 564, in run_destination_sample
    choices = destination_presample(
  File "./activitysim/activitysim/abm/models/util/tour_destination.py", line 492, in destination_presample
    taz_sample = _destination_sample(
  File "./activitysim/activitysim/abm/models/util/tour_destination.py", line 109, in _destination_sample
    choices = interaction_sample(
  File "./activitysim/activitysim/core/interaction_sample.py", line 594, in interaction_sample
    choices = _interaction_sample(
  File "./activitysim/activitysim/core/interaction_sample.py", line 289, in _interaction_sample
    ) = interaction_simulate.eval_interaction_utilities(
  File "./activitysim/activitysim/core/interaction_simulate.py", line 418, in eval_interaction_utilities
    sh_utility_fat = sh_utility_fat[trace_rows, :]
...
stefancoe commented 8 months ago

Thanks. I am getting a similar error, but in non_mandatory_tour_frequency:

''' 24/10/2023 12:07:08 - ERROR - root - ===== ERROR IN non_mandatory_tour_frequency ===== 24/10/2023 12:07:08 - ERROR - root - Boolean array size 1728 is used to index array with shape (96, 210). Traceback (most recent call last): File "e:\asim_testing\asim_fix_mem_use\activitysim\activitysim\core\workflow\steps.py", line 46, in wrapper return func(*args, **kwargs) File "e:\asim_testing\asim_fix_mem_use\activitysim\activitysim\abm\models\non_mandatory_tour_frequency.py", line 251, in non_mandatory_tour_frequency choices = interaction_simulate( File "e:\asim_testing\asim_fix_mem_use\activitysim\activitysim\core\interaction_simulate.py", line 949, in interaction_simulate choices = _interaction_simulate( File "e:\asim_testing\asim_fix_mem_use\activitysim\activitysim\core\interaction_simulate.py", line 772, in _interaction_simulate interaction_utilities, trace_eval_results = eval_interaction_utilities( File "e:\asim_testing\asim_fix_mem_use\activitysim\activitysim\core\interaction_simulate.py", line 415, in eval_interaction_utilities sh_utility_fat = sh_utility_fat[trace_rows, :] File "C:\Users\Modeller.PSRC\Anaconda3\envs\asim_fix_mem_use\lib\site-packages\xarray\core\dataarray.py", line 823, in getitem return self.isel(indexers=self._item_key_to_dict(key)) File "C:\Users\Modeller.PSRC\Anaconda3\envs\asim_fix_mem_use\lib\site-packages\xarray\core\dataarray.py", line 1421, in isel variable = self._variable.isel(indexers, missing_dims=missing_dims) File "C:\Users\Modeller.PSRC\Anaconda3\envs\asim_fix_mem_use\lib\site-packages\xarray\core\variable.py", line 1378, in isel return self[key] File "C:\Users\Modeller.PSRC\Anaconda3\envs\asim_fix_mem_use\lib\site-packages\xarray\core\variable.py", line 899, in getitem dims, indexer, new_order = self._broadcast_indexes(key) File "C:\Users\Modeller.PSRC\Anaconda3\envs\asim_fix_mem_use\lib\site-packages\xarray\core\variable.py", line 732, in _broadcast_indexes self._validate_indexers(key) File "C:\Users\Modeller.PSRC\Anaconda3\envs\asim_fix_mem_use\lib\site-packages\xarray\core\variable.py", line 774, in _validate_indexers raise IndexError( IndexError: Boolean array size 1728 is used to index array with shape (96, 210). '''