|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xj.anylogic.engine.Presentable
com.xj.anylogic.engine.Utilities
com.xj.anylogic.engine.Experiment<ROOT>
ROOT - class of root objectpublic abstract class Experiment<ROOT extends ActiveObject>
A base class for all AnyLogic experiments. Experiment describes how would
one like to run the model (just perfrom a single simulation run, do Monte Carlo
simulation, vary parameters, optimize, etc.), and what outputs of the model you
are interested in (this may be a simple chart of how a certain value was changing over
time during a run, or how an observable depends on a parameter in case of
multiple runs, or a histogram in case of risk analysis, etc.). The experiment is
also capable of storing the outputs producted by the model so that they are
available after the simulation and independently of it. Experiment can display
itself in a presentation window and be controlled by the presentation GUI. For
that purpose it supports a set of commands that can be assigned to the presentation
window toolbar buttons and menu items.
AnyLogic models with GUI can run as Java applications as well as applets.
This is the recommended HTML for AnyLogic applets:
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<title>My Model - AnyLogic 6</title>
<style type="text/css">
body, html, object, embed, applet { margin:0; padding:0; border:0; }
</style></head>
<body>
<object
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="100%"
height="100%"
codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,7">
<param name="code" value="my_package/MyExperiment$Applet.class" />
<param name="archive" value="com.xj.anylogic.engine.jar,my_model.jar" />
<comment>
<embed
code="my_package/MyExperiment$Applet.class"
archive="com.xj.anylogic.engine.jar,my_model.jar"
width="100%"
height="100%"
type="application/x-java-applet"
pluginsspage="http://java.sun.com/j2se/1.5.0/download.html">
<noembed>
<applet
code="my_package/MyExperiment$Applet.class"
archive="com.xj.anylogic.engine.jar,my_model.jar"
width="100%"
height="100%"> </applet>
</noembed>
</embed>
</comment>
</object>
</body>
</html>
| Field Summary | |
|---|---|
static int |
ERROR
|
static int |
FINISHED
|
static int |
IDLE
|
com.xj.anylogic.engine.internal.ActionQueue |
modelExecutionCommandQueue
This field shouldn't be accessed by user is public due to technical reasons |
com.xj.anylogic.engine.internal.ActionQueue |
mutexModelActionQueue
This field shouldn't be accessed by user is public due to technical reasons |
static int |
OPEN_RESULTS
|
static int |
OPEN_SNAPSHOT
|
static int |
PAUSE
|
static int |
PAUSED
|
static int |
PLEASE_WAIT
|
static int |
RUN
|
static int |
RUNNING
|
static int |
SAVE_RESULTS
|
static int |
SAVE_SNAPSHOT
|
static int |
STEP
|
static int |
STOP
|
| Fields inherited from class com.xj.anylogic.engine.Utilities |
|---|
AM, APRIL, AUGUST, DAY, DECEMBER, FEBRUARY, FRIDAY, HOUR, infinity, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK, YEAR |
| Method Summary | |
|---|---|
void |
close()
This method returns immediately and performs the following actions in a separate thread: stops experiment if it is not stopped, destroys the model and closes experiment window (only if model is started in the application mode) |
abstract ROOT |
createRoot(Engine engine)
Is called to obtain a new root active object. |
java.lang.RuntimeException |
error(java.lang.String errorText)
Signals an error during the model run by throwing a RuntimeException with errorText preceded by the active object full name. |
java.lang.String[] |
getCommandLineArguments()
Returns an array of Command-line Arguments passed to this experiment on model start (empty array in case of no arguments) Never returns null |
java.lang.Object |
getMutexRead_xjal()
|
java.lang.Object |
getMutexWrite_xjal()
|
java.lang.String |
getName()
Returns the name of the experiment. |
Presentation |
getPresentation()
Returns the presentation object of the model, or null if there is none. |
abstract double |
getProgress()
Returns the progress of the experiment: a number between 0 and 1 depending on what part of experiment is completed, or -1 if not known. |
int |
getRunCount()
Returns the number of the current simulation run, more precisely the number of times the model was destroyed. |
abstract double |
getRunTimeSeconds()
Returns the real duration of the experiment in seconds, excluding pause times. |
java.lang.String |
getSnapshotFileName()
Returns the name of snapshot file this experiment is configured to start simulation from |
abstract int |
getState()
Returns the current state of the experiment: IDLE, PAUSED, RUNNING, FINISHED, ERROR, or PLEASE_WAIT |
long |
getStep()
Returns the number of events executed by the engine. |
int |
getWindowHeight()
Returns the initial height of the experiment window, 600 by default. |
int |
getWindowWidth()
Returns the initial width of the experiment window, 800 by default. |
void |
initDefaultRandomNumberGenerator(Engine engine)
This method should be overridden to initialize random number generator of the given engine Default implementation set new random generation with random seed - for unique experiments |
boolean |
isCommandEnabled(int cmd)
Checks if a command can be executed. |
boolean |
isLoadRootFromSnapshot()
Returns true if this experiment is configured
to start simulation from state loaded from snapshot file |
void |
onBeforeSimulationRun(ROOT root)
User's extension point for Before Simulation Run Code By default does nothing |
void |
onDestroy_xjal()
This method normally shouldn't be called by user. |
void |
onDestroy()
User extension point which is called when the experiment object is dynamically disposed - before closing the model window. |
void |
onEngineFinished()
Is called by the engine when it finishes running and is intended to wrap up a single simulation run. |
void |
onError(java.lang.Throwable error)
This method may be overridden to perform custom processing on errors in the model execution (i.e. errors in the action code of events, dynamic events, transitions, entry/exit codes of states etc, formulas, conditions of events etc.) |
abstract void |
pause()
Pauses the experiment execution. |
void |
registerPresentation_xjal(Presentation presentation)
This method isn't designed to be called by user. |
void |
reset()
Is called each time before a new model is created and is intended to reset all data associated with the experiment. |
abstract void |
run()
Starts the experiment execution from the current state. |
void |
setCommandLineArguments_xjal(java.lang.String[] commandLineArguments)
This method should not be called by user |
void |
setLoadRootFromSnapshot(java.lang.String snapshotFileName)
Tells this experiment to load the root object from AnyLogic snapshot file This method is only available in the AnyLogic Professional |
void |
setName(java.lang.String name)
Sets the name of the experiment. |
void |
setup(java.awt.Container container)
Is called in static main() method of applications and in the init() method of applets, after the experiment is constructed. |
void |
setupEngine(Engine engine)
Is called for the simulation engine when it is created |
abstract void |
step()
Performs one step of experiment execution. |
abstract void |
stop()
Terminates the experiment execution. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int IDLE
public static final int PAUSED
public static final int RUNNING
public static final int FINISHED
public static final int ERROR
public static final int PLEASE_WAIT
public static final int OPEN_RESULTS
public static final int SAVE_RESULTS
public static final int OPEN_SNAPSHOT
public static final int SAVE_SNAPSHOT
public static final int RUN
public static final int STEP
public static final int PAUSE
public static final int STOP
public transient com.xj.anylogic.engine.internal.ActionQueue modelExecutionCommandQueue
public transient com.xj.anylogic.engine.internal.ActionQueue mutexModelActionQueue
| Method Detail |
|---|
public void setName(java.lang.String name)
name - the new name of the experimentpublic java.lang.String getName()
public java.lang.RuntimeException error(java.lang.String errorText)
Utilities
error in class UtilitieserrorText - the text describing the error that will be displayed.
throw error("my message");public int getRunCount()
public long getStep()
public abstract int getState()
public abstract double getProgress()
public abstract double getRunTimeSeconds()
public int getWindowWidth()
public int getWindowHeight()
public Presentation getPresentation()
Presentable
getPresentation in class Presentablepublic abstract void run()
public abstract void step()
public abstract void pause()
public abstract void stop()
public void close()
public boolean isCommandEnabled(int cmd)
cmd - the command id
public final void setLoadRootFromSnapshot(java.lang.String snapshotFileName)
snapshotFileName - public final boolean isLoadRootFromSnapshot()
true if this experiment is configured
to start simulation from state loaded from snapshot file
true if this experiment is configured
to start simulation from state loaded from snapshot filepublic final java.lang.String getSnapshotFileName()
public final java.lang.String[] getCommandLineArguments()
null
public abstract ROOT createRoot(Engine engine)
engine - the simulation engine that will simulate the modelpublic void onBeforeSimulationRun(ROOT root)
public void onEngineFinished()
public void reset()
public void setup(java.awt.Container container)
container - the applet - in applet mode,
external container - in component mode, or null
in standalone application modepublic void setupEngine(Engine engine)
engine - the simulation enginepublic void onDestroy()
public void onDestroy_xjal()
onDestroy(),
release resources (e.g. commit connections with database) and call
super.onDestroy_xjal() method
public void initDefaultRandomNumberGenerator(Engine engine)
engine - the engine instancepublic void onError(java.lang.Throwable error)
error - an error which has occurred during event executionpublic void setCommandLineArguments_xjal(java.lang.String[] commandLineArguments)
commandLineArguments - public java.lang.Object getMutexRead_xjal()
public java.lang.Object getMutexWrite_xjal()
public void registerPresentation_xjal(Presentation presentation)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||