Search code examples
javaanylogic

Is it possible to do a ParametersVariation, access values from main and store them in an excel after iteration?


I am running a number of experiments and after the simulation is over the results are stored in an excel called excelFile. At the moment I am doing one experiment after another, because if I use Parameter Variation I do not know how to get access to the measured values in the main from the Experiment ParametersVariation: Main This is what I use in the single experiment runs with an excel in the Main :

excelFile.createCell(1, t, 2);

excelFile.setCellValue(shopfloor_throughput_time.mean() ,1 , t , 2);

But I want to run 30 experiments at the same time and have the excel in the ParameterVariations environment. I don't know how to access the measured values in the Main from the ParametersVariation to write them into the excel in the ParametersVariation.

I tried this:

excelFile.createCell(1, getCurrentIteration(), 1);

excelFile.setCellValue(main.shopfloor_throughput_time.mean() ,1 ,getCurrentIteration() , 1);

in the ParametersVariation environment on After iteration.


Solution

  • You only have access to Main in the "after simulation run" code field in your Param-Var experiment. You need to use the keyword root to access Main from there.

    If you had an xls sheet "outputs" with columns "iterationNo, ReplicationNo, value", you could use code like this to store unique run results:

    int rowIndex = 0; // increase this after every round
    excelFile.setCellValue(getCurrentIteration(), "outputs", rowIndex, 0); // first column
    excelFile.setCellValue(getCurrentReplication(), "outputs", rowIndex, 1); // 2nd column
    excelFile.setCellValue(root.someValueToStore, "outputs", rowIndex, 2); // 3rd column
    rowIndex++; // for next run
    

    Likely needs some adjustments, but this is the zest