repast-simphony

Repast: how to add and set a new parameter directly from the code instead of GUI


I want to create a parameter that contains a list of string (list of hub codes). This list of string is created by reading an external csv file (this list could contain the different codes depending on the hub codes in the CSV file)

What I want is to find a easy auto way to perform batch runs by each hub code in the list.

So this question is:

1) how to add and set a new parameter directly from the code (during the initialization when reading the CSV) instead of GUI parameter panel? 
2) how to avoid manual configuration of hub list in the batch run configuration

Solution

  • Something like this for adding the parameters should work in your ContextBuilder.

    Parameters params = RunEnvironment.getInstance().getParameters();
    ((DefaultParameters)params).addParameter("foo", "Big Foo", Integer.class, 3, false);
    

    You would read the csv file to get the parameter name and value.

    I'm not sure I completely understand the batch run configuration question, but each batch run has a run number associated with it

    RunState.getInstance().getRunInfo().getRunNumber()
    

    If you can associate line numbers in your csv parameter file with run number (e.g. run number 1 should use line 1, and so on), then each batch run would use a different parameter line.