AnyLogic Execution with Jar files - Run Fastest Sp

2019-08-31 14:07发布

问题:

I am recently developing software with AnyLogic and I have a question about how to run with the fastest speed from outside.

My current code for running a simulation is like this.

package defaultpackage;

import com.anylogic.engine.Experiment;

import agvver1.*;

public class MyClass{
	public static void main(String[] args) {
		Simulation thisSim = new Simulation();
		thisSim.run();
		Experiment.State ThisState = thisSim.getState();
		while(!ThisState.equals(Experiment.State.FINISHED)) {
			try
			{
			    Thread.sleep(1000);
			}
			catch(InterruptedException ex)
			{
			    Thread.currentThread().interrupt();
			}
			ThisState = thisSim.getState();
		}
		
		System.out.println(Main.totalTardy);
	}
}

It is not so efficient but it can produce outputs very slowly.

How can I run it with the fastest speed as I did it in AnyLogic at virtual speed? I found ExperiemntRunFast class but I have no idea how to use it.

Thanks in advance and have a wonderful day!

[Update] I tried runFast but it still doesn't work. Please see attached.

enter image description here

回答1:

Instead of

thisSim.run();

try

thisSim.runFast();

Should do the trick :-)