Greetings,
Is there any feasible way to fast forwarding the simulation with time scale i.e. x512 and then returning back to i.e.
x1 time scale when the given time i.e. (simulation time) 12.12.2007 02.00 AM?
I tried to use a button to move 1 hours a bit more speedy:
double t = getTime();
getEngine().setRealTimeScale(512);
while (getTime() - t < 3600); //wait to reach expected hour
However simulation window freezes. Is there something I'm missing?
Thank you.
Maxim G — 03.05.08
Hi! AnyLogic model is single threaded. This means that the simulation engine jumps from one event to another executing
its actions. Therefore if an event freezes (e.g. in an infinite loop) then the whole simulation freezes. There is an
infinite loop in your case (the one with time condition) because engine could not advance time without finishing the
event code. And the event code cannot be finished because time is the same.
I would do this:
1. change time scale
2. create a dynamic event (create_MyDynamicEvent( 3600 ) )
where MyDynamicEvent is an event with code changing time scale back to 1.
Please let me know if it helps!
Dinçer Kavraal — 04.05.08
Hi Maxim,
I hoped there would be another possible way to achieve the solution. Because, then, I would probably have to recreate
the whole world just to fast forward with a dynamic event (which is my whole experiment, in this case) ?
Regards,
Maxim G — 07.05.08
Hi! Dynamic Event is an element of a model, you don't need to recreate the whole model. The DE is one of the simplest
ways to generate events (e.g. speedup at model time 3600 or slowdown at time 5600). Technically there are two types of
events: event and dynamic event. The difference between the event and the dynamic event is that the dynamic event
deletes itself after its action is executed. Dynamic events are used to schedule any number of concurrent and
independent events. To create new dynamic event instance, use the method that is generated automatically by AnyLogic for
every dynamic event declared on the active object diagram (e.g. create_MySpeedupEvent( 3600 ) ).
Regards, Max
Dinçer Kavraal — 26.06.08
Thank you. I have tried to add two events. One of them is speeding up and other one is slowing down back to original
speed of the simulation. I call the speeding event and when I am done (perfectly it could be called inside the speed up
function) I call the slowing back to original speed event.
Eventually it totally fit my needs.
Thank you.