1

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
Jack
  • 1,131
  • 1
  • 8
  • 17

1 Answers1

3

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.

Ruben Helsloot
  • 10,555
  • 5
  • 17
  • 36
Nick Collier
  • 1,239
  • 7
  • 9
  • thanks. how to make sure batch run can recognize the newly add parameter name and the value (which is a list of hub code string). something like this: I did not see the batch_params.xml automatically updated. – Jack Jun 04 '20 at 13:40
  • The batch params will not be updated via the model. The change is internal to that particuar model run. If you want to change the batch parameters file, you’ll have to do that outside the model. There’s nothing specific to repast about this, but you could write script to iterate through your csv file and create a batch parameter file for each one. You could create batch_params template and just update the template to create each new file. Maybe this would help: https://www.stringtemplate.org – Nick Collier Jun 05 '20 at 14:02