Saving and loading a grid

38 views
Skip to first unread message

Romain Mejean

unread,
Mar 23, 2020, 5:14:51 AM3/23/20
to GAMA
Hi everyone,

I created a heavy model, whose initialization requires a lot of computations... so I had the idea to create a kind of "init generator" that allows to save the agents generated in init with all their attributes and then to load them directly from the saved files for the next simulations (so that I don't have to do the heavy computations each time).

For most agents: no problem, they are saved in shapefiles and easily loaded with their attributes. But for the grid, it's problematic: in which format can I save the grid to keep all its attributes? I tried the shapefile... it works to save but then, it is impossible to recreate (load) it from this one. So I'm trying to save a grid with several attributes (not just the grid_value) and then re-open it from this save... Does anyone have an idea? 

Maybe there is a solution with the save_simulation & saved_simulation_file commands but I don't know how to use them. Thank you in advance for your help.

Greetings,
Romain Mejean

Kevin Chapuis

unread,
Mar 23, 2020, 5:40:37 AM3/23/20
to gama-p...@googlegroups.com
Hi Romain,
In my opinion,  the simplest way would be to save your attributes in a csv, let's say in a list, file using coordinate to re-assigne attribute value to the cells. It would require few loops within your init to go through the csv and give attributes to the cells. To parse csv content you should use split_with to have individual attribute value.
Best,
Kevin

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/40be73d3-78de-499e-8f49-736a11477026%40googlegroups.com.


--
Chapuis kevin
Post-Doc / Research Fellow
IRD, UMI 209 UMMISCO / UMR 228 ESPACE-DEV

Romain Mejean

unread,
Mar 23, 2020, 10:27:09 AM3/23/20
to GAMA
Hi Kevin,

Thank you for your answer. I will try to proceed as you advise.

Best,
Romain


Le lundi 23 mars 2020 10:40:37 UTC+1, Kevin Chapuis a écrit :
Hi Romain,
In my opinion,  the simplest way would be to save your attributes in a csv, let's say in a list, file using coordinate to re-assigne attribute value to the cells. It would require few loops within your init to go through the csv and give attributes to the cells. To parse csv content you should use split_with to have individual attribute value.
Best,
Kevin

Le lun. 23 mars 2020 à 10:14, Romain Mejean <nae...@gmail.com> a écrit :
Hi everyone,

I created a heavy model, whose initialization requires a lot of computations... so I had the idea to create a kind of "init generator" that allows to save the agents generated in init with all their attributes and then to load them directly from the saved files for the next simulations (so that I don't have to do the heavy computations each time).

For most agents: no problem, they are saved in shapefiles and easily loaded with their attributes. But for the grid, it's problematic: in which format can I save the grid to keep all its attributes? I tried the shapefile... it works to save but then, it is impossible to recreate (load) it from this one. So I'm trying to save a grid with several attributes (not just the grid_value) and then re-open it from this save... Does anyone have an idea? 

Maybe there is a solution with the save_simulation & saved_simulation_file commands but I don't know how to use them. Thank you in advance for your help.

Greetings,
Romain Mejean

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-p...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages