Klasse FunctionValueFromTable

java.lang.Object
net.simplace.sim.model.FWSimComponent
net.simplace.sim.components.util.FunctionValueFromTable
Alle implementierten Schnittstellen:
net.simplace.sim.util.FWSimFieldContainer

public class FunctionValueFromTable extends net.simplace.sim.model.FWSimComponent
Calculate values of a function defined by tables.

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 TypeNameDescriptionData TypeUnitMin ValueMax ValueDefault Value
constantcExtrapolateIf true, then numeric x values outside the range will give the first (x smaller) or the last (x bigger) y valueBOOLEAN--true
constantcMethodInterpolation method, one of 'NONE' (only lookup), 'CONSTANT_LEFT', 'CONSTANT_MID', 'CONSTANT_RIGHT' or 'LINEAR' CHAR--LINEAR
constantcScaleValueValue that will be multiplied with the function valueDOUBLE--1.0
constantcUseCachingIf the index of the previous calculation should be stored. Can improve speed, if x values vary slowly.BOOLEAN--true
constantcXValuesCharX-Values of the function table - strings, categorical valuesCHARARRAY---
constantcXValuesDoubleX-Values of the function table - real numbersDOUBLEARRAY---
constantcXValuesIntX-Values of the function table - integer numbersINTARRAY---
constantcYValuesCharY-Values of the function table - strings, categorical valuesCHARARRAY---
constantcYValuesDoubleY-Values of the function table - real numbersDOUBLEARRAY---
constantcYValuesIntY-Values of the function table - integer numbersINTARRAY---
inputiXCharx value (string/categorical) value to look upCHAR--
inputiXDoublex value (real) to calculate y=f(x)DOUBLE--0.0
inputiXIntx value (integer) value to calculateINT--0
outYCharCalculated string/categorical value at iXCHAR---
outYDoubleCalculated real value at iXDOUBLE---
outYIntCalculated integer value at iXINT---
  • 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
    Konstruktor
    Beschreibung
    Empty constructor used by class.forName()
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    protected net.simplace.sim.model.FWSimComponent
    clone(net.simplace.sim.util.FWSimVarMap aVarMap)
     
    HashMap<String,net.simplace.sim.util.FWSimVariable<?>>
    Create the FWSimVariables as interface for this SimComponent
    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.
    protected void
    Initializes the fields by getting input and output FWSimVariables from VarMap
    protected void
    Process the algorithm and write the results back to VarMap

    Von 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

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Konstruktordetails

    • FunctionValueFromTable

      public FunctionValueFromTable()
      Empty constructor used by class.forName()
  • Methodendetails

    • createVariables

      public HashMap<String,net.simplace.sim.util.FWSimVariable<?>> createVariables()
      Create the FWSimVariables as interface for this SimComponent
      Angegeben von:
      createVariables in Schnittstelle net.simplace.sim.util.FWSimFieldContainer
      Angegeben von:
      createVariables in Klasse net.simplace.sim.model.FWSimComponent
      Siehe auch:
      • FWSimComponent.createVariables()
    • init

      protected void init()
      Initializes the fields by getting input and output FWSimVariables from VarMap
      Angegeben von:
      init in Klasse net.simplace.sim.model.FWSimComponent
      Siehe auch:
      • FWSimComponent.init()
    • process

      protected void process()
      Process the algorithm and write the results back to VarMap
      Angegeben von:
      process in Klasse net.simplace.sim.model.FWSimComponent
      Siehe auch:
      • FWSimComponent.process()
    • 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:
      fillTestVariables in Klasse net.simplace.sim.model.FWSimComponent
      Siehe auch:
      • Ungültige Referenz
        net.simplace.sim.util.FWSimFieldContainer#fillTestVariables(int aParamIndex, TEST_STATE aDefineOrCheck)
    • clone

      protected net.simplace.sim.model.FWSimComponent clone(net.simplace.sim.util.FWSimVarMap aVarMap)
      Angegeben von:
      clone in Klasse net.simplace.sim.model.FWSimComponent
      Siehe auch:
      • FWSimComponent.clone(net.simplace.sim.util.FWSimVarMap)