|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xj.anylogic.engine.ExperimentCustom
public abstract class ExperimentCustom
Base class for all custom experiments
The experiment scenario should be defined in the overridden run() method
Custom experiment may be executed from another experiment - in this case the latter
should be passed as an argument to the constructor of the custom experiment. Experiment
is executed by calling run() method.
A sample action code of some Main active object which runs custom experiment:
// Create custom experiment, pass currently running experiment // as an argument to the constructor: MyCustomExperiment e = new MyCustomExperiment(getExperiment()); // setup some custom fields defined in the // additional class code of MyCustomExperiment: e.day = getDayOfWeek(); // run experiment e.run(); // collect results from custom fields defined in the // additional class code of MyCustomExperiment: traceln( "result: " + e.myResult );(In the example above, custom experiment has Code (which is actually inside
run() method) which gets field day (defined in the additional
class code), uses it in the experiment and then sets some result value to
the field myResult)createEngine() to create new Engine instance
Use Engine.runFast() method to run experiment in the fastest possible
modeExperimentOptimization.createOptimization(Engine) to
create new OptQuest Optimization instancerun() code:
// Create Engine, initialize random number generator: Engine engine = createEngine(); // Set stop time engine.setStopTime( 100 ); // Create new root object: Main root = new Main(engine, null, null); // Setup parameters of root object here root.myParameter = 10; // Prepare Engine for simulation: engine.start( root ); // Start simulation in fast mode: engine.runFast(); // Obtain results of simulation here traceln( root.myResult ); // Destroy the model: engine.stop();This object is only available in the AnyLogic Professional
run(),
Serialized Form| Constructor Summary | |
|---|---|
ExperimentCustom(java.lang.Object parentExperiment)
Creates new custom experiment which may be executed from another experiment - in this case the latter should be passed as an argument to the constructor of the custom experiment |
|
| Method Summary | |
|---|---|
Engine |
createEngine()
Creates Engine |
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 nullThis method is designed for usage inside the run() method |
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 |
run()
Use createEngine() |
void |
setCommandLineArguments_xjal(java.lang.String[] commandLineArguments)
This method should not be called by user |
void |
setupEngine_xjal(Engine engine)
This method should not be called by user |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExperimentCustom(java.lang.Object parentExperiment)
parentExperiment - experiment which uses/runs this custom experiment
(it may be experiment of any type: simulation, optimization, custom etc.)| Method Detail |
|---|
public final Engine createEngine()
Engine instancepublic void setupEngine_xjal(Engine engine)
engine - public abstract void run()
createEngine()
public void onError(java.lang.Throwable error)
error - an error which has occurred during event executionpublic void setCommandLineArguments_xjal(java.lang.String[] commandLineArguments)
commandLineArguments - public final java.lang.String[] getCommandLineArguments()
nullrun() method
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||