public abstract class ExperimentCustom
extends java.lang.Object
implements java.io.Serializable
run()
methodrun()
method.// 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 top-level agent: Main root = new Main(engine, null, null); // Setup parameters of top-level agent 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 FormConstructor and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
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 null This 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.)
|
void |
onError(java.lang.Throwable error,
Agent root)
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
|
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.)@AnyLogicInternalCodegenAPI public 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 onError(java.lang.Throwable error, Agent root)
error
- an error which has occurred during event executionroot
- the root (main) agent of the model, useful for experiments with multiple runs executed in parallel. May be null
in some cases (e.g. on errors during root agent creation).@AnyLogicInternalCodegenAPI public void setCommandLineArguments_xjal(java.lang.String[] commandLineArguments)
commandLineArguments
- public final java.lang.String[] getCommandLineArguments()
null
run()
methodCopyright © AnyLogic North America, LLC. All Rights Reserved.