首页 > 解决方案 > 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这样的数据集类?还是一种通过主上下文访问数据聚合器的方法?

标签: javarepast-simphony

解决方案


不幸的是,当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 中加载带有注释数据集的场景并进行编辑和保存,那么这并不是特别可靠,那么数据集将不再被注释掉但根本不会被写入。


推荐阅读