0

I am currently doing a parameter variation experiment. I want to display a progress bar of the each simulation (similar to the animation provided by anylogic "progress of parallel runs"), which would be calculated as number of days elapsed in the root (simulation) over total days that will be simulated. I cannot access that information as I only get the option to code before and after simulation run, but not in between (and events are not an option). How can I manually program this?

Thanks in advance, FM

Note: I want the progress bar of EACH simulation, not the general progress of the experiment.

1 Answers1

0

Compute the value within the model using:

double totalDays = getEngine().getStopTime(DAY) - getEngine().getStartTime(DAY);
double progressSoFar = time(DAY) / totalDays; // ratio between 0 and 1

Put that in a function getProgress returning progressSoFar on Main.

Now have a regular event on Main that "pushes" the value up to the experiment. This can be done using typecasting:

if (getExperiment() instanceof ParameterVariation) {
    ((ParameterVariation)getExperiment()).myText.setText(getProgress());
}

For this, you need a text element on your experiment named myText. Ideally, make this replicated to the number of runs you have, put them below each other and access them from the model using its getIteration(). Then, each iteration will update its own text element.

Benjamin
  • 10,603
  • 3
  • 16
  • 28