Class WeightedLeastDifferenceSelector
- All Implemented Interfaces:
FWSimFieldContainer
- Direct Known Subclasses:
LeastDifferenceSelector
Configuration
User has to specify
- the frequency at which values should be compared
- the calculation method cMode (Bias,MRE,MAE,RMAE,MSE,RMSE,index,rc etc.)
- the number of target variables cNumberOfVariables (up to 20)
- for each target variable a pair of SimVariables cObserved{i}/cSimulated{i}
- for each target variable the weight for the error cWeight{i}
- {i} ranges from 1 to cNumberOfVariables
Outputs
- the selected simulation id as a one size CHARARRAY selectedsimulations
- the best error value achieved as DOUBLE BestErrorValue
- all simulations weighted sum of errors ErrorValues as DOUBLEARRAY
- for each target variable all simulations error ErrorValuesVariable{i} as DOUBLEARRAY
Description
For a simulation the calculated values of different variables \(i = 1, ... cNumberOfVariables\) are compared to reference (measured) values (e.g. Yield, LAI, Biomass). The selector can handle maximum 20 different variables. Each variable exists pairwise in the simulation as observed\simulated. Observed variables normally come from a resource (datafile), where simulated ones are calculated. (Notice: The selector works also, if both variables come from resources or if both are simulated.)
For each of these variables \(n\) samples are produced by the simulation (\(n\) is determined by the simulated time span and the selectors frequence information).
Let \(\mathcal{E}: \mathbb{R}^n \times \mathbb{R}^n\ \rightarrow \mathbb{R}\) be the selected calculation method - e.g. the bias \(E(o,s)=\sum_{j=1}^n o_j - s_j\)
The weighted difference is then
\[ E = \frac{1}{\omega}\sum_{i=1}^{cNumberOfVariables} cWeight_i \mathcal{E}(cObserved_i,cSimulated_i) \] where \(\omega\) is the sum of weights: \[ \omega = \sum_{i=1}^{cNumberOfVariables} cWeight_i \]If \(k= 1, ... l\) simulations are performed within a project, then the selector calculates all weighted errors \(E_k\) and selects the simulation with the best error. (The best error depends on the calculation method for RMSE it's the one closest to 0, for agreement index closest to 1 etc.)
The output NumberOfValues counts the number of simulations used for comparison. Normally it's equal to \(l\), but it can be lower because simulations that produce no usable result (i.e. \(E_k\) could not be calculated) are skipped.
Example
| <selector id="Selector" class="net.simplace.sim.control.selectors.WeightedLeastDifferenceSelector"
| frequence="COMPLEX" rule="${observations.HasData}" >
| <input id="cMode" datatype="CHAR">RRMSE</input>
| <input id="cNumberOfVariables" datatype="INT">1</input>
|
| <input id="cObserved1" datatype="DOUBLE" mode="LAST" source="observations.yield"/>
| <input id="cSimulated1" datatype="DOUBLE" mode="LAST" source="GecrosCrop.WSO"/>
| <input id="cWeight1" datatype="DOUBLE">0.8</input>
|
| <input id="cObserved2" datatype="DOUBLE" mode="LAST" source="observations.greenLAI_destructive"/>
| <input id="cSimulated2" datatype="DOUBLE" mode="LAST" source="GecrosCrop.LAI"/>
| <input id="cWeight2" datatype="DOUBLE">0.2</input>
| </selector>
Error methods
- Bias - mean error
- SignedBias - mean error, selects the smallest signed bias
- MRE - mean relative error
- MAE - mean absolute error
- RMAE - relative mean absolute error
- MSE - mean squared error
- RMSE - root mean squared error
- RRMSE - relative root mean squared error
- SMAPE - symmetric mean absolute percentage error
- EF - model efficiency
- r - Correlation Coefficient
- rc - Concordance Correlation Coefficient
- index - Agreement Index
- NONE - Void Error Calculator
- Author:
- Gunther Krauss
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FWSimVariable<String> input: error calculation methodprotected FWSimVariable<Integer> input: number of variable pairsprotected ArrayList<FWSimVariable<Double>> inputs: weights of the variable pairsprotected ErrorCalculationMethod[]error calculator per variable pairprotected FWSimVariable<String> output: name of the error calculation methodprotected FWSimVariable<Double> output: error of the selected simulationprotected FWSimVariable<Double[]> output: errors of all simulationsprotected ArrayList<FWSimVariable<Double[]>> outputs: errors of all simulations per variable pairprotected ArrayList<FWSimVariable<String>> inputs: observed variablesprotected ArrayList<FWSimVariable<String>> inputs: simulated variablesprotected intmaximum number of variable pairs (20, or 1 if set beforecreateVariables())protected intnumber of variable pairs usedprotected FWSimVariable<Integer> output: number of compared simulationsprotected doublesum of the weightsFields inherited from class FWSimulationSelector
iFrequence, iGlobalModeSimulationIDMap, iSelectStatementFields inherited from class FWSimulationControlContainer
iCache, iCals, iConstraint, iContainerElement, iControlMap, iFieldMap, iIdentifier, iInputMap, iInputs, iName, iParams, iSession, iSimulationMap -
Constructor Summary
ConstructorsConstructorDescriptionWeightedLeastDifferenceSelector(org.jdom2.Element aSimulationSelectorElement, FWSimSession aSession) -
Method Summary
Modifier and TypeMethodDescriptionHashMap<String, FWSimVariable<?>> Creates the inputs (cNumberOfVariables,cMode, andcObserved{i},cSimulated{i},cWeight{i}per pair) and the outputs.voidinit()Takes over the inputs: the number of pairs (at most the maximum), the variables and weights (a non-positive sum of weights is replaced by 1) and the error method.protected voidReads the data of the iteration row by row (ordered by simulation), accumulates the error of each variable pair per simulation, calculates the weighted error of each simulation and selects the best simulation (per project in INDIVIDUAL mode, over all projects in GLOBAL mode).Methods inherited from class FWSimulationSelector
createSelectStatement, createSimulationSelector, createSimulationSelector, selectSimulationsMethods inherited from class FWSimulationControlContainer
addProcessTime, addVariable, checkCondition, evaluate, getContentType, getCreateFormXML, getEditFormXML, getFieldMap, getFrequence, getInputVariables, getName, getOrderNumber, getOutputVariables, getVariable, getVarMap, isConditionCheck, readInputCalAndConstraint, removeVariable, setPropertyValue, toXML
-
Field Details
-
maxnumber
protected int maxnumbermaximum number of variable pairs (20, or 1 if set beforecreateVariables()) -
number
protected int numbernumber of variable pairs used -
weightsum
protected double weightsumsum of the weights -
cNumberOfVariables
input: number of variable pairs -
iObserved
inputs: observed variables -
iSimulated
inputs: simulated variables -
cWeight
inputs: weights of the variable pairs -
cMode
input: error calculation method -
NumberOfValues
output: number of compared simulations -
ErrorValue
output: error of the selected simulation -
ErrorValues
output: errors of all simulations -
IndividualErrorValues
outputs: errors of all simulations per variable pair -
ErrorMethod
output: name of the error calculation method -
errorCalculator
error calculator per variable pair
-
-
Constructor Details
-
WeightedLeastDifferenceSelector
public WeightedLeastDifferenceSelector(org.jdom2.Element aSimulationSelectorElement, FWSimSession aSession) - Parameters:
aSimulationSelectorElement- theselectorelementaSession- the session
-
-
Method Details
-
createVariables
Creates the inputs (cNumberOfVariables,cMode, andcObserved{i},cSimulated{i},cWeight{i}per pair) and the outputs.- Returns:
- the variables, keyed by name
- See Also:
-
init
public void init()Takes over the inputs: the number of pairs (at most the maximum), the variables and weights (a non-positive sum of weights is replaced by 1) and the error method.- Specified by:
initin classFWSimulationControlContainer
-
select
Reads the data of the iteration row by row (ordered by simulation), accumulates the error of each variable pair per simulation, calculates the weighted error of each simulation and selects the best simulation (per project in INDIVIDUAL mode, over all projects in GLOBAL mode). The outputs are set and the selected simulation id is appended to the selected simulations.- Specified by:
selectin classFWSimulationSelector- Parameters:
aResultSet- the data of the iteration (must not benull)
-