AnyLogic
Expand
Font size

Class Engine

  • java.lang.Object
    • com.anylogic.engine.Engine
All Implemented Interfaces:
java.io.Serializable

public final class Engine
extends java.lang.Object
implements java.io.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-interruptable 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

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

Field Summary

Fields 
static Engine.State ERROR  
static Engine.EventSelectionMode EVENT_SELECTION_DETERMINISTIC
Deprecated.
static 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
static 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
static 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.
static Engine.State FINISHED  
static Engine.State IDLE  
static Engine.ModelType MODEL_TYPE_CONTINUOUS  
static Engine.ModelType MODEL_TYPE_DISCRETE  
static Engine.ModelType MODEL_TYPE_HYBRID  
static Engine.ModelType MODEL_TYPE_UNKNOWN  
static Engine.State PAUSED  
static Engine.State PLEASE_WAIT  
static Engine.State RUNNING  
static Engine.SolverDAEType SOLVER_DAE_EULER_NEWTON  
static Engine.SolverDAEType SOLVER_DAE_RK45_NEWTON  
static Engine.SolverNAEType SOLVER_NAE_CLASSIC_NEWTON  
static Engine.SolverNAEType SOLVER_NAE_FAST_NEWTON  
static Engine.SolverNAEType SOLVER_NAE_MODIFIED_NEWTON  
static Engine.SolverODEType SOLVER_ODE_EULER  
static Engine.SolverODEType SOLVER_ODE_RK4  
Modifier and Type Field Description

Constructor Summary

Constructors 
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
Constructor Description

Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
java.util.Date date()
Returns the current model date with respect to the start time/date and the model time unit.
long dateInMillis()
Returns the current model date milliseconds with respect to the start time/date and the model time unit.
double dateToTime​(java.util.Date d)
Converts the given date to model time with respect to the start date, start time and model time unit settings
void disableWarning​(java.lang.String warningType)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
java.lang.RuntimeException error​(java.lang.String errorText)
Signals an error during the model run by throwing a RuntineException with the given text.
java.lang.RuntimeException error​(java.lang.Throwable cause, java.lang.String errorText)
Signals an error during the model run by throwing a RuntineException with the given text.
java.lang.RuntimeException errorInModel​(java.lang.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.
java.lang.RuntimeException errorInModel​(java.lang.Throwable cause, java.lang.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.
boolean finish()
Terminates the model after execution of current event.
void flushSnapshotCache()
Clears cache with contents of recently loaded snapshot file
NB: cache is automatically cleared on new snapshot loading
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.
double getATOL()
Returns absolute tolerance of the numeric engine.
java.util.Date getDate()
Deprecated.
Use date() instead
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.
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: Utilities.SUNDAY Utilities.MONDAY Utilities.TUESDAY Utilities.WEDNESDAY Utilities.THURSDAY Utilities.FRIDAY Utilities.SATURDAY
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.
java.util.Random getDefaultRandomGenerator()
Returns the currently used default random number generator.
long getEventCount()
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
ExperimentCustom getExperimentCustom()
Returns the custom experiment controlling the model execution.
Returns null for other types of experiments
IExperimentHost getExperimentHost()
Returns the experiment host object associated with this engine, or some dummy object with no functionality if there is none.
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.
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.
double getHTOL()
Returns fixed step of the numeric engine.
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.
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.
ModelDatabase getModelDatabase()
Returns the the database of this model
ModelProperties getModelProperties()
Returns the model properties of this model
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
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: 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.
double getNextEventTime()
Returns the time of the earliest event scheduled so far.
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.
IExperimentHost getPresentation()
Deprecated.
this method will be removed in the next releases.
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.
boolean getRealTimeMode()
Returns true if the current execution mode is real time, false if virtual time.
double getRealTimeScale()
Returns the currently set real time scale of model execution, i.e.
Agent getRoot()
Returns the top-level agent setup for the engine (the topmost level agent from which the model creation and execution starts).
double getRTOL()
Returns relative tolerance of the numeric engine.
int getRunCount()
Returns the number of the current simulation run, more precisely the number of times the model was destroyed.
long getRunTimeMillis()
Returns the real duration of the simulation run in milliseconds, excluding pause times.
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.
Engine.SolverDAEType getSolverDAE()
Returns solver type for mixed differential-algebraic equations
Engine.SolverNAEType getSolverNAE()
Returns solver type for algebraic equations
Engine.SolverODEType getSolverODE()
Returns solver type for ordinary differential equations
java.util.Date getStartDate()
Returns the date corresponding to the start time of the simulation.
double getStartTime()
Returns the currently set start time - the model time at which the simulation starts, by default it is 0.
double getStartTime​(TimeUnits units)
Returns the currently set start time - the model time at which the simulation starts, by default it is 0.
long getStartTimeMillis()
Returns the result of a call to System.currentTimeMillis() at the simulation start.
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-interruptable command like pause(), step() or stop()
The state is however not guaranteed as may be modified concurrently.
long getStep()
Returns the number of events executed by the engine.
java.util.Date getStopDate()
Returns the date corresponding to the stop time, null if the stop time is infinity.
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.
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.
double getTime()
Deprecated.
Use time() instead.
TimeUnits getTimeUnit()
Returns the currently set real time unit corresponding to the model time unit.
double getTTOL()
Returns time tolerance of the numeric engine.
java.lang.Number getVMethods()  
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
void interruptRunFast​(java.lang.Runnable callback)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
boolean isCalendarDateUsed()
Returns true if calendar dates (e.g.
static boolean isDebugging()
Returns true if the model is started in the debug mode from AnyLogic
boolean isEventAwareSolver()
Returns the current setting used by System Dynamics solver in the models having both System Dynamics equations and Discrete Event parts.
boolean isRealTimeMaintained()
This method is not designed to be called by user
is public due to technical reasons
boolean isStopping()
Deprecated.
Agent loadRootObjectFromSnapshot​(java.lang.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.
Agent loadRootObjectFromSnapshot​(java.lang.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.
boolean pause()
Engine command applicable only in RUNNING state (in other states does nothing and returns false).
void registerAgentWithEquations​(Agent ao)
Registers given agent with equations in Engine equations solver.
void registerDelay​(VariableDelay variableDelay)
Registers given delay in Engine equations solver.
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
boolean run()
Engine command applicable only in PAUSED state (in other states does nothing and returns false).
boolean runFast()
Runs the model in the fastest possible way in the same (calling) thread.
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.
void runFastInterruptible​(double pauseTime)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void saveRootObjectSnapshot​(java.lang.String snapshotFileName)
Saves top-level agent and current state of this Engine to a snapshot file with the given name.
void setATOL​(double atol)
Sets the absolute tolerance of the numeric engine.
void setDefaultRandomGenerator​(java.util.Random r)
Changes the default random number generator.
void setEventAwareSolver​(boolean eventAwareSolver)
This setting is actual for models having both System Dynamics equations and Discrete Event parts.
void setExperiment​(Experiment<?> ex)
Sets the experiment that will be controlling the model execution.
void setExperimentHost​(IExperimentHost h)
Sets the object that will be host the model execution (animation and controls).
void setHTOL​(double htol)
Sets the fixed step of the numeric engine.
void setPresentation​(IExperimentHost p)
Deprecated.
this method will be removed in the next releases.
void setRealTimeMode​(boolean on)
Sets the virtual or real time execution mode.
void setRealTimeScale​(double scale)
Sets the desired real time scale of model execution, i.e.
void setRTOL​(double rtol)
Sets the relative tolerance of the numeric engine.
void setSimultaneousEventsSelectionMode​(Engine.EventSelectionMode mode)
Sets the mode of event selection among simultaneous events (if any occur).
void setSolverDAE​(Engine.SolverDAEType solverDAE)
Sets solver type for mixed differential-algebraic equations
Available solvers: SOLVER_DAE_RK45_NEWTON (default) SOLVER_DAE_EULER_NEWTON
void setSolverNAE​(Engine.SolverNAEType solverNAE)
Sets solver type for algebraic equations
Available solvers: SOLVER_NAE_MODIFIED_NEWTON (default) SOLVER_NAE_FAST_NEWTON SOLVER_NAE_CLASSIC_NEWTON
void setSolverODE​(Engine.SolverODEType solverODE)
Sets solver type for ordinary differential equations
Available solvers: SOLVER_ODE_EULER (default) SOLVER_ODE_RK4
void setStartDate​(java.util.Date date)
Sets the date corresponding to the start time of the simulation.
void setStartTime​(double tstart)
Sets the start time for the simulation - the initial value of the model clock.
void setStartTime​(double tstart, TimeUnits units)
Sets the start time for the simulation - the initial value of the model clock.
void setStopDate​(java.util.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.
void setStopTime​(double tstop)
Sets the stop time for the simulation.
void setStopTime​(double tstop, TimeUnits units)
Sets the stop time for the simulation.
void setTimeUnit​(TimeUnits tu)
Sets the correspondence between the model time unit and a real time unit.
void setTTOL​(double ttol)
Sets the time tolerance of the numeric engine.
void setVMethods​(java.lang.Number n)  
boolean start​(Agent root)
Engine command applicable only in IDLE state (in other states does nothing and returns false).
boolean step()
Makes at most one discrete step of the model (can be done from the PAUSED state only).
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).
double time()
Returns the current model (logical) time.
double time​(TimeUnits units)
Returns the current model (logical) time.
java.util.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.
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
boolean unregisterAgentWithEquations​(Agent ao)
Unregisters the agent from the engine equations solver.
void unregisterDelay​(VariableDelay variableDelay)
Unregisters the delay from the engine equations solver.
Modifier and Type Method Description

Methods inherited from class java.lang.Object

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

Field Detail

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 Detail

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 Detail

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 java.lang.RuntimeException error​(java.lang.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 java.lang.RuntimeException errorInModel​(java.lang.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 java.lang.RuntimeException error​(java.lang.Throwable cause,
                                        java.lang.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 java.lang.RuntimeException errorInModel​(java.lang.Throwable cause,
                                               java.lang.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​(java.lang.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 java.util.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 java.util.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​(java.util.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 java.util.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​(java.util.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 java.util.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​(java.util.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 java.util.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 currently set real time unit corresponding to the model time unit.
Returns:
the number of milliseconds per model time unit
See Also:
TimeUnits.toMilliseconds()

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​(java.lang.Number n)

getVMethods

@AnyLogicInternalCodegenAPI
public final java.lang.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 java.lang.Exception
This method is not designed to be called by user
is public due to technical reasons
Throws:
java.lang.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-interruptable 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 occured 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​(java.lang.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.

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 java.util.Random getDefaultRandomGenerator()
Returns the currently used default random number generator.
Returns:
the default random number generator.

setDefaultRandomGenerator

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

saveRootObjectSnapshot

public void saveRootObjectSnapshot​(java.lang.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​(java.lang.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:
flushSnapshotCache(), loadRootObjectFromSnapshot(String, boolean)

loadRootObjectFromSnapshot

public Agent loadRootObjectFromSnapshot​(java.lang.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:
loadRootObjectFromSnapshot(String), loadRootObjectFromSnapshot(String, boolean)

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
How can we improve this article?