net.simplace.sim.control.generators.RandomSimGenerator

Generate simulations with parameters created randomly from specified distributions.

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.

| <cal id="VariableName" target="vModuleName">

For each calibration variable the distribution and it's parametrization as in the table above.

| <cal id="VariableName" target="vModelParameter" datatype="DOUBLE">
|   <input id="distribution" datatype="CHAR">DISTRIBUTION</input>
|   <input id="PARAMETER1" datatype="DOUBLE">3.0</input>
|   <input id="PARAMETER2" datatype="DOUBLE">.5</input>
| </cal>

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.

| <constraint rule="${Generator.TsumMaturity} &gt; 	 ${Generator.TsumAnthesis}+100">

Remark

The number of created simulations can be smaller than Count.

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

|<generator id="Generator" class="net.simplace.sim.control.generators.RandomSimGenerator">
|
| <cal id="TsumAnthesis" datatype="DOUBLE" target="vTsumAnt">
|   <input id="distribution" datatype="CHAR">Uniform</input>
|   <input id="min" datatype="DOUBLE">0</input>
|   <input id="max" datatype="DOUBLE" source="vTsumMax" />
| </cal>
|
| <cal id="TsumMat" datatype="DOUBLE" target="vTsumMat">
|   <input id="distribution" datatype="CHAR">Normal</input>
|   <input id="sigma" datatype="DOUBLE" source="Iterator.TsumMat.sigma" />
|   <input id="mean" datatype="DOUBLE" source="Iterator.TsumMat.mean" />
|   <input id="min" datatype="DOUBLE">0</input>
|   <input id="max" datatype="DOUBLE" source="vTsumMax" />
| </cal>
|
| <cal id="Soiltype" datatype="CHAR" target="vSoiltype">
|   <input id="distribution" datatype="CHAR">Choice</input>
|   <input id="values" datatype="CHARARRAY">{loam,sand,sandyloam}</input>
|   <input id="frequencies" datatype="DOUBLEARRAY" >{2,9,6}</input>
| </cal>
|
| <input id="cRandomSeed" datatype="CHAR">342345734</input>
| <input id="cCount" datatype="INT">100</input>
|
| <constraint rule="${Generator.TsumMaturity} &gt; ${Generator.TsumAnthesis}+100">
|
|</generator>




public class RandomSimGenerator extends DefaultSimulationGenerator {
// Public Constructors
public RandomSimGenerator(Element aGeneratorElement, FWSimSession aSession,
HashMap aFieldMap, FWSimVariable.CONTENT_TYPE aContentType);


// Class Methods
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
returns random number
protected static int getIndex(double value, Double[] breaks);

Return the index of the first break, that is bigger than the value.
returns index

// Public Instance Methods
public void init(); // Overrides DefaultSimulationGenerator

public HashMap createVariables(); // Overrides DefaultSimulationGenerator

public void generate(FWSimulationControlCache aCache, ResultSet aResultSet)
throws SQLException; // Overrides DefaultSimulationGenerator



}



Hierarchy: java.lang.Object - net.simplace.sim.control.FWSimulationControlContainer (net.simplace.sim.util.FWSimFieldContainer) - net.simplace.sim.control.FWSimulationGenerator - DefaultSimulationGenerator - RandomSimGenerator