HSLdevcom / helmet-model-system

European Union Public License 1.2
10 stars 3 forks source link

Agent-based model crashes due to index error #513

Closed hsl-petrhaj closed 1 year ago

hsl-petrhaj commented 1 year ago

2023-05-10 16:03:13 [INFO] Assigning mode and destination for 1334423 agents (100 % of total population) 2023-05-10 16:07:55 [ERROR] Exception at iteration 1 Traceback (most recent call last): File "C:/Users/HajduPe/Documents/helmet-model-system/Scripts/helmet.py", line 104, in main else model.run_iteration(impedance, i)) File "C:\Users\HajduPe\Documents\helmet-model-system\Scripts\modelsystem.py", line 257, in run_iteration self._add_internal_demand(previous_iter_impedance, iteration=="last") File "C:\Users\HajduPe\Documents\helmet-model-system\Scripts\modelsystem.py", line 571, in _add_internal_demand tour.choose_destination(sec_dest_tours) File "C:\Users\HajduPe\Documents\helmet-model-system\Scripts\datatypes\tour.py", line 152, in choose_destination self.purpose.attracted_tours[self.mode][dest_idx] += 1 IndexError: index 1977 is out of bounds for axis 0 with size 1977 2023-05-10 16:07:55 [ERROR] Fatal error occured, simulation aborted.

Forcing dest_idx to be under 1977 fixes the situation, but we need some more thorough investigation of why this happens.

@zptro @johpiip

zptro commented 1 year ago

I think I was not entirely right when I said in #495 that numpy.searchsorted() does not require float64 matrices. But I think I have a solution to this.

hsl-petrhaj commented 1 year ago

Thanks for investigating this.