javarepast-simphony

Repast Simphony: Turn Off Data Collection in Batch Runs


We've been developing in Repast Simphony, and are now attempting to scale up simulations. The GUI has been fantastic for testing, however, we don't need those datasets for larger runs. I assume we can stop data collection by removing the data sets from the GUI, or deleting the *.xml files that define them, but that would make it difficult to switch back to small tests.

Is there a way to stop Repast data collection, given that a simulation is in batch mode? Something like -

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

Is there a data set class like RunEnvironment? Or a way to access the data aggregators through the main context?


Solution

  • Unfortunately, by the time ContextBuilder.build gets called it's too late to remove the datasets as they have already been initialized. You could remove the datasets manually from the scenario.xml For example,

    ?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>
    

    If you keep two copies - one for batch and one for GUI and swap between them (copying the appropriate one to scenario.xml) that should give you what you want. I would avoid using one file and uncommenting as necessary. That's not particularly robust given that if you load the scenario with the commented datasets in the GUI and edit and save, then the datasets are no longer commented out but not written at all.