Keeping maps between BehaviorSpace runs

你离开我真会死。 提交于 2020-01-25 00:07:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!