Formula

Formula

Computes result by evaluating the specified formula. Can access child generators with generator[index].

Attributes
Name Description Required Min Max Allowed Values
seed Random number generator seed of this Element. Overrides default seeding behavior. no 0 1
name (Class)Name of this element. Used to identify plugin Class. Full name is required. Example: com.en.myPluginPackage.myPuginClass no 0 1
id Identification String of this element. May be used to uniquely identify a field within the children of an Element. no 0 1
ignoreInvalidValues tells this generator to ignore invalid values from other generators. Instead of throwing an exception, the invalid value for generator[] is to: Double.NaN no 0 1
  • true
  • false
  • 0
  • 1
Nodes
Name Description Required Min Max Allowed Values
staticValue Content type: Java code
Here you can specify static values to be available to use. Especially useful if "heavy initalization" should be avoided for every generated dataset.
Example: <staticValue>new int{1,2,3,4,5}</staticValue>
no 0 1
format no 0 1
formula Content type: Java code
The formula to evaluate. Example: (300 * ( generator[1] + 4 ))/ generator[0]. Any number of sub-generator nodes may be specified within the Formula which can be accessed in the formula. If the formula contains characters of the xml structure (like '<', '>', ...), the formula has to be wrapped into '<![CDATA[ ... ]]'.
yes 1 1
locale Content type: String
Locale to use. A locale defines the formatting rules for numbers, e.g what symbol to use as the decimal point and the thousand separator.
Examples: 'en-US', 'en-GB'. 'de-DE'
'Default is: 'us'
no 0 1
  • und
  • ar-AE
  • ar-JO
  • ar-SY
  • hr-HR
  • fr-BE
  • es-PA
  • mt-MT
  • es-VE
  • bg
  • zh-TW
  • it
  • ko
  • uk
  • lv
  • da-DK
  • es-PR
  • vi-VN
  • en-US
  • sr-ME
  • sv-SE
  • es-BO
  • en-SG
  • ar-BH
  • pt
  • ar-SA
  • sk
  • ar-YE
  • hi-IN
  • ga
  • en-MT
  • fi-FI
  • et
  • sv
  • cs
  • sr-Latn-BA
  • el
  • uk-UA
  • hu
  • fr-CH
  • id
  • es-AR
  • ar-EG
  • ja-JP-u-ca-japanese-x-lvariant-JP
  • es-SV
  • pt-BR
  • be
  • is-IS
  • cs-CZ
  • es
  • pl-PL
  • tr
  • ca-ES
  • sr-CS
  • ms-MY
  • hr
  • lt
  • es-ES
  • es-CO
  • bg-BG
  • sq
  • fr
  • ja
  • sr-BA
  • is
  • es-PY
  • de
  • es-EC
  • es-US
  • ar-SD
  • en
  • ro-RO
  • en-PH
  • ca
  • ar-TN
  • sr-Latn-ME
  • es-GT
  • sl
  • ko-KR
  • el-CY
  • es-MX
  • ru-RU
  • es-HN
  • zh-HK
  • nn-NO
  • hu-HU
  • th-TH
  • ar-IQ
  • es-CL
  • fi
  • ar-MA
  • ga-IE
  • mk
  • tr-TR
  • et-EE
  • ar-QA
  • sr-Latn
  • pt-PT
  • fr-LU
  • ar-OM
  • th
  • sq-AL
  • es-DO
  • es-CU
  • ar
  • ru
  • en-NZ
  • sr-RS
  • de-CH
  • es-UY
  • ms
  • el-GR
  • he-IL
  • en-ZA
  • th-TH-u-nu-thai-x-lvariant-TH
  • hi
  • fr-FR
  • de-AT
  • nl
  • no-NO
  • en-AU
  • vi
  • nl-NL
  • fr-CA
  • lv-LV
  • de-LU
  • es-CR
  • ar-KW
  • sr
  • ar-LY
  • mt
  • it-CH
  • da
  • de-DE
  • ar-DZ
  • sk-SK
  • lt-LT
  • it-IT
  • en-IE
  • zh-SG
  • ro
  • en-CA
  • nl-BE
  • no
  • pl
  • zh-CN
  • ja-JP
  • de-GR
  • sr-Latn-RS
  • he
  • en-IN
  • ar-LB
  • es-NI
  • zh
  • mk-MK
  • be-BY
  • sl-SI
  • es-PE
  • id-ID
  • en-GB
decimalPlaces Content type: Integer
Used to specify the precision of the calculation result.
Example: calculation raw result 3.644345345;
decimalPlaces<0: result -> 3.644345345 //unmodified (default)
decimalPlaces=2: result -> 3.64
decimalPlaces=3: result -> 3.642
decimalPlaces=36 <-max precision
Default: -1
no 0 1
gen Value Generator for this field no 0
  • pdgf.generator.MarkovChainText
  • pdgf.generator.AsReferenceChoice
  • pdgf.generator.WeightedListItem
  • pdgf.generator.DetailFromDate
  • pdgf.generator.BuildList
  • pdgf.generator.InsertIntoString
  • pdgf.generator.UUID
  • pdgf.generator.Probability
  • pdgf.generator.RandomString
  • pdgf.generator.Sequential
  • pdgf.generator.ConvertNumberToString
  • pdgf.generator.WeightedSubListItem
  • pdgf.generator.RandomListItems
  • pdgf.generator.Email
  • pdgf.generator.ActionDeleteIsAlsoUpdate
  • pdgf.generator.DoubleNumber
  • pdgf.generator.Permutation
  • pdgf.generator.Switch
  • pdgf.generator.ReferenceValue
  • pdgf.generator.ForFormula
  • pdgf.generator.PrePostfix
  • pdgf.generator.StaticValue
  • pdgf.generator.Hash
  • pdgf.generator.Padding
  • pdgf.generator.FormatString
  • pdgf.generator.DateTime
  • pdgf.generator.Id
  • pdgf.generator.LastChoice
  • pdgf.generator.MaskString
  • pdgf.generator.Null
  • pdgf.generator.AddRandomSeconds
  • pdgf.generator.RandomStringInRange
  • pdgf.generator.Formula
  • pdgf.generator.AbstractDecimal
  • pdgf.generator.FormatFloatingPoint
  • pdgf.generator.OtherFieldValue
  • pdgf.generator.RandomSentence
  • pdgf.generator.FormatNumber
  • pdgf.generator.Template
  • pdgf.generator.BigBenchReview
  • pdgf.generator.UpperLowerCase
  • pdgf.generator.For
  • pdgf.generator.Relative
  • pdgf.generator.RandomUniqeString
  • pdgf.generator.PermutationReference
  • pdgf.generator.UpdateActionType
  • pdgf.generator.FormatNumberAsDate
  • pdgf.generator.OldReferenceGeneratorDeprecated
  • pdgf.generator.DictList
  • pdgf.generator.ExtendedFormula
  • pdgf.generator.FormatDateAsNumber
  • pdgf.generator.If
  • pdgf.generator.GlobalRowNumber
  • pdgf.generator.LongNumber
  • pdgf.generator.UnsafeDistinct
Sub-Attributes
Parent Name Description Required Min Max Allowed Values
staticValue unlockFullAccess Content type: Boolean
Omits complexity restriction. This allows to enter ';' into the formula and staticValue elements to be able to enter multiple commands into one line.
no 0 1
  • true
  • false
  • 0
  • 1
decimalPlaces roundingMode Content type: String
Sets the rounding mode used to round numbers.
Default: HALF_EVEN
Possible values: [UP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY]
no 0 1
  • UP
  • DOWN
  • CEILING
  • FLOOR
  • HALF_UP
  • HALF_DOWN
  • HALF_EVEN
  • UNNECESSARY
decimalPlaces roundPlainValue Content type: Boolean
Round generated raw value to specified 'decimalPlaces'
If true : other generators will work with the rounded value.
If false: still round the value during 'toString()' but retain full precision for other generators using this generator's output, e.g., by reference or another computational generator.
Only available if 'decimalPlaces' parameter is >=0.
Default: true
no 0 1
  • true
  • false
  • 0
  • 1
formula unlockFullAccess Content type: Boolean
Omits complexity restriction. This allows to enter ';' into the formula and staticValue elements to be able to enter multiple commands into one line.
no 0 1
  • true
  • false
  • 0
  • 1

Examples

  1. Constant Formula

    Evaluates a constant formula and cuts of the redundant decimal part.

    Schema config for Constant Formula
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="FORMULAE">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Constant Formula-->
          <!--Evaluates a constant formula and cuts of the redundant decimal part.-->
          <field name="formula" size="" type="NUMERIC">
            <gen_Formula>
              <formula>1 + 2 + 3</formula>
              <decimalPlaces>0</decimalPlaces>
            </gen_Formula>
          </field>
          </table>
    </schema>
    
    Output for Constant Formula
    6
    6
    6
    6
    6
    6
    6
    6
    6
    6
  2. Linear Formula

    Generates the results for y=ax+b, where a is 2 and b is 5, for n in [0..n].

    Schema config for Linear Formula
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="FORMULAE">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Linear Formula-->
          <!--Generates the results for y=ax+b, where a is 2 and b is 5, for n in [0..n].-->
          <field name="linear_formula" size="" type="NUMERIC">
            <gen_Formula>
              <formula>2 * generator[0] + 5</formula>
              <gen_Id>
                <min>0</min>
              </gen_Id>
            </gen_Formula>
          </field>
          </table>
    </schema>
    
    Output for Linear Formula
    5.0
    7.0
    9.0
    11.0
    13.0
    15.0
    17.0
    19.0
    21.0
    23.0
  3. Random Formula

    Generates values starting from 1 and going in 1/3 steps. The result is randomly signed, rounded to the first decimal places, and formatted according to the en-US locale.

    Schema config for Random Formula
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="FORMULAE">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Random Formula-->
          <!--
            Generates values starting from 1 and going in 1/3 steps. The result is randomly signed, rounded to the first
            decimal places, and formatted according to the en-US locale.
          -->
          <field name="random_formula" size="" type="NUMERIC">
            <gen_Formula>
              <!-- sign -->
              <gen_Probability>
                <!-- -1 (negative) -->
                <probability value="0.50">
                  <gen_StaticValue>
                    <value>-1</value>
                  </gen_StaticValue>
                </probability>
    
                <!-- 1 (neutral) -->
                <probability value="0.50">
                  <gen_StaticValue>
                    <value>1</value>
                  </gen_StaticValue>
                </probability>
              </gen_Probability>
    
               <!--factors [0..n] -->
              <gen_Id>
                <min>0</min>
              </gen_Id>
    
               <!--sign * (1 + factor/3) -->
              <formula>generator[0] * (generator[1] / 3 + 1)</formula>
              <format>#.000</format>
              <locale>en-US</locale>
            </gen_Formula>
          </field>
          </table>
    </schema>
    
    Output for Random Formula
    1.000
    -1.333
    1.667
    -2.000
    2.333
    2.667
    3.000
    -3.333
    3.667
    -4.000
2.6_#1486_b758 | 2016-05-24