java - Repast Simphony:关闭批处理运行中的数据收集
问题描述
我们一直在 Repast Simphony 中进行开发,现在正在尝试扩大模拟规模。GUI 非常适合测试,但是,我们不需要这些数据集来进行更大规模的运行。我假设我们可以通过从 GUI 中删除数据集或删除定义它们的 *.xml 文件来停止数据收集,但这会使切换回小型测试变得困难。
鉴于模拟处于批处理模式,有没有办法停止 Repast 数据收集?就像是 -
public class myBuilder implements ContextBuilder<Object> {
@Override
public Context build(Context<Object> context) {
// some very intelligent code
// with excellent commenting
if(RunEnvironment.getInstance().isBatch()) {
// what can I put here?
// something like this?
AbstractDataSetManager.getInstance.clearDataSets();
}
} // end build()
}// end myBuilder class
是否有像RunEnvironment这样的数据集类?还是一种通过主上下文访问数据聚合器的方法?
解决方案
不幸的是,当ContextBuilder.build
被调用时,删除数据集为时已晚,因为它们已经被初始化。您可以从scenario.xml 中手动删除数据集例如,
?xml version="1.0" encoding="UTF-8" ?>
<Scenario simphonyVersion="2.8.0">
<repast.simphony.dataLoader.engine.ClassNameDataLoaderAction context="jzombies" file="repast.simphony.dataLoader.engine.ClassNameDataLoaderAction_0.xml" />
<!--
<repast.simphony.action.data_set context="jzombies" file="repast.simphony.action.data_set_1.xml" />
<repast.simphony.action.data_set context="jzombies" file="repast.simphony.action.data_set_2.xml" />
<repast.simphony.action.data_set context="jzombies" file="repast.simphony.action.data_set_3.xml" />
-->
<repast.simphony.action.time_series_chart context="jzombies" file="repast.simphony.action.time_series_chart_10.xml" />
<repast.simphony.action.histogram_chart context="jzombies" file="repast.simphony.action.histogram_chart_11.xml" />
<repast.simphony.action.histogram_chart context="jzombies" file="repast.simphony.action.histogram_chart_12.xml" />
<repast.simphony.action.display context="jzombies" file="repast.simphony.action.display_13.xml" />
<repast.simphony.action.display context="jzombies" file="repast.simphony.action.display_14.xml" />
<repast.simphony.action.display context="jzombies" file="repast.simphony.action.display_15.xml" />
<repast.simphony.action.display context="jzombies" file="repast.simphony.action.display_16.xml" />
<repast.simphony.action.display context="jzombies" file="repast.simphony.action.display_17.xml" />
</Scenario>
如果您保留两份副本 - 一份用于批处理,一份用于 GUI,并在它们之间进行交换(将适当的一份复制到scenario.xml
),这应该可以满足您的需求。我会避免使用一个文件并根据需要取消注释。考虑到如果您在 GUI 中加载带有注释数据集的场景并进行编辑和保存,那么这并不是特别可靠,那么数据集将不再被注释掉但根本不会被写入。
推荐阅读
- javascript - setTimeout / Promise.resolve:宏任务与微任务
- reactjs - JSX 在 React 中的 .map 之后不渲染
- python - 如何让对象从画布边框反弹?
- swift - Ping 多个主机并根据响应创建单独的 UIImageView
- math - 两个数字的 gcd 其中一个太大
- mysql - MySQL:为什么 IN 子句中的第 5 个 ID 极大地改变了查询计划?
- c# - 按列标题排序单击删除列过滤器
- python - 熊猫csv数据框中两点之间的距离
- vba - 我的双参数 vlookup 函数 (VBA) 跳过了我的数据范围的第一行
- excel - 用于复制多个单元格并粘贴到另一个工作表的 Vba 代码