AnyLogic
Expand
Font size

Class Engine

All Implemented Interfaces:
Serializable

public final class Engine
extends Object
implements Serializable
The simulation engine that drives the model execution. The engine maintains the event queue, the default random number generator, etc. Although there is one engine per simulation, it is designed to have no static data, so there may exist several concurrent simulations in one JVM, in particular, one simulation can invoke the other, etc.
The engine behavior and usage patterns are best described with a statechart with states IDLE, PAUSED, RUNNING, FINISHED, ERROR, PLEASE_WAIT. The normal usage pattern of the engine controlled by the Presentation GUI is like this:
Engine engine = new Engine(); // -> IDLE; random number generator is initialized
Agent root = new RootAgent( engine, null, null );
...//setup parameters of root
engine.start( root ); // -> PAUSED
engine.run(); // -> RUNNING; launches execution in a new thread, calls the experiment back on finish
...
engine.pause(); // -> PAUSED
engine.step(); // -> PAUSED
engine.run(); // -> RUNNING
...
engine.stop(); // -> IDLE completely destroys the model
...
Agent root2 = new RootAgent2( engine, null, null );
...etc.
The engine state PLEASE_WAIT means the engine is executing a non-interruptible single command, such as pause(), step(), or stop(). If you do not need multithreading and wish to run the model as fast as possible (i.e. in virtual time mode only) in the controlling thread, you may call runFast() instead of run(). runFast() ignores any synchronization, therefore you should not access the model data (e.g. call drawing of agents) concurrently with runFast().
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Nested Class Summary

Modifier and TypeClassDescription
static enum Engine.EventSelectionMode
Simultaneous event selection mode constants
static enum Engine.ModelType
The type of the model, returned by Engine.
static enum Engine.SolverDAEType
The solver type for mixed differential-algebraic equations
static enum Engine.SolverNAEType
The solver type for algebraic equations
static enum Engine.SolverODEType
The solver type for ordinary differential equations
static enum Engine.State
The state of the Engine

Field Summary

Modifier and TypeFieldDescription
static final Engine.StateERROR 
static final Engine.EventSelectionModeEVENT_SELECTION_DETERMINISTIC
Deprecated.
static final Engine.EventSelectionModeEVENT_SELECTION_FIFO
Deterministic selection mode (first in - first out) constant for setSimultaneousEventsSelectionMode(EventSelectionMode)
Offers good performance, simultaneous events are executed in the same order they were scheduled.
This is the default mode used by engine
static final Engine.EventSelectionModeEVENT_SELECTION_LIFO
Deterministic selection mode (last in - first out) constant for setSimultaneousEventsSelectionMode(EventSelectionMode)
Offers good performance, simultaneous events are executed in the reverse to the order they were scheduled
static final Engine.EventSelectionModeEVENT_SELECTION_RANDOM
Random selection mode constant for setSimultaneousEventsSelectionMode(EventSelectionMode)
This mode is slower than EVENT_SELECTION_FIFO or EVENT_SELECTION_LIFO
This mode utilises the default random number generator of the Engine.
static final Engine.StateFINISHED 
static final Engine.StateIDLE 
static final Engine.ModelTypeMODEL_TYPE_CONTINUOUS 
static final Engine.ModelTypeMODEL_TYPE_DISCRETE 
static final Engine.ModelTypeMODEL_TYPE_HYBRID 
static final Engine.ModelTypeMODEL_TYPE_UNKNOWN 
static final Engine.StatePAUSED 
static final Engine.StatePLEASE_WAIT 
static final Engine.StateRUNNING 
static final Engine.SolverDAETypeSOLVER_DAE_EULER_NEWTON 
static final Engine.SolverDAETypeSOLVER_DAE_RK45_NEWTON 
static final Engine.SolverNAETypeSOLVER_NAE_CLASSIC_NEWTON 
static final Engine.SolverNAETypeSOLVER_NAE_FAST_NEWTON 
static final Engine.SolverNAETypeSOLVER_NAE_MODIFIED_NEWTON 
static final Engine.SolverODETypeSOLVER_ODE_EULER 
static final Engine.SolverODETypeSOLVER_ODE_RK4 

Constructor Summary

ConstructorDescription
Engine()
Constructs the engine and sets the seed of the default random number generator to 0.
Normally this constructor calls are generated automatically by AnyLogic.

For AnyLogic Professional users: in custom experiments please use ExperimentCustom.createEngine() method instead of this constructor to create and obtain new instance of the engine

Method Summary

Modifier and TypeMethodDescription
Datedate()
Returns the current model date with respect to the start time/date and the model time unit.
longdateInMillis()
Returns the current model date milliseconds with respect to the start time/date and the model time unit.
doubledateToTime(Date d)
Converts the given date to model time with respect to the start date, start time and model time unit settings
voiddisableWarning(String warningType)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
RuntimeExceptionerror(String errorText)
Signals an error during the model run by throwing a RuntineException with the given text.
RuntimeExceptionerror(Throwable cause, String errorText)
Signals an error during the model run by throwing a RuntineException with the given text.
RuntimeExceptionerrorInModel(String errorText)
Signals an model logic error during the model run by throwing a ModelException with the given text.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments.
RuntimeExceptionerrorInModel(Throwable cause, String errorText)
Signals an model logic error during the model run by throwing a ModelException with the given text.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments.
booleanfinish()
Terminates the model after execution of current event.
voidflushSnapshotCache()
Clears cache with contents of recently loaded snapshot file
NB: cache is automatically cleared on new snapshot loading
intgetAmPm()
Indicates whether the hour of the current model date with respect to the start time/date and the model time unit is before (AM) or after (Utilities.PM) noon.
This method is used for the 12-hour clock.
E.g., at 10:04:15.250 PM the result is Utilities.PM.
doublegetATOL()
Returns absolute tolerance of the numeric engine.
DategetDate()
Deprecated.
Use date() instead
intgetDayOfMonth()
Returns the day of the month of the current model date with respect to the start time/date and the model time unit.
The first day of the month has value 1.
intgetDayOfWeek()
Returns the day of the week of the current model date with respect to the start time/date and the model time unit.
Returned value is one of: Utilities.SUNDAY Utilities.MONDAY Utilities.TUESDAY Utilities.WEDNESDAY Utilities.THURSDAY Utilities.FRIDAY Utilities.SATURDAY
intgetDayOfYear()
Returns the day of the year of the current model date with respect to the start time/date and the model time unit.
The first day of the year has value 1.
RandomgetDefaultRandomGenerator()
Returns the currently used default random number generator.
longgetEventCount()
Returns the number of currently scheduled events.
Experiment<?>getExperiment()
Returns the experiment controlling the model execution.
This method isn't designed for AnyLogic Cloud, also returns null for custom experiments
ExperimentCustomgetExperimentCustom()
Returns the custom experiment controlling the model execution.
Returns null for other types of experiments
IExperimentHostgetExperimentHost()
Returns the experiment host object associated with this engine, or some dummy object with no functionality if there is none.
intgetHour()
Returns the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit.
This method is used for the 12-hour clock.
Noon and midnight are represented by 0, not by 12.
E.g., at 10:04:15.250 PM the result is 10.
intgetHourOfDay()
Returns the hour of day of the current model date with respect to the start time/date and the model time unit.
This method is used for the 24-hour clock.
E.g., at 10:04:15.250 PM the result is 22.
doublegetHTOL()
Returns fixed step of the numeric engine.
intgetMillisecond()
Returns the millisecond within the second of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 250.
intgetMinute()
Returns the minute within the hour of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 4.
ModelDatabasegetModelDatabase()
Returns the the database of this model
ModelPropertiesgetModelProperties()
Returns the model properties of this model
Engine.ModelTypegetModelType()
Returns the type of model being executed:
MODEL_TYPE_UNKNOWN - the model is either empty or it is too early to judge
MODEL_TYPE_DISCRETE - the model so far had at least one discrete event and no equations
MODEL_TYPE_CONTINUOUS - the model so far had at equation and no discrete events
MODEL_TYPE_HYBRID the model had both events and equations
intgetMonth()
Returns the month of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value.
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.
Possible values: Utilities.JANUARY Utilities.FEBRUARY Utilities.MARCH Utilities.APRIL Utilities.MAY Utilities.JUNE Utilities.JULY Utilities.AUGUST Utilities.SEPTEMBER Utilities.OCTOBER Utilities.NOVEMBER Utilities.DECEMBER Utilities.UNDECIMBER (indicates the thirteenth month of the year.
doublegetNextEventTime()
Returns the time of the earliest event scheduled so far.
doublegetNextStepTime()
Returns the time which will be after the next step() execution If the model is about to finish, returns -infinity.
Special cases: in system-dynamics models the result may depend on the selected accuracy in system-dynamics models some conditional events may occur based on the value obtained from numerical solver within the step.
IExperimentHostgetPresentation()
Deprecated.
this method will be removed in the next releases.
doublegetProgress()
Returns the progress of the simulation: the part of model time simulated so far in case the stop time is set, or -1 if it is not set.
booleangetRealTimeMode()
Returns true if the current execution mode is real time, false if virtual time.
doublegetRealTimeScale()
Returns the currently set real time scale of model execution, i.e.
AgentgetRoot()
Returns the top-level agent setup for the engine (the topmost level agent from which the model creation and execution starts).
doublegetRTOL()
Returns relative tolerance of the numeric engine.
intgetRunCount()
Returns the number of the current simulation run, more precisely the number of times the model was destroyed.
longgetRunTimeMillis()
Returns the real duration of the simulation run in milliseconds, excluding pause times.
intgetSecond()
Returns the second within the minute of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 15.
Engine.SolverDAETypegetSolverDAE()
Returns solver type for mixed differential-algebraic equations
Engine.SolverNAETypegetSolverNAE()
Returns solver type for algebraic equations
Engine.SolverODETypegetSolverODE()
Returns solver type for ordinary differential equations
DategetStartDate()
Returns the date corresponding to the start time of the simulation.
doublegetStartTime()
Returns the currently set start time - the model time at which the simulation starts, by default it is 0.
doublegetStartTime(TimeUnits units)
Returns the currently set start time - the model time at which the simulation starts, by default it is 0.
longgetStartTimeMillis()
Returns the result of a call to System.currentTimeMillis() at the simulation start.
Engine.StategetState()
Returns the current state of the engine:
IDLE - no model is set for execution, doing nothing
PAUSED - model is set and have started, ready to run or make a step
RUNNING - in the loop of model execution invoked by run() or runFast()
FINISHED - the model execution is finished OK, but the model is not yet destroyed
ERROR - the model execution is finished with error, the model is not yet destroyed
PLEASE_WAIT - in the process of executing a non-interruptible command like pause(), step() or stop()
The state is however not guaranteed as may be modified concurrently.
longgetStep()
Returns the number of events executed by the engine.
DategetStopDate()
Returns the date corresponding to the stop time, null if the stop time is infinity.
doublegetStopTime()
Returns the currently set stop time - the model time at which the simulation should stop, or +infinity if stop time is not set.
doublegetStopTime(TimeUnits units)
Returns the currently set stop time - the model time at which the simulation should stop, or +infinity if stop time is not set.
doublegetTime()
Deprecated.
Use time() instead.
TimeUnitsgetTimeUnit()
Returns the real time units currently set as the model time units.
doublegetTTOL()
Returns time tolerance of the numeric engine.
final NumbergetVMethods() 
intgetYear()
Returns the year of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value
voidinterruptRunFast(Runnable callback)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
booleanisCalendarDateUsed()
Returns true if calendar dates (e.g.
static booleanisDebugging()
Returns true if the model is started in the debug mode from AnyLogic
booleanisEventAwareSolver()
Returns the current setting used by System Dynamics solver in the models having both System Dynamics equations and Discrete Event parts.
booleanisPackage3DResourcesLocatedinJar(String packagePrefix)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
booleanisRealTimeMaintained()
This method is not designed to be called by user
is public due to technical reasons
booleanisStopping()
Deprecated.
booleanisTestExperiment()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
AgentloadRootObjectFromSnapshot(String snapshotFileName)
Loads and sets top-level agent from the given snapshot with caching contents of snapshot file (for performance speed-up)
This method supports loading from snapshots created with any experiment with animation (i.e.
AgentloadRootObjectFromSnapshot(String snapshotFileName, boolean cacheSnapshot)
Loads and sets top-level agent from the given snapshot with optional caching contents of snapshot file (for performance speed-up)
This method supports loading from snapshots created with any experiment with animation (i.e.
booleanpause()
Engine command applicable only in RUNNING state (in other states does nothing and returns false).
voidregisterAgentWithEquations(Agent ao)
Registers given agent with equations in Engine equations solver.
voidregisterDelay(VariableDelay variableDelay)
Registers given delay in Engine equations solver.
voidresetBeforeStart()
This method should be called from custom experiments which use logging to database.
Resets state variables which may be accessed by root parameters setup before start(Agent) is called.
This method does nothing if state isn't IDLE
booleanrun()
Engine command applicable only in PAUSED state (in other states does nothing and returns false).
booleanrunFast()
Runs the model in the fastest possible way in the same (calling) thread.
booleanrunFast(double pauseTime)
Calls runFast() but pauses the model execution at the specified model time and returns true
If the model finishes (because of stop time or finish() method called) before the pauseTime, the method runs the model until the finish moment only.
voidrunFastInterruptible(double pauseTime)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidsaveRootObjectSnapshot(String snapshotFileName)
Saves top-level agent and current state of this Engine to a snapshot file with the given name.
voidsetATOL(double atol)
Sets the absolute tolerance of the numeric engine.
voidsetDefaultRandomGenerator(Random r)
Changes the default random number generator.
voidsetEventAwareSolver(boolean eventAwareSolver)
This setting is actual for models having both System Dynamics equations and Discrete Event parts.
voidsetExperiment(Experiment<?> ex)
Sets the experiment that will be controlling the model execution.
voidsetExperimentHost(IExperimentHost h)
Sets the object that will be host the model execution (animation and controls).
voidsetHTOL(double htol)
Sets the fixed step of the numeric engine.
voidsetPresentation(IExperimentHost p)
Deprecated.
this method will be removed in the next releases.
voidsetRealTimeMode(boolean on)
Sets the virtual or real time execution mode.
voidsetRealTimeScale(double scale)
Sets the desired real time scale of model execution, i.e.
voidsetRTOL(double rtol)
Sets the relative tolerance of the numeric engine.
voidsetSimultaneousEventsSelectionMode(Engine.EventSelectionMode mode)
Sets the mode of event selection among simultaneous events (if any occur).
voidsetSolverDAE(Engine.SolverDAEType solverDAE)
Sets solver type for mixed differential-algebraic equations
Available solvers: SOLVER_DAE_RK45_NEWTON (default) SOLVER_DAE_EULER_NEWTON
voidsetSolverNAE(Engine.SolverNAEType solverNAE)
Sets solver type for algebraic equations
Available solvers: SOLVER_NAE_MODIFIED_NEWTON (default) SOLVER_NAE_FAST_NEWTON SOLVER_NAE_CLASSIC_NEWTON
voidsetSolverODE(Engine.SolverODEType solverODE)
Sets solver type for ordinary differential equations
Available solvers: SOLVER_ODE_EULER (default) SOLVER_ODE_RK4
voidsetStartDate(Date date)
Sets the date corresponding to the start time of the simulation.
voidsetStartTime(double tstart)
Sets the start time for the simulation - the initial value of the model clock.
voidsetStartTime(double tstart, TimeUnits units)
Sets the start time for the simulation - the initial value of the model clock.
voidsetStopDate(Date date)
Sets the stop time of the simulation by converting the stop date provided to the model time, subject to the start time, start date and time unit settings.
voidsetStopTime(double tstop)
Sets the stop time for the simulation.
voidsetStopTime(double tstop, TimeUnits units)
Sets the stop time for the simulation.
voidsetTimeUnit(TimeUnits tu)
Sets the correspondence between the model time unit and a real time unit.
voidsetTTOL(double ttol)
Sets the time tolerance of the numeric engine.
final voidsetVMethods(Number n) 
booleanstart(Agent root)
Engine command applicable only in IDLE state (in other states does nothing and returns false).
booleanstep()
Makes at most one discrete step of the model (can be done from the PAUSED state only).
booleanstop()
Stops and destroys the model, see also finish() method, which doesn't destroy the model.

Engine command applicable only in any non-IDLE state (in IDLE state does nothing and returns false).
doubletime()
Returns the current model (logical) time.
doubletime(TimeUnits units)
Returns the current model (logical) time.
DatetimeToDate(double t)
Converts the given model time to date with respect to the start date, start time and model time unit settings, null if the time is infinity.
longtimeToDateInMillis(double time)
Returns the model date milliseconds with respect to the start time/date and the model time unit for the given model time
booleanunregisterAgentWithEquations(Agent ao)
Unregisters the agent from the engine equations solver.
voidunregisterDelay(VariableDelay variableDelay)
Unregisters the delay from the engine equations solver.

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

MODEL_TYPE_UNKNOWN

public static final Engine.ModelType MODEL_TYPE_UNKNOWN

MODEL_TYPE_DISCRETE

public static final Engine.ModelType MODEL_TYPE_DISCRETE

MODEL_TYPE_CONTINUOUS

public static final Engine.ModelType MODEL_TYPE_CONTINUOUS

MODEL_TYPE_HYBRID

public static final Engine.ModelType MODEL_TYPE_HYBRID

EVENT_SELECTION_LIFO

public static final Engine.EventSelectionMode EVENT_SELECTION_LIFO
Deterministic selection mode (last in - first out) constant for setSimultaneousEventsSelectionMode(EventSelectionMode)
Offers good performance, simultaneous events are executed in the reverse to the order they were scheduled

EVENT_SELECTION_FIFO

public static final Engine.EventSelectionMode EVENT_SELECTION_FIFO
Deterministic selection mode (first in - first out) constant for setSimultaneousEventsSelectionMode(EventSelectionMode)
Offers good performance, simultaneous events are executed in the same order they were scheduled.
This is the default mode used by engine

EVENT_SELECTION_DETERMINISTIC

@Deprecated
public static final Engine.EventSelectionMode EVENT_SELECTION_DETERMINISTIC
Deprecated.
Deterministic selection mode constant for setSimultaneousEventsSelectionMode(EventSelectionMode)
Offers good performance

EVENT_SELECTION_RANDOM

public static final Engine.EventSelectionMode EVENT_SELECTION_RANDOM
Random selection mode constant for setSimultaneousEventsSelectionMode(EventSelectionMode)
This mode is slower than EVENT_SELECTION_FIFO or EVENT_SELECTION_LIFO
This mode utilises the default random number generator of the Engine.

IDLE

public static final Engine.State IDLE

PAUSED

public static final Engine.State PAUSED

RUNNING

public static final Engine.State RUNNING

FINISHED

public static final Engine.State FINISHED

ERROR

public static final Engine.State ERROR

PLEASE_WAIT

public static final Engine.State PLEASE_WAIT

SOLVER_ODE_EULER

public static final Engine.SolverODEType SOLVER_ODE_EULER

SOLVER_ODE_RK4

public static final Engine.SolverODEType SOLVER_ODE_RK4

SOLVER_NAE_MODIFIED_NEWTON

public static final Engine.SolverNAEType SOLVER_NAE_MODIFIED_NEWTON

SOLVER_NAE_FAST_NEWTON

public static final Engine.SolverNAEType SOLVER_NAE_FAST_NEWTON

SOLVER_NAE_CLASSIC_NEWTON

public static final Engine.SolverNAEType SOLVER_NAE_CLASSIC_NEWTON

SOLVER_DAE_RK45_NEWTON

public static final Engine.SolverDAEType SOLVER_DAE_RK45_NEWTON

SOLVER_DAE_EULER_NEWTON

public static final Engine.SolverDAEType SOLVER_DAE_EULER_NEWTON

Constructor Details

Engine

public Engine()
Constructs the engine and sets the seed of the default random number generator to 0.
Normally this constructor calls are generated automatically by AnyLogic.

For AnyLogic Professional users: in custom experiments please use ExperimentCustom.createEngine() method instead of this constructor to create and obtain new instance of the engine

Method Details

getRoot

public Agent getRoot()
Returns the top-level agent setup for the engine (the topmost level agent from which the model creation and execution starts). Usually (and by default) it is an instance of Agent class Main.
Returns:
the top-level agent

error

public RuntimeException error(String errorText)
Signals an error during the model run by throwing a RuntineException with the given text.
Parameters:
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw error("my message");

errorInModel

public RuntimeException errorInModel(String errorText)
Signals an model logic error during the model run by throwing a ModelException with the given text.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments. Examples are 'entity was unable to leave flowchart block because subsequent block was busy', 'insufficient capacity of pallet rack' etc.
Parameters:
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw error("my message");

error

public RuntimeException error(Throwable cause,
 String errorText)
Signals an error during the model run by throwing a RuntineException with the given text.
Parameters:
cause - the cause (which will be saved for more detailed message), may be null
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw error("my message");

errorInModel

public RuntimeException errorInModel(Throwable cause,
 String errorText)
Signals an model logic error during the model run by throwing a ModelException with the given text.
This method differs from error() in the way of displaying error message: model logic errors are 'softer' than other errors, they use to happen in the models and signal the modeler that model might need some parameters adjustments. Examples are 'entity was unable to leave flowchart block because subsequent block was busy', 'insufficient capacity of pallet rack' etc.
Parameters:
cause - the cause (which will be saved for more detailed message), may be null
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw error("my message");

disableWarning

@AnyLogicInternalAPI
public void disableWarning(String warningType)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

time

public double time()
Returns the current model (logical) time. Time stays constant during an event execution and is only advanced between events.
Returns:
current model time in model time units
See Also:
getTimeUnit()

time

public double time(TimeUnits units)
Returns the current model (logical) time. Time stays constant during an event execution and is only advanced between events.
Parameters:
units - the time units
Returns:
current model time in the given units
Since:
8.0

getTime

@Deprecated
public double getTime()
Deprecated.
Use time() instead.
Returns the current model (logical) time.
Returns:
the current model (logical) time

getNextEventTime

public double getNextEventTime()
Returns the time of the earliest event scheduled so far. If there is no events, returns -infinity.
This method should be generally used in the model internal logic because the "next event" may be the utility one which e.g. updates some plot/chart/...
This method is designed for some external time management applications, e.g. for HLA (High-level architecture) implementations.
Returns:
the time of the earliest event or -infinity
Since:
7.0

getNextStepTime

public double getNextStepTime()
Returns the time which will be after the next step() execution If the model is about to finish, returns -infinity.
Special cases:
  • in system-dynamics models the result may depend on the selected accuracy
  • in system-dynamics models some conditional events may occur based on the value obtained from numerical solver within the step. This case can't be predicted and in such situations the actual step() will have the time "before" the value returned by this function
  • for the models without any activity, this method depends on the setRealTimeMode(boolean) and setRealTimeScale(double) settings: it either simply increments the time with some amount - like the step() function does or returns -infinity
This method is designed for some external time management applications, e.g. for HLA (High-level architecture) implementations.
Returns:
the time of the next step or -infinity
Since:
7.1
See Also:
getNextEventTime()

getProgress

public double getProgress()
Returns the progress of the simulation: the part of model time simulated so far in case the stop time is set, or -1 if it is not set. In IDLE and ERROR states also returns -1.
Returns:
the progress of the simulation

setStartTime

public void setStartTime(double tstart)
Sets the start time for the simulation - the initial value of the model clock. By default it is 0. Has no effect if called after the model starts running.
Parameters:
tstart - the simulation start time, in model time units
See Also:
getTimeUnit()

setStartTime

public void setStartTime(double tstart,
 TimeUnits units)
Sets the start time for the simulation - the initial value of the model clock. By default it is 0. Has no effect if called after the model starts running.
Parameters:
units - the time units
tstart - the simulation start time, in the given time units
Since:
8.0

getStartTime

public double getStartTime()
Returns the currently set start time - the model time at which the simulation starts, by default it is 0.
Returns:
the simulation start time, in model time units
See Also:
getTimeUnit()

getStartTime

public double getStartTime(TimeUnits units)
Returns the currently set start time - the model time at which the simulation starts, by default it is 0.
Parameters:
units - the time units
Returns:
the simulation start time, in the given time units
Since:
8.0

setStopTime

public void setStopTime(double tstop)
Sets the stop time for the simulation. The simulation won't stop if the stop time set at runtime is earlier than the current model time or equals +infinity. If any event(s) are scheduled exactly at stop time, they will be executed. By default the stop time is +infinity, so the simulation may run infinitely.
Parameters:
tstop - the (model) time to stop the simulation, in model time units
See Also:
getTimeUnit()

setStopTime

public void setStopTime(double tstop,
 TimeUnits units)
Sets the stop time for the simulation. The simulation won't stop if the stop time set at runtime is earlier than the current model time or equals +infinity. If any event(s) are scheduled exactly at stop time, they will be executed. By default the stop time is +infinity, so the simulation may run infinitely.
Parameters:
tstop - the (model) time to stop the simulation, in the given time units
units - the time units
Since:
8.0

getStopTime

public double getStopTime()
Returns the currently set stop time - the model time at which the simulation should stop, or +infinity if stop time is not set.
Returns:
the simulation stop time, in model time units or +infinity
See Also:
getTimeUnit()

getStopTime

public double getStopTime(TimeUnits units)
Returns the currently set stop time - the model time at which the simulation should stop, or +infinity if stop time is not set.
Parameters:
units - the time units
Returns:
the simulation stop time, in the given time units or +infinity
Since:
8.0

date

public Date date()
Returns the current model date with respect to the start time/date and the model time unit.
Returns:
the current model date

getDate

@Deprecated
public Date getDate()
Deprecated.
Use date() instead
Returns the current model date.
Returns:
the current model date

isCalendarDateUsed

public boolean isCalendarDateUsed()
Returns true if calendar dates (e.g. date() method) are meaningful.
Returns:
true if calendar dates are meaningful

dateInMillis

@AnyLogicInternalAPI
public long dateInMillis()
Returns the current model date milliseconds with respect to the start time/date and the model time unit.
Returns:
the current model date milliseconds

timeToDateInMillis

@AnyLogicInternalAPI
public long timeToDateInMillis(double time)
Returns the model date milliseconds with respect to the start time/date and the model time unit for the given model time
Returns:
the model date milliseconds for the given model time

getMillisecond

public int getMillisecond()
Returns the millisecond within the second of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 250.
Returns:
the millisecond within the second of the current model date with respect to the start time/date and the model time unit

getSecond

public int getSecond()
Returns the second within the minute of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 15.
Returns:
the second within the minute of the current model date with respect to the start time/date and the model time unit

getMinute

public int getMinute()
Returns the minute within the hour of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 4.
Returns:
the minute within the hour of the current model date with respect to the start time/date and the model time unit

getHour

public int getHour()
Returns the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit.
This method is used for the 12-hour clock.
Noon and midnight are represented by 0, not by 12.
E.g., at 10:04:15.250 PM the result is 10.
Returns:
the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit
See Also:
getAmPm()getHourOfDay()

getAmPm

public int getAmPm()
Indicates whether the hour of the current model date with respect to the start time/date and the model time unit is before (AM) or after (Utilities.PM) noon.
This method is used for the 12-hour clock.
E.g., at 10:04:15.250 PM the result is Utilities.PM.
Returns:
Utilities.AM or Utilities.PM depending on the hour of the current model date with respect to the start time/date and the model time unit
See Also:
getHour()getHourOfDay()

getHourOfDay

public int getHourOfDay()
Returns the hour of day of the current model date with respect to the start time/date and the model time unit.
This method is used for the 24-hour clock.
E.g., at 10:04:15.250 PM the result is 22.
Returns:
the hour of day of the current model date with respect to the start time/date and the model time unit
See Also:
getHour()getAmPm()

getDayOfWeek

public int getDayOfWeek()
Returns the day of the week of the current model date with respect to the start time/date and the model time unit.
Returned value is one of:
Returns:
the day of the week of the current model date with respect to the start time/date and the model time unit

getDayOfMonth

public int getDayOfMonth()
Returns the day of the month of the current model date with respect to the start time/date and the model time unit.
The first day of the month has value 1.
Returns:
the day of the month of the current model date with respect to the start time/date and the model time unit

getDayOfYear

public int getDayOfYear()
Returns the day of the year of the current model date with respect to the start time/date and the model time unit.
The first day of the year has value 1.
Returns:
the day of the year of the current model date with respect to the start time/date and the model time unit

getMonth

public int getMonth()
Returns the month of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value.
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.
Possible values:
Returns:
the month of the current model date with respect to the start time/date and the model time unit

getYear

public int getYear()
Returns the year of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value
Returns:
the year of the current model date with respect to the start time/date and the model time unit

dateToTime

public double dateToTime(Date d)
Converts the given date to model time with respect to the start date, start time and model time unit settings
Parameters:
d - the date to convert
Returns:
the model time corresponding to date

timeToDate

public Date timeToDate(double t)
Converts the given model time to date with respect to the start date, start time and model time unit settings, null if the time is infinity.
Parameters:
t - the model time
Returns:
the date corresponding to the given model time, or null

setStartDate

public void setStartDate(Date date)
Sets the date corresponding to the start time of the simulation.
Parameters:
date - the date corresponding to the start time of the simulation (composed in the default time zone)

getStartDate

public Date getStartDate()
Returns the date corresponding to the start time of the simulation.
Returns:
the date corresponding to the start time of the simulation (in local TimeZone set in the Java Virtual Machine)

setStopDate

public void setStopDate(Date date)
Sets the stop time of the simulation by converting the stop date provided to the model time, subject to the start time, start date and time unit settings. Discards the previously set stop time.
Parameters:
date - the stop date for the simulation (composed in the default time zone)

getStopDate

public Date getStopDate()
Returns the date corresponding to the stop time, null if the stop time is infinity.
Returns:
the date corresponding to the stop time (in local TimeZone set in the Java Virtual Machine), or null

setTimeUnit

@AnyLogicInternalCodegenAPI
public void setTimeUnit(TimeUnits tu)
Sets the correspondence between the model time unit and a real time unit. You may use constants SECOND, MINUTE, etc. The default value is SECOND. This has nothing to do with the simulation real time mode but affects the conversion between the model time and date.
This method is internal and generally shouldn't be called by user, because 'time units' is the property of the whole model and shouldn't be changed.
Parameters:
tu - the real time unit corresponding to the model time unit

getTimeUnit

public TimeUnits getTimeUnit()
Returns the real time units currently set as the model time units.
Returns:
the units used as model time units

getRunCount

public int getRunCount()
Returns the number of the current simulation run, more precisely the number of times the model was destroyed.
Returns:
the number of the current simulation run, more precisely the number of times the model was destroyed.

getStep

public long getStep()
Returns the number of events executed by the engine.
Returns:
the number of events executed

getEventCount

public long getEventCount()
Returns the number of currently scheduled events.
Returns:
the number of currently scheduled events

getStartTimeMillis

@AnyLogicInternalAPI
public long getStartTimeMillis()
Returns the result of a call to System.currentTimeMillis() at the simulation start.
Returns:
the system time at the simulation start

getRunTimeMillis

@AnyLogicInternalAPI
public long getRunTimeMillis()
Returns the real duration of the simulation run in milliseconds, excluding pause times.
Returns:
the real duration of the simulation run

setVMethods

@AnyLogicInternalCodegenAPI
public final void setVMethods(Number n)

getVMethods

@AnyLogicInternalCodegenAPI
public final Number getVMethods()

getModelType

public Engine.ModelType getModelType()
Returns the type of model being executed:
MODEL_TYPE_UNKNOWN - the model is either empty or it is too early to judge
MODEL_TYPE_DISCRETE - the model so far had at least one discrete event and no equations
MODEL_TYPE_CONTINUOUS - the model so far had at equation and no discrete events
MODEL_TYPE_HYBRID the model had both events and equations
Returns:
the type of model being executed

setRealTimeMode

public void setRealTimeMode(boolean on)
Sets the virtual or real time execution mode. In virtual time mode the model is executed as fast as possible, and no sleep() methods are executed. In real time mode the engine tries to maintain the given scale between model time and real time by executing sleep() if there remains any real time to spend in between two events.
Parameters:
on - true means execution in scale to real time

getRealTimeMode

public boolean getRealTimeMode()
Returns true if the current execution mode is real time, false if virtual time.
Returns:
the current model execution mode

setRealTimeScale

public void setRealTimeScale(double scale)
Sets the desired real time scale of model execution, i.e. the number of model time units to be simulated per real second. The actual scale will depend on factors such as simulation performance, applications running in parallel, etc. This scale only has effect in real time execution mode.
Parameters:
scale - then new real time scale

getRealTimeScale

public double getRealTimeScale()
Returns the currently set real time scale of model execution, i.e. the number of model time units to be simulated per real second. The actual scale will depend on factors such as simulation performance, applications running in parallel, etc. This scale only has effect in real time execution mode.
Returns:
the current real time scale

isRealTimeMaintained

@AnyLogicInternalAPI
public boolean isRealTimeMaintained()
                             throws Exception
This method is not designed to be called by user
is public due to technical reasons
Throws:
Exception

setExperimentHost

public void setExperimentHost(IExperimentHost h)
Sets the object that will be host the model execution (animation and controls). Engine needs to know the experiment host to be able to notify it about destruction of agents (they can be displayed), also the user can retrieve and access the experiment host via engine.
Parameters:
h - the experiment host object displaying the model

setPresentation

@Deprecated
public void setPresentation(IExperimentHost p)
Deprecated.
this method will be removed in the next releases. Please use getExperimentHost() instead.

getExperimentHost

public IExperimentHost getExperimentHost()
Returns the experiment host object associated with this engine, or some dummy object with no functionality if there is none.
Returns:
the experiment host object of the model

getPresentation

@Deprecated
public IExperimentHost getPresentation()
Deprecated.
this method will be removed in the next releases. Please use getExperimentHost() instead.

setExperiment

public void setExperiment(Experiment<?> ex)
Sets the experiment that will be controlling the model execution. Engine needs to know the experiment to be able to notify it about important events, also the user can retrieve and access the experiment via engine.
Parameters:
ex - the experiment

getExperiment

public Experiment<?> getExperiment()
Returns the experiment controlling the model execution.
This method isn't designed for AnyLogic Cloud, also returns null for custom experiments
Returns:
the experiment controlling the model execution

getExperimentCustom

public ExperimentCustom getExperimentCustom()
Returns the custom experiment controlling the model execution.
Returns null for other types of experiments
Returns:
the custom experiment controlling the model execution
Since:
8.5.0

setATOL

public void setATOL(double atol)
Sets the absolute tolerance of the numeric engine.
Parameters:
atol - the absolute tolerance to set

getATOL

public double getATOL()
Returns absolute tolerance of the numeric engine.
Returns:
absolute tolerance of the numeric engine

setRTOL

public void setRTOL(double rtol)
Sets the relative tolerance of the numeric engine.
Parameters:
rtol - the relative tolerance to set

getRTOL

public double getRTOL()
Returns relative tolerance of the numeric engine.
Returns:
relative tolerance of the numeric engine

setTTOL

public void setTTOL(double ttol)
Sets the time tolerance of the numeric engine.
Parameters:
ttol - the time tolerance to set

getTTOL

public double getTTOL()
Returns time tolerance of the numeric engine.
Returns:
time tolerance of the numeric engine

setHTOL

public void setHTOL(double htol)
Sets the fixed step of the numeric engine.
Parameters:
htol - the fixed step to set

getHTOL

public double getHTOL()
Returns fixed step of the numeric engine.
Returns:
fixed step of the numeric engine

setEventAwareSolver

public void setEventAwareSolver(boolean eventAwareSolver)
This setting is actual for models having both System Dynamics equations and Discrete Event parts.
  • If true, SD equations will be solved with respect to each event occurrence time. This is the most precise technique, but in some cases it may significantly slow down the model, e.g. when many asynchronous agents generate dense events on the timeline.
  • If false, SD equations will be solved with fixed steps regardless events' occurrences. As a result, an event will operate with some recent (not quite actual) values of continuous variables, namely, corresponding to the last result of numeric integration step. In the worst case, the values will be HTOL time units late. And similarly, in this mode SD formulas aren't evaluated after each event execution, this is done only on fixed steps of the solver.
This setting is true by default

isEventAwareSolver

public boolean isEventAwareSolver()
Returns the current setting used by System Dynamics solver in the models having both System Dynamics equations and Discrete Event parts.
See Also:
more information...

getSolverODE

public Engine.SolverODEType getSolverODE()
Returns solver type for ordinary differential equations
Returns:
solver type for ordinary differential equations

setSolverODE

public void setSolverODE(Engine.SolverODEType solverODE)
Sets solver type for ordinary differential equations
Available solvers:
Parameters:
solverODE - solver type for ordinary differential equations

getSolverNAE

public Engine.SolverNAEType getSolverNAE()
Returns solver type for algebraic equations
Returns:
solver type for algebraic equations

setSolverNAE

public void setSolverNAE(Engine.SolverNAEType solverNAE)
Sets solver type for algebraic equations
Available solvers:
Parameters:
solverNAE - solver type for algebraic equations

getSolverDAE

public Engine.SolverDAEType getSolverDAE()
Returns solver type for mixed differential-algebraic equations
Returns:
solver type for mixed differential-algebraic equations

setSolverDAE

public void setSolverDAE(Engine.SolverDAEType solverDAE)
Sets solver type for mixed differential-algebraic equations
Available solvers:
Parameters:
solverDAE - solver type for mixed differential-algebraic equations

setSimultaneousEventsSelectionMode

public void setSimultaneousEventsSelectionMode(Engine.EventSelectionMode mode)
Sets the mode of event selection among simultaneous events (if any occur). The default choice is LIFO.
This feature is experimental and not recommended in general cases.
Parameters:
mode - one of the following values:
  • EVENT_SELECTION_LIFO (selected by default since AnyLogic 8.6) - fast deterministic selection mode, simultaneous events are executed in the reverse to the order they were scheduled
  • EVENT_SELECTION_FIFO - fast deterministic selection mode, simultaneous events are executed in the same order they were scheduled
  • EVENT_SELECTION_RANDOM - random (but slow) selection mode

getState

public Engine.State getState()
Returns the current state of the engine:
IDLE - no model is set for execution, doing nothing
PAUSED - model is set and have started, ready to run or make a step
RUNNING - in the loop of model execution invoked by run() or runFast()
FINISHED - the model execution is finished OK, but the model is not yet destroyed
ERROR - the model execution is finished with error, the model is not yet destroyed
PLEASE_WAIT - in the process of executing a non-interruptible command like pause(), step() or stop()
The state is however not guaranteed as may be modified concurrently.
Returns:
the current state of the engine

resetBeforeStart

public void resetBeforeStart()
This method should be called from custom experiments which use logging to database.
Resets state variables which may be accessed by root parameters setup before start(Agent) is called.
This method does nothing if state isn't IDLE
Since:
7.2

start

public boolean start(Agent root)
Engine command applicable only in IDLE state (in other states does nothing and returns false). Does the following:
1. Sets up the start time of the model execution
2. Creates whatever is needed in the top-level agent - calls root.create();
3. Starts the model (first events get scheduled) - calls root.start();
4. Puts the engine into the PAUSED state.

step

public boolean step()
Makes at most one discrete step of the model (can be done from the PAUSED state only). Finishes in either FINISHED, ERROR or PAUSED state.
This method should never be called from the model execution thread!
Returns:
false if the engine state does not allow for making a step

isDebugging

public static boolean isDebugging()
Returns true if the model is started in the debug mode from AnyLogic
Returns:
true if the model is started in the debug mode from AnyLogic, false if this is an ordinary run
Since:
7.1

run

public boolean run()
Engine command applicable only in PAUSED state (in other states does nothing and returns false). Puts the engine into RUNNING state and then starts the model execution in a separate thread. The execution may discontinue due to the one of the following reasons
- there are no more events to execute (state -> FINISHED)
- stopTime is reached (state -> FINISHED)
- pause() was called (state -> PAUSED)
- top-level agent has been destroyed (state -> FINISHED)
- exception occurred during event execution or agent destruction (state -> ERROR)
This method should never be called from the model execution thread!
Please note that by the time this method finishes, then engine may already be in PAUSED, FINISHED, or ERROR state.
Returns:
false if the engine state does not allow running

runFast

public boolean runFast()
Runs the model in the fastest possible way in the same (calling) thread. The run is done in virtual time mode regardless any settings. The method finishes in one of the following cases:
- illegal engine state when it is called (returns false, in all other cases - returns true)
- there are no more events/equations to execute (state -> FINISHED)
- stopTime is reached (state -> FINISHED)
- pause() was called (state -> PAUSED)
- finish() was called (state -> FINISHED)
- top-level agent has been destroyed (state -> FINISHED)
- exception occurred during model execution (state -> ERROR)
The model is locked for both write and read during the entire run, so you should not try to display presentation of the agents, or execute any concurrent actions that may access the model.
Returns:
false if the engine state does not allow running

runFast

public boolean runFast(double pauseTime)
Calls runFast() but pauses the model execution at the specified model time and returns true
If the model finishes (because of stop time or finish() method called) before the pauseTime, the method runs the model until the finish moment only.
Parameters:
pauseTime - the time to pause model execution
Returns:
false if the engine state does not allow running
See Also:
runFast()

runFastInterruptible

@AnyLogicInternalAPI
public void runFastInterruptible(double pauseTime)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Since:
8.0

interruptRunFast

@AnyLogicInternalAPI
public void interruptRunFast(Runnable callback)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Since:
8.0

pause

public boolean pause()
Engine command applicable only in RUNNING state (in other states does nothing and returns false). Puts the engine into PLEASE_WAIT state and then sets a flag that, when tested by the engine, causes it to pause after completing the current event execution. Further behavior depends on context where this method is called:
  • When this method is called from the model execution thread, from control action code, or from on-click code of a shape, it returns true immediately. Model is paused just after current event execution
  • When this method is called from other locations (e.g. user-defined concurrent thread), it waits for the model execution thread to terminate and returns true.
Note that by the time this method finishes, the engine may be in PAUSED, FINISHED, or ERROR state.
Returns:
false if the engine state does not allow pausing

finish

public boolean finish()
Terminates the model after execution of current event. Doesn't destroy the model.
Note that by the time this method finishes, the engine may be in FINISHED or ERROR state.

Engine command applicable only in RUNNING or PAUSED state (in other states does nothing and returns false). Sets a flag that, when tested by the engine, causes it to finish after completing the current event execution. Further behavior depends on context where this method is called:
  • When this method is called from the model execution thread, control action code, or from on-click code of a shape, it returns true immediately. Model is finished just after current event execution (After Simulation Run code of an experiment may be used to handle this moment)
  • When this method is called from other locations (e.g. user-defined concurrent thread), it waits for the model execution thread to terminate and returns true.
Returns:
false if the engine state does not allow terminating (engine is neither running nor paused)

stop

public boolean stop()
Stops and destroys the model, see also finish() method, which doesn't destroy the model.

Engine command applicable only in any non-IDLE state (in IDLE state does nothing and returns false). If the state is RUNNING, sets a flag that, when tested by the model execution thread, causes it to terminate. Further behavior depends on context where this method is called:
  • When this method is called from the model execution thread, or from control action code, or from on-click code of a shape, it returns true immediately, leaving the model in PLEASE_WAIT state. Model is stopped and destroyed some time later (After Simulation Run code of an experiment or On Destroy code of top-level agent may be used to handle this moment)
    It is more recommended to use finish() method in such situations
  • When this method is called from other locations (e.g. user-defined concurrent thread), it waits for the model execution thread to terminate and then destroys the model (calls root.onDestroy()) and forgets it. Then puts the engine into IDLE state and returns true.
  • If this method is called during "run fast" execution, then it simply finishes the model - you should manually take care of stopping the engine after you collect all needed data from finished model.

isTestExperiment

@AnyLogicInternalAPI
public boolean isTestExperiment()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

isStopping

@AnyLogicInternalAPI
@Deprecated
public boolean isStopping()
Deprecated.
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

registerAgentWithEquations

@AnyLogicInternalCodegenAPI
public void registerAgentWithEquations(Agent ao)
Registers given agent with equations in Engine equations solver. Is called from Agent constructor code if the object has equations.
Parameters:
ao - the agent that has equations and registers

unregisterAgentWithEquations

@AnyLogicInternalCodegenAPI
public boolean unregisterAgentWithEquations(Agent ao)
Unregisters the agent from the engine equations solver. Is called from agent onDestroy code if the agent had equations.
Parameters:
ao - the agent that had equations but now unregisters

registerDelay

@AnyLogicInternalCodegenAPI
public void registerDelay(VariableDelay variableDelay)
Registers given delay in Engine equations solver. Is called from Agent constructor code if the object has equations.
Parameters:
variableDelay - delay

unregisterDelay

@AnyLogicInternalCodegenAPI
public void unregisterDelay(VariableDelay variableDelay)
Unregisters the delay from the engine equations solver. Is called from agent onDestroy code if the agent had delay.
Parameters:
variableDelay - delay

getDefaultRandomGenerator

public Random getDefaultRandomGenerator()
Returns the currently used default random number generator.
Returns:
the default random number generator.

setDefaultRandomGenerator

public void setDefaultRandomGenerator(Random r)
Changes the default random number generator.
Parameters:
r - the new random number generator.

saveRootObjectSnapshot

public void saveRootObjectSnapshot(String snapshotFileName)
Saves top-level agent and current state of this Engine to a snapshot file with the given name. This method is designed to be used in custom experiments and is available in professional version only.
This method shouldn't be called from the model-execution thread (except calling from custom experiments where the model is executed using runFast() method). Also, this method shouldn't be called when this engine is in RUNNING state.
Note that created snapshot file may only be used in calls to loadRootObjectFromSnapshot methods, i.e. it isn't compatible with any experiments with animation (i.e. not custom)
Parameters:
snapshotFileName - the absolute path to the snapshot file

loadRootObjectFromSnapshot

public Agent loadRootObjectFromSnapshot(String snapshotFileName)
Loads and sets top-level agent from the given snapshot with caching contents of snapshot file (for performance speed-up)
This method supports loading from snapshots created with any experiment with animation (i.e. not custom) and from snapshots saved using saveRootObjectSnapshot(String) method
Parameters:
snapshotFileName - the absolute path to the snapshot file
See Also:

loadRootObjectFromSnapshot

public Agent loadRootObjectFromSnapshot(String snapshotFileName,
 boolean cacheSnapshot)
Loads and sets top-level agent from the given snapshot with optional caching contents of snapshot file (for performance speed-up)
This method supports loading from snapshots created with any experiment with animation (i.e. not custom) and from snapshots saved using saveRootObjectSnapshot(String) method
Parameters:
snapshotFileName - the absolute path to the snapshot file
cacheSnapshot - if true, snapshot file will be cached for performance speed-up
See Also:
flushSnapshotCache()

flushSnapshotCache

public void flushSnapshotCache()
Clears cache with contents of recently loaded snapshot file
NB: cache is automatically cleared on new snapshot loading
See Also:

getModelDatabase

public ModelDatabase getModelDatabase()
Returns the the database of this model
Returns:
the database of this model
Since:
7.2

getModelProperties

@AnyLogicInternalAPI
public ModelProperties getModelProperties()
Returns the model properties of this model
Since:
7.2

isPackage3DResourcesLocatedinJar

@AnyLogicInternalAPI
public boolean isPackage3DResourcesLocatedinJar(String packagePrefix)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.