(Deprecated) Defining global entity aggregates

You define a global entity aggregate by specifying an aggregate expression, an evaluation schedule, and an optional default value.

Before you begin

Create a global aggregate definition file (.agg).

About this task

A global entity aggregate can find the total, minimum, maximum, or average value of a collection of entities and their attributes, as well as the number of entities. For example, if your business model has aircraft entities, you can determine the average load of all the aircraft and evaluate that average daily.

The calculations are launched according to the schedule and are run as batch jobs that occur in each of the nodes of your solution. The results from the individual partitions are therefore not initially consistent. Over time, however, a feedback mechanism ensures that the results become consistent.

You define a global entity aggregate by composing an expression that specifies a schedule in the .agg file and that has the following syntax:
define '<same_name_as_file>' as <expr>

An expression can reference a related entity, but the processing time might increase substantially.

If only a few entities exist, a global entity aggregate might not have a meaningful value. Therefore, you can specify a default value and the condition for when the default applies. The default value applies unless enough entities exist for the aggregate calculations, and any rules that are based on them, to have meaningful results. You might need to test and experiment with the default value and the condition to obtain optimal results for your particular solution.

In the editor, you can type Space or Ctrl+Space to display the available constructs, and then double-click a construct to select it.

Procedure

  1. Specify the name of the variable. You can overwrite the default, which is the same name as the .agg file.
  2. Replace <expr> with an aggregate expression, an optional default value, and a schedule:
    1. Specify an aggregation operator or the number of construct.
    2. Specify an attribute of an entity or a related entity.
    3. Optional: Specify a time filter to restrict the entity to a specific time period, and specify a where clause to restrict the entities with a condition.
    4. Add a comma.
    5. Optional: Specify a default value phrase and condition, followed by a comma.
    6. Specify an evaluation schedule.
  3. Click Save.

Results

The global aggregate is verbalized and you can use its variable name in rules and Java™ agents in your solution. In a Java agent and in the REST API, you must prefix defvar to the variable name.

Attention: You can view a summary of the global aggregates in the globalQueries.var variable set file, which is in the aggregates folder of the BOM project. Do not change the content of the file because your changes to it are not saved.

Examples

Consider the following definition of a global entity aggregate:
define 'average_capacity' as the average business class capacity of all aircraft,
	evaluated daily at 2:00 PM

This statement defines the variable average_capacity, which can then be used in the rules in a solution. The calculation is run every day at the specified time to account for periodic changes to entities in the model. At each node, a local average is calculated, and the partial results are aggregated across the data grid to obtain the overall average capacity.

A global entity aggregate can reference an entity that is related to another entity, such as in the following example:
define 'numAvailTerminalsOfAllFlights' as the total available terminals of the destination airports of all flights, 
	 evaluated every day at 3:00 PM
The following definition of a global entity aggregate includes a default value and condition, and evaluates the average capacity every 24 hours:
define 'average_capacity' as the average business class capacity of all aircraft, defaulting to 50 if there are less than 5 aircraft,
	evaluated at intervals of 24 hours