Expressions

Expressions are specified as abstract syntax trees and are used to describe simple computations for various parameters in a schedule.

The supported nodes are:

  • immediate values (string, numeric, boolean and null)
  • operands (arithmetic, set operators and data)
  • functions

Immediate Values

Immediate values can be specified directly in JSON, for instance "hello" will specify the 'hello' string, 1234 will specify the number one thousand two hundreds and thirty four.

Operands

Operands are specified as JSON object with the following fields:

  • Op is a textual string that specifies the operator, it can be
    • + for addition (param0 + param1 + param2...)
    • - for subtraction (param0 - param1 - param2...)
    • * for multiplication (param0 * param1 * param2...)
    • / for division (param0 / param1 / param2...)
    • max to compute the numeric maximum among param0, param1, param2...
    • min to compute the numeric minimum among param0, param1, param2...
    • data to perform a data lookup
  • P is an array of expressions to be used as parameters for the operator
  • Data is the data field for the data operator, it can be a hierarchical mix of objects and arrays. If the value is a string, then it is assumed to be the name of a DataSet.

This expression is equivalent to a 1 + 2 :

{
   "Op": "+",
   "P": [1, 2]
}

This expression is equivalent to max(10, 20) - 5 :

{
   "Op": "-",
   "P": [
      {
         "Op": "max",
         "P": [10, 20]
      },
      5
   ]
}

This expression evaluates to the hello string :

{
   "Op": "data",
   "P": [0, "h"],
   "Data" : [ { "h" : "hello" }, ["byebye", "ciao"] ]
}

but if P is changed to [1,1] it will evaluate to ciao.

Functions

Functions are specified as JSON object with the following fields:

  • Fn is a textual string that specifies the name of the function
  • P is an array of expressions to be used as parameters for the function

The following functions are supported:

  • ID returns the ID for the contextual entity
  • Attr(attributeIndex) returns the index of the value of the Attribute for the contextual entity
  • LoadAttr(aptitude, attributeIndex) returns the index of the value of the Attribute for the Resources or Workgroup of the Workload of given Aptitude of the contextual Task (invalid if the context is not a Task)
  • LoadResID(aptitude) returns the ID of the Resource or Workgroup of the Workload of given Aptitude of the contextual Task (invalid if the context is not a Task)