InstituteforDiseaseModeling / laser

Light Agent Spatial modeling for ERadication
MIT License
2 stars 5 forks source link

Quickstart.ipynb - loading model error #14

Closed krosenfeld-IDM closed 3 months ago

krosenfeld-IDM commented 5 months ago

Error while initializing the model (https://github.com/InstituteforDiseaseModeling/laser/blob/jbloedow/end_of_may_wip/jb/QuickStart.ipynb)

ctx = model.initialize_database() # should really be called "load model"
ctx = model.eula_init( ctx, demographics_settings.eula_age )
csv_writer = report.init()

Error:

---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
Cell In[2], [line 1](vscode-notebook-cell:?execution_count=2&line=1)
----> [1](vscode-notebook-cell:?execution_count=2&line=1) ctx = model.initialize_database() # should really be called "load model"
      [2](vscode-notebook-cell:?execution_count=2&line=2) ctx = model.eula_init( ctx, demographics_settings.eula_age )
      [3](vscode-notebook-cell:?execution_count=2&line=3) csv_writer = report.init()

File ~/projects/laser/jb/sandbox/sir_numpy_c.py:231, in initialize_database()
    [230](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:230) def initialize_database():
--> [231](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:231)     return load( demographics_settings.pop_file )

File ~/projects/laser/jb/sandbox/sir_numpy_c.py:180, in load(pop_file)
    [178](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:178) unborn = {header: [] for i, header in enumerate(headers)}
    [179](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:179) global unborn_end_idx 
--> [180](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:180) sir_numpy.add_expansion_slots( unborn, num_slots=settings.expansion_slots )
    [181](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:181) unborn_end_idx = int(settings.expansion_slots)
    [183](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:183) data = {header: data[:, i] for i, header in enumerate(headers)}

File ~/projects/laser/jb/sandbox/sir_numpy.py:78, in add_expansion_slots(columns, num_slots)
     [76](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:76) print( f"Adding {num_slots} expansion slots for future babies." )
     [77](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:77) new_ids = [ x for x in range( num_slots ) ]
---> [78](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:78) new_nodes = np.ones( num_slots, dtype=np.uint32 )*-1
     [79](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:79) new_ages = np.ones( num_slots, dtype=np.float32 )*-1
     [80](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:80) new_infected = np.zeros( num_slots, dtype=bool )

OverflowError: Python integer -1 out of bounds for uint32

Machine RAM: MemTotal: 16371640 kB

krosenfeld-IDM commented 5 months ago

I think this has to do with using the np.uint32 here: https://github.com/InstituteforDiseaseModeling/laser/blob/b066650a4e5a1cd4a76635dadd95056e809df3c4/jb/src/sir_numpy.py#L78

jonathanhhb commented 5 months ago

There are a bunch of associated changes that should probably go along with this fix. They are present in jb_modulify branch, which is also installable as idmlaser==0.0.1.

krosenfeld-IDM commented 5 months ago

ok, that's helpful to know. It makes the most sense to me to have both @KevinMcCarthyAtIDM and myself working off of the same branch (or as close as possible) for this loop. I don't plan to change branches at this point.