Class RandomSimGenerator
java.lang.Object
net.simplace.sim.control.FWSimulationControlContainer
net.simplace.sim.control.FWSimulationGenerator
net.simplace.sim.control.generators.DefaultSimulationGenerator
net.simplace.sim.control.generators.RandomSimGenerator
- All Implemented Interfaces:
net.simplace.sim.util.FWSimFieldContainer
public class RandomSimGenerator
extends net.simplace.sim.control.generators.DefaultSimulationGenerator
Generate simulations with parameters created randomly from specified
distributions.
WIKI_START
== Distributions ==
For each model variable the user can chose one of the distribution below:
||'''Distribution''' ||'''Distribution Parameters''' || ''Optional Param.''|| '''Return datatype''' || '''Remark''' ||
|| Uniform || min, max || || DOUBLE || ||
|| Normal || mean, sigma || min, max || DOUBLE || ||
|| Exponential || lambda || min, max || DOUBLE || ||
|| Poisson || lambda || min, max || INT || ||
|| Binomial || n, p || min, max || INT || n has to be of type INT ||
|| Choice || values || frequencies || any || Choses randomly a value from a list. Values have to be an array of the same type as the cal variable||
If min and max are specified and the generated value exceeds them,
new random numbers are generated until one fits the interval.
The number of trials is limited to `cMaxAttemptsOutOfRange`. If no number is found, the parameter
set is skipped.
Generated parameter sets can be further restricted by constraints.
== Variable specific configuration ==
Arbitrary number of calibration variables (either `INT` or `DOUBLE`, depending on
distribution used). When using the distribution `Choice`, then the datatype can
be additionally `CHAR`, `DATE` or `BOOLEAN`.
{{{
|
}}}
For each calibration variable the distribution and it's parametrization
as in the table above.
{{{
|
| DISTRIBUTION
| 3.0
| .5
|
}}}
== General configuration ==
|| '''Name''' || '''DATATYPE''' || '''Description''' ||
|| cCount || INT ||the number of parameter sets to be generated, mandatory ||
|| cRandomSeed || CHAR ||optional random seed for the generator. Can be a long integer, therefore it has datatype CHAR ||
|| cMaxAttemptsOutOfRange || INT ||maximum number of trials to re-generate a random number if it's value is outside min/max range||
A constraint prohibits the creation of invalid variable values.
{{{
|
}}}
== Remark ==
The number of created simulations can be smaller than Count.
- the min and max attributes of the generated values may prohibit generation of some parameter sets
- an additional constraint on the parameter set may prevent generation of a simulation
The random seed is set only on initialization of the generator. That means,
that a subsequent iteration
or a subsequent project can not set it's individual random seed.
== Example ==
{{{
|
|
|
| Uniform
| 0
|
|
|
|
| Normal
|
|
| 0
|
|
|
|
| Choice
| {loam,sand,sandyloam}
| {2,9,6}
|
|
| 342345734
| 100
|
|
|
|
}}}
WIKI_END
- Author:
- Gunther Krauss
-
Field Summary
Fields inherited from class net.simplace.sim.control.FWSimulationGenerator
iContentType, iSimulationsMap
Fields inherited from class net.simplace.sim.control.FWSimulationControlContainer
iCache, iCals, iConstraint, iContainerElement, iControlMap, iFieldMap, iInputMap, iInputs, iName, iParams, iSession, iSimulationMap
-
Constructor Summary
ConstructorDescriptionRandomSimGenerator
(org.jdom2.Element aGeneratorElement, net.simplace.sim.FWSimSession aSession, HashMap<String, net.simplace.sim.util.FWSimVariable<?>> aFieldMap, net.simplace.sim.util.FWSimVariable.CONTENT_TYPE aContentType) -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected static int
Return the index of the first break, that is bigger than the value.void
init()
protected static double
nextRandom
(Random randomizer, String distribution, double min, double max, double mean, double sigma, double lambda, double p, int n) Generates a next random numberMethods inherited from class net.simplace.sim.control.FWSimulationGenerator
addSimulation, canUpdate, clearSimulations, createSimulationGenerator, finalize, getSimulation, getSimulationsListSize, initializeProject, reset, setFinished, setInitial, updateSimulations, writeSimulation
Methods inherited from class net.simplace.sim.control.FWSimulationControlContainer
addProcessTime, addVariable, checkCondition, evaluate, getContentType, getCreateFormXML, getEditFormXML, getFieldMap, getFrequence, getInputVariables, getName, getOrderNumber, getOutputVariables, getVariable, getVarMap, isConditionCheck, readInputCalAndConstraint, removeVariable, setPropertyValue, toXML
-
Constructor Details
-
RandomSimGenerator
-
-
Method Details
-
init
public void init()- Overrides:
init
in classnet.simplace.sim.control.generators.DefaultSimulationGenerator
-
createVariables
- Specified by:
createVariables
in interfacenet.simplace.sim.util.FWSimFieldContainer
- Overrides:
createVariables
in classnet.simplace.sim.control.generators.DefaultSimulationGenerator
-
generate
public void generate(net.simplace.sim.control.FWSimulationControlCache aCache, ResultSet aResultSet) throws SQLException - Overrides:
generate
in classnet.simplace.sim.control.generators.DefaultSimulationGenerator
- Throws:
SQLException
-
nextRandom
protected static double nextRandom(Random randomizer, String distribution, double min, double max, double mean, double sigma, double lambda, double p, int n) Generates a next random number- Parameters:
randomizer
-distribution
-min
-max
-mean
-sigma
-lambda
-p
-n
-- Returns:
- random number
-
getIndex
Return the index of the first break, that is bigger than the value.- Parameters:
value
- a value between 0 and 1breaks
- an array of ordered values between 0 and 1- Returns:
- index
-