public class StochasticAccessorAnyLogic<S extends AbstractStochasticItem> extends AbstractStochasticAccessInfo implements java.io.Serializable
This is an AnyLogic-specific variant of the standard version which works round AnyLogic threading issues (and should always be used for AnyLogic models).
Constructor and Description |
---|
StochasticAccessorAnyLogic(java.lang.Class<?> owner,
java.lang.String id)
Create an 'empty' accessor, normally held statically to access the per-run
stochastic item across all instances of the class (in a way that works around
AnyLogic threading issues).
|
Modifier and Type | Method and Description |
---|---|
void |
addForRun(com.anylogic.engine.Agent agentInModel,
S stochItem)
Thread-safe method to add a stochastic item for the current run.
|
S |
getForRun(com.anylogic.engine.Agent agentInModel)
Thread-safe method to get the stochastic item for the current run.
|
static void |
registerAccessorFreeStochItem(java.lang.Class<?> owner,
java.lang.String id,
com.anylogic.engine.Agent agentInModel,
AbstractStochasticItem stochItem)
Register a stochastic item for use without an accessor for access.
|
void |
removeMe(AbstractStochasticItem stochItem)
Exposed for technical reasons; not for JSIT user use.
|
getFullID, getOwnerName
public StochasticAccessorAnyLogic(java.lang.Class<?> owner, java.lang.String id)
owner
- The class owning (using) the stochastic item.id
- A user-provided ID to define this stochastic item (used in
stochastic control configuration files together with the
owning class name).public static void registerAccessorFreeStochItem(java.lang.Class<?> owner, java.lang.String id, com.anylogic.engine.Agent agentInModel, AbstractStochasticItem stochItem)
owner
- The class owning (using) the stochastic item.agentInModel
- Any Agent instance that is part of the model. This method will
actually search for the closest 'parent' MainModel_AnyLogic
instance, so passing that (if available directly) will speed
up the call.id
- A user-provided ID to define this stochastic item (used in
stochastic control configuration files together with the
owning class name).stochItem
- The stochastic item to register.public void addForRun(com.anylogic.engine.Agent agentInModel, S stochItem)
agentInModel
- Any Agent instance that is part of the model. This method will
actually search for the closest 'parent' MainModel_AnyLogic
instance, so passing that (if available directly) will speed
up the call.stochItem
- The stochastic item being added.public S getForRun(com.anylogic.engine.Agent agentInModel)
agentInModel
- Any Agent instance that is part of the model. This method will
actually search for the closest 'parent' MainModel_AnyLogic
instance, so passing that (if available directly) will speed
up the call.public void removeMe(AbstractStochasticItem stochItem)
removeMe
in class AbstractStochasticAccessInfo