在 BehaviorSpace 运行之间保持映射 [英] Keeping maps between BehaviorSpace runs
问题描述
我有一个已上传的 *.shp 文件,我将其用作模型的一部分(计算最短路径).这是一个相当大的形状文件,包含数以千计的道路链接以及由节点表示的交叉路口和桥梁.我希望通过不每次都加载此地图来加速行为空间的运行,因此创建了一个单独的程序来加载地图和定义链接权重等.在此程序中,我清除了所有 - 重置刻度,因此一切都有效如果我加载新地图,则擦除.在设置中,我为每次运行定义了海龟属性.在每次运行之间,我使用 clear-all-plots 和 clear-output 以及 reset-ticks.当我运行这个模型行为空间在几次设置后开始缓慢运行,即使有一个表输出.但是,如果我将加载映射和设置文件组合在一起,即每个新行为空间运行加载映射,那么速度将始终保持不变.
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?
推荐答案
对您的模型一无所知,我想知道您是否本质上存在内存泄漏",在全局变量中积累了大量信息,而这些信息并不是每次都被清除时间由 to-setup-model
程序决定.是否还有其他全局变量可以在 to-setup-model
中显式地重新初始化,这可能有助于释放一些空间?例如,您是否有大表在运行之间闲置,这些表只会获得更多的键值对而永远不会被削减?只是一个想法.
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.
我几乎总是定义一个 clear-most
过程,它清除除我不想每次加载/计算的大数据之外的所有内容.不幸的是,这意味着我必须详细列出要初始化的变量,但我喜欢在运行之间尽可能多地释放以保持速度.-- 格伦
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
这篇关于在 BehaviorSpace 运行之间保持映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!