有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

是否有类似于运行环境的数据集类? 还是通过主上下文访问数据聚合器的方法


共 (1) 个答案

  1. # 1 楼答案

    不幸的是,在调用ContextBuilder.build时,删除数据集已经太晚了,因为它们已经初始化。您可以从场景中手动删除数据集。例如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中加载带有注释的数据集的场景并进行编辑和保存,那么这些数据集就不再被注释掉,而根本就不会被写入,因此这并不特别健壮