Klasse FunctionValueFromTable
- Alle implementierten Schnittstellen:
net.simplace.sim.util.FWSimFieldContainer
Description
A function y=f(x) can be defined by giving tables for the x and y values.
This component takes as parameters the x-table and y-table as well as the x value. It outputs the calculated y value for the given x value.
The types of x and y can be DOUBLE, INT or CHAR. Depending on the types, there are different options to calculate y.
- If x is CHAR, then a lookup is performed
- If x is numeric (DOUBLE or INT) and y is CHAR, then beside lookup also constant interpolation is available.
- If x and y are numeric, then beside lookup and constant interpolation there is also linear interpolation available.
There are additional options to configure the component
- if extrapolation should be performed (numeric x)
- if the last position in the x-table should be cached (improves speed if x values vary slowly)
- if y is numeric, then a scaling factor can be given
More details
We consider functions
\[ f : \mathbb{X} \rightarrow \mathbb{Y} \]where the domain $\mathbb{X}$ and range/image $\mathbb{Y}$ can be intervals of real numbers $I \subseteq \mathbb{R}$ or integer numbers $I\subseteq\mathbb{Z}$ or a finit sets $S=\{a_i \in \mathcal{A} | i=1 .. n \in \mathbb{N}\}$.
Technically real numbers are represented by Double values (DOUBLE in the framework context), integer numbers by Integer (INT) and the set elements $a_i$ can be real numbers ($a_i \in \mathbb{R}$), integers ($a_i \in \mathbb{Z}$) or Strings ('CHAR').
The functions are defined by two tables $T_X = {x_i \in \mathbb{X} | i = 1..n}$ and $T_Y = {y_i \in \mathbb{Y} | i = 1..n}$.
If the domain $\mathbb{X}$ is a finite set, then
\[ f(x_i):=y_i \quad\quad \text{(interpolation method NONE)} \]If the domain $\mathbb{X}$ is a real or integer interval and the range is a finite set, then there are three different options to define $f$.
\[ f(x) := y_{i-1} \text{ if } x_{i-1} \lt x \leq x_{i} \quad\quad \text{(CONSTANT_LEFT)} \] \[ f(x) := \begin{cases}{y_{i-1} \text{ if } \frac{x_i - x_{i-1}}{2} \leq x \lt x_{i}\\y_{i} \text{ if } x_i \leq x \lt \frac{x_{i+1}-x_i}{2}}\end{cases} \quad\quad \text{(CONSTANT_MID)} \] \[ f(x) := y_{i} \text{ if } x_{i} \leq x \lt x_{i+1} \quad\quad \text{(CONSTANT_RIGHT)} \]If both domain and range are intervals, then the values are linearly interpolated
\[ f(x) := y_i + \frac{y_{i+1}-y_i}{x_{i+1}-x_i}(x_{i+1}-x) \text{ if } x_i \leq x \lt x_{i+1} \quad\quad \text{(LINEAR)} \]If the user choses to extrapolate the function for values outside the interval $[x_1,x_n]$ then $f(x):=y_1$ for $x \lt x_1$ and $f(x) := y_n$ for $x_n \lt x$.
Notice: as finite sets can consist of number (real or integer) too, one can't infer from the datatype if it should be a finite set or a numeric interval. Therefore the user has to give the interpolation method explicitely.
Configuration, inputs
The sim component needs exactly one of the tables cXValuesDouble (DOUBLEARRAY), cXValuesInt (INTARRAY) or cXValuesChar (CHARARRAY).
It needs at least one of cYValuesDouble (DOUBLEARRAY), cYValuesInt (INTARRAY), cYValuesChar (CHARARRAY).
It needs exaxtly one of the variables iXDouble, iXInt or iXChar. It outputs then at least one of the calculated YDouble, YInt or YChar (depending which of the y-tables are given).
Interpolation method can be defined by setting cMethod to one of NONE, CONSTANT_LEFT,`CONSTANT_MID`, CONSTANT_RIGHT or LINEAR. Setting cExtrapolate to true/`false` will en-/disable extrapolation. If disabled, null will be returned for values outside the range.
cUseCaching determines whether the index in the x-table of the previous function evaluation is stored. If not stored, then the routine will always start at the beginning of the x-table until it reaches the values it sits inbetween. If the x values vary slowly from day to day (e.g. DVS), then storing the last index will improve the speed.
- Autor:
- Gunther Krauss, gk@uni-bonn.de
- Siehe auch:
Component Variables
| Content Type | Name | Description | Data Type | Unit | Min Value | Max Value | Default Value |
|---|---|---|---|---|---|---|---|
| constant | cExtrapolate | If true, then numeric x values outside the range will give the first (x smaller) or the last (x bigger) y value | BOOLEAN | - | - | true | |
| constant | cMethod | Interpolation method, one of 'NONE' (only lookup), 'CONSTANT_LEFT', 'CONSTANT_MID', 'CONSTANT_RIGHT' or 'LINEAR' | CHAR | - | - | LINEAR | |
| constant | cScaleValue | Value that will be multiplied with the function value | DOUBLE | - | - | 1.0 | |
| constant | cUseCaching | If the index of the previous calculation should be stored. Can improve speed, if x values vary slowly. | BOOLEAN | - | - | true | |
| constant | cXValuesChar | X-Values of the function table - strings, categorical values | CHARARRAY | - | - | - | |
| constant | cXValuesDouble | X-Values of the function table - real numbers | DOUBLEARRAY | - | - | - | |
| constant | cXValuesInt | X-Values of the function table - integer numbers | INTARRAY | - | - | - | |
| constant | cYValuesChar | Y-Values of the function table - strings, categorical values | CHARARRAY | - | - | - | |
| constant | cYValuesDouble | Y-Values of the function table - real numbers | DOUBLEARRAY | - | - | - | |
| constant | cYValuesInt | Y-Values of the function table - integer numbers | INTARRAY | - | - | - | |
| input | iXChar | x value (string/categorical) value to look up | CHAR | - | - | ||
| input | iXDouble | x value (real) to calculate y=f(x) | DOUBLE | - | - | 0.0 | |
| input | iXInt | x value (integer) value to calculate | INT | - | - | 0 | |
| out | YChar | Calculated string/categorical value at iX | CHAR | - | - | - | |
| out | YDouble | Calculated real value at iX | DOUBLE | - | - | - | |
| out | YInt | Calculated integer value at iX | INT | - | - | - |
-
Verschachtelte Klassen - Übersicht
Von Klasse geerbte verschachtelte Klassen/Schnittstellen net.simplace.sim.model.FWSimComponent
net.simplace.sim.model.FWSimComponent.TEST_STATE -
Feldübersicht
Von Klasse geerbte Felder net.simplace.sim.model.FWSimComponent
iFieldMap, iFrequence, iInputMap, iJexlRule, iMasterComponentGroup, iName, iOrderNumber, isComponentGroup, iSimComponentElement, iSimModel, iVarMap -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected net.simplace.sim.model.FWSimComponentclone(net.simplace.sim.util.FWSimVarMap aVarMap) Create the FWSimVariables as interface for this SimComponentfillTestVariables(int aParamIndex, net.simplace.sim.model.FWSimComponent.TEST_STATE aDefineOrCheck) called for single component test to check the components algorithm.protected voidinit()Initializes the fields by getting input and output FWSimVariables from VarMapprotected voidprocess()Process the algorithm and write the results back to VarMapVon Klasse geerbte Methoden net.simplace.sim.model.FWSimComponent
addVariable, bind, checkCondition, createSimComponent, createSimComponent, createSimComponent, createSimComponent, doProcess, getConstantVariables, getContentType, getCreateFormXML, getDescription, getEditFormXML, getFieldMap, getFrequence, getFrequenceRuleScript, getInputs, getInputVariables, getMasterComponentGroup, getName, getOrderNumber, getOutputVariables, getVariable, getVariableField, getVarMap, initialize, isConditionCheck, isVariableAvailable, performLinks, performLinks, readInputs, removeVariable, reset, runComponentTest, setVariablesDefault, toComponentLinkingXML, toDocXML, toGroupXML, toOutputDefinitionXML, toResourcesDataXML, toResourcesDefinitionXML, toString, toXML, writeVarInfos
-
Konstruktordetails
-
FunctionValueFromTable
public FunctionValueFromTable()Empty constructor used by class.forName()
-
-
Methodendetails
-
createVariables
Create the FWSimVariables as interface for this SimComponent- Angegeben von:
createVariablesin Schnittstellenet.simplace.sim.util.FWSimFieldContainer- Angegeben von:
createVariablesin Klassenet.simplace.sim.model.FWSimComponent- Siehe auch:
-
init
protected void init()Initializes the fields by getting input and output FWSimVariables from VarMap- Angegeben von:
initin Klassenet.simplace.sim.model.FWSimComponent- Siehe auch:
-
process
protected void process()Process the algorithm and write the results back to VarMap- Angegeben von:
processin Klassenet.simplace.sim.model.FWSimComponent- Siehe auch:
-
fillTestVariables
public HashMap<String,net.simplace.sim.util.FWSimVariable<?>> fillTestVariables(int aParamIndex, net.simplace.sim.model.FWSimComponent.TEST_STATE aDefineOrCheck) called for single component test to check the components algorithm.- Angegeben von:
fillTestVariablesin Klassenet.simplace.sim.model.FWSimComponent- Siehe auch:
-
clone
protected net.simplace.sim.model.FWSimComponent clone(net.simplace.sim.util.FWSimVarMap aVarMap) - Angegeben von:
clonein Klassenet.simplace.sim.model.FWSimComponent- Siehe auch:
-