问题
I have a *.shp file that I've upload and i'm using as part of my model (calculating shortest paths). This is quite a big shape file with thousands of road links and intersections and bridges represented by nodes. I was hoping to speed up the running of behavior space by not loading this map every time, and so created a separate procedure for loading the map and defining link weights etc. In this procedure I have clear-all - reset ticks so everything is effectively wiped if i load a new map. In the setup i define turtle attributes for each run. Between each run I use clear-all-plots and clear-output, and reset-ticks. When i run this model behavior space starts to run slowly after a few setups, even with a table output. However, if i combine the load-map and setup-files together i.e. the map is load for every new behavior space run, then the speed is maintained throughout.
Example - runs slow, but the maps is not reloaded everytime
to-load-map
Clear-all
... code for loading map
reset-ticks
end
to-setup-model
clear-all-plots
clear-outputs
... code for setting up turtle variables
reset-ticks
end
Example (maintains speed - but has to load map)
To-setup
clear-all
...code for loading map
...code for setting up turtle variables
reset-ticks
end
My question: am i missing something that would help to speed things up while not having to reload the map?
回答1:
Not knowing anything else about your model, I wonder if you essentially have a "memory leak" with lots of information accumulating in global variables that are not getting purged every time by the to-setup-model
procedure. Are there perhaps other global variables you can explicitly reinitialize in to-setup-model
that might help free up some of this space? For instance, do you have large tables hanging around between runs that only gain more key-value pairs and never get trimmed back down? Just a thought.
I almost always define a clear-most
procedure that clears everything out except the big data I don't want to load/compute every time. Unfortunately, that means I must list the variables to initialize out in detail, but I like to free as much as possible between runs to keep things speedy.
-- Glenn
来源:https://stackoverflow.com/questions/24521206/keeping-maps-between-behaviorspace-runs