public class RandomVariateInitialiser extends SpringSimulationFactory implements org.springframework.beans.factory.InitializingBean
A simulation factory which initialises the values of pre-specified Spring bean properties by drawing randomly from the specified probability distribution. The bean properties are designated as random variates by creating a configuration file which specifies the mapping between each variate and its corresponding distribution.
Currently the following distributions are supported.
N | Normal distribution |
U | Uniform distribution |
The parameters of the distribution are specified in brackets after the abbreviation. For example the following configuration:
agent.epsilon = U(0.2, 0.5)
agent.wealth = N(200.0, 10.0)
specifies that the agent's epsilon parameter is uniformly distributed between 0.2 and 0.5 and the agent's wealth is normally distributed with mean 200 and standard deviation 10.
Properties
,
AbstractDistribution
Modifier and Type | Field and Description |
---|---|
protected String |
configFileName |
protected Object |
configFileNamePrefix |
protected EventScheduler |
eventScheduler |
protected HashMap<String,String> |
expressionBindings |
protected cern.jet.random.engine.RandomEngine |
prng |
Constructor and Description |
---|
RandomVariateInitialiser() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
Number |
evaluate(String expression,
Properties variateBindings) |
protected void |
fireEvent(String variableName,
Number value) |
String |
getConfigFileName() |
Object |
getConfigFileNamePrefix() |
EventScheduler |
getEventScheduler() |
cern.jet.random.engine.RandomEngine |
getPrng() |
Simulation |
initialise(SimulationController simulationController) |
bsh.Interpreter |
initialiseBeanShell(Properties variateBindings) |
void |
parseConfigFile() |
void |
setConfigFileName(String configFileName)
The name of the configuration file which specifies which
bean properties are to be treated as random variates and their
corresponding distribution.
|
void |
setConfigFileNamePrefix(Object configFileNamePrefix) |
void |
setEventScheduler(EventScheduler eventScheduler)
If this property is set then the initialiser will fire
a RandomVariateInitialisedEvent each time a
random variate is initialised.
|
void |
setPrng(cern.jet.random.engine.RandomEngine prng)
The pseudo-random number generator to be used for drawing all
variates drawn by this initialiser.
|
protected Object configFileNamePrefix
protected String configFileName
protected cern.jet.random.engine.RandomEngine prng
protected EventScheduler eventScheduler
public Simulation initialise(SimulationController simulationController)
initialise
in interface SimulationFactory
initialise
in class SpringSimulationFactory
public void parseConfigFile() throws FileNotFoundException, IOException
FileNotFoundException
IOException
public Number evaluate(String expression, Properties variateBindings)
public bsh.Interpreter initialiseBeanShell(Properties variateBindings) throws bsh.EvalError
bsh.EvalError
public String getConfigFileName()
public void setConfigFileName(String configFileName)
configFileName
- Properties
public cern.jet.random.engine.RandomEngine getPrng()
public void setPrng(cern.jet.random.engine.RandomEngine prng)
prng
- public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public EventScheduler getEventScheduler()
public void setEventScheduler(EventScheduler eventScheduler)
eventScheduler
- The scheduler used to manage the event queue.RandomVariateInitialisedEvent
,
EventScheduler
public Object getConfigFileNamePrefix()
public void setConfigFileNamePrefix(Object configFileNamePrefix)
Copyright © 2014. All rights reserved.