Each operator in an expression must be appropriate for the types of its operands. For instance, it is invalid for G2 to combine an arithmetic operator with an operand that does not produce a value of type
integer or float. G2 offers these operators:
quantity, integer, and float
and, or, and not for operands that produce values of type truth-value
quantity, integer, float, and text: equal to, not equal to, greater than, greater than or equal to, less than, and less than or equal to
symbol: equal to and not equal to
truth-value: equal to, not equal to, is less true than, is more true than, is not less true than, and is not more true than
| Reserved Character | Arithmetic Operation |
|---|---|
|
- (hyphen)
|
Negation
|
|
+ (plus)
|
Addition
|
|
- (hyphen)
|
Subtraction
|
|
* (asterisk)
|
Multiplication
|
|
/ (forward slash)
|
Division
|
|
^ (caret)
|
Exponentiation
|
Tip: For G2 to interpret the - (hyphen) character as an operator, rather than as a character in a symbol, include at least one space before and after it.
Identifying the Default Order of Evaluation
By default, G2 evaluates an expression with an arithmetic operator from left to right. For example, G2 evaluates this expression:
W * X - Y + Z
W * ( X - Y ) + Z
| Precedence | Reserved Character | Arithmetic Operation(s) |
|---|---|---|
|
1
|
-
|
Negation
|
|
2
|
^
|
Exponentiation
|
|
3
|
* and /
|
Multiplication and division
|
|
4
|
+ and -
|
Addition and subtraction
|
For example, in this expression:
W + X * Y + Z
W + (X * Y) + Z
Constraints on Exponentiation Operations
G2 disallows certain values to participate in an exponentiation operation, as follows:
truth-value, as summarized in this table:
An expression that includes a logical operator produces a value of type
truth-value.
the tank is empty or the input-valve connected to the tank is broken
not valve-is-broken
and and or operators are short-circuited:
and operator's first term evaluates to false, G2 does not evaluate the second term.
or operator's first term evaluates to true, G2 does not evaluate the second term.
and operator, G2 uses the expiration time of the first logical variable whose current value is false.
true, G2 evaluates the entire expression as the truth-value true, and the expiration time for entire expression is the expiration time among those of the operand terms that is nearest into the future from the current time.
false, G2 produces the no value condition for the entire expression, and the expiration time for the entire expression also produces the no value condition.
false, G2 evaluates the entire expression as the truth-value false, and the expiration time of the expression is that of the term that produced false.
or operator, G2 uses the expiration time of the first logical variable whose current value is true.
false, then G2 evaluates the entire expression as the truth-value false, and the expiration time for the entire expression is the expiration time among those of the operand terms that is nearest into the future from the current time.
true, then G2 produces the no value condition for the entire expression, and the expiration time also produces the no value condition.
true, G2 evaluates the entire expression as the truth-value true, and the expiration time of the entire expression is the same as the expiration time of the term that produced true.
Precedence and Order of Evaluation
The precedence for logical operators is as follows:
not
and
or
X and not Y or Z and W
not operator has higher precedence than and, and because the and operator has higher precedence than the or operator, G2 associates the operators and operands as follows:
( X and ( not Y ) ) or ( Z and W )
2 + X > Y and Z > W
( 2 + X > Y ) and ( Z > W )
truth-value. Use these relational operators to compare two terms for which G2 obtains a value of type
quantity, integer, or float:
Use these relational operators to compare two terms for which G2 obtains a value of type
text:
G2 ignores the alphabetic case when comparing two
text values. symbol:
| Reserved Symbols | Relational Operation | Usage |
|---|---|---|
|
=
|
Is equal to
|
A = B
|
|
/=
|
Is not equal to
|
A /= B
|
Use these relational operators to compare a term for which G2 obtains a value of type
symbol with a literal symbol:
| Reserved Symbols | Relational Operation | Usage |
|---|---|---|
is
|
Is the same symbol as
|
A is red
|
is not
|
Is not the same symbol as
|
A is not red
|
Tip: There are corresponding relational operators for fuzzy truth expressions. See the section Fuzzy Truth Operators for more information.
Producing Fuzzy Truth Values From Relational Operations
A truth-value expression that includes a relational operator produces a value of type truth-value. As introduced in Using the Truth-Value Type, a value of type truth-value can range from -1.0 true to +1.0 true, where -1.0 true signifies complete certainty that a comparison is false and +1.0 true signifies complete certainty that a comparison is true. Thus, such an expression can also produce a fuzzy truth value, which signifies a partial certainty in the truth of a comparison.
X < Z ( + - 4 )
the level of tank-1 < 110 ( + - 5 )
(+- quantity-expression)
the flow of pump-1 > 50 ( +- 5 )
( +- 5 ) specifies that the fuzzy truth value produced corresponds to a range of values, from 45 (50 minus 5) to 55 (50 plus 5). That is, as the value of the Flow attribute of pump-1 ranges from 45 to 55, the corresponding fuzzy truth values range from -1.0 true to +1.0 true. Thus, the expression
the flow of pump-1 > 50 ( +- 5 ) has a +1.0 true truth-value when the the flow of pump-1 is 55 or greater, and a -1.0 true truth value when the flow of pump-1 is 45 or less, as shown in the next diagram:
![]() |
As the diagram indicates, the truth-values in the fuzzy-truth band fall along a line between the specified end-points of the band.
Truth-threshold attribute in the Inference Engine Parameters system table. Its value can range from 0.0 to 1.0, and its default value is .800 (or +0.8 true). When G2 invokes a rule, for G2 to execute the actions in the rule's consequent, the truth-value that results from evaluating the rule's antecedent must be greater than or equal to the Truth-threshold.
if the temperature of tank-1 >100 ( +- 2 ) then
conclude that the tank-is-boiling of tank-1 is true
Temperature attribute of tank-1 has a value of 101.8, the subexpression causes the entire truth-value expression to produce the fuzzy truth value of +0.9 true. Because the value +0.9 true is greater than the value of Truth-threshold (that is, +0.8 true), G2 executes the action to conclude the truth-value (+0.9 true) into the Tank-is-boiling attribute of tank-1.
X > Y ( +- 5 ) and Z > W ( +- 3 )
and operator is used, G2 produces the lesser fuzzy truth value as the value of the entire truth-value expression.
or operator is used, G2 produces the greater fuzzy truth value as the value of the entire truth-value expression.
not operator is used, G2 produces the fuzzy truth value with the opposite sign.
and logical operator:
X > Y ( +- 5 ) and Z > W ( +- 3 )
( +- 5 ) to calculate a truth-value for the subexpression X > Y.
( +- 3 ) to calculate a truth-value for the subexpression Z > W.
+0.6 true and the value of the right side is +0.7 true, G2 produces the value +0.6 true for the entire expression.
or logical operator:
X or Y >= W ( +- .3 )
( +- .3 ) to calculate a truth-value for the subexpression Y >= W.
+0.4 true and the value of the right side is +0.9 true, G2 produces the value +0.9 true for the entire expression.
not logical operator:
not ( X > Y ( +- .2 ) )
X > Y ( +- .2 ) evaluates to a fuzzy truth value of +0.3 true, G2 produces the value -0.3 true for the entire truth-value expression.
= (is equal to)
/= (is not equal to)
is more true than
is less true than
is not more true than
is not less true than
true or false. It does not produce a fuzzy truth value. The following truth-value expressions specify both fuzzy truth band subexpressions and fuzzy truth operators. The fuzzy truth operators appear in boldface:
Y < 6 ( +- 3 ) ) /= ( Z > 4 ( +- 2 )
( X < Z ( +- 4 ) ) is less true than ( X > 7 ( +- 2 ) )
the level of tank-1 < 110 ( +- 5 ) )is not more true than
( the level of tank-2 < 120 ( +- 10 )
( X > Y ( +- 2 ) ) is more true than ( Z > X ( +- 3 ) )
text version of any value to a literal text value. To concatenate by inserting, specify a text expression such as:
"The direction of flow for the water-pipe[the public-name of the water-pipe
connected to tank-1]is[the direction-of-flow of the water-pipe
connected to tank-1]."
the public-name of the water-pipe connected to tank-1 to a text value and inserts it into the literal text enclosed in double quotes. Likewise, G2 converts the value produced by the expression the direction-of-flow of the water-pipe connected to tank-1. To concatenate by prepending, specify an expression such as:
"[the public-name of the first alarm in the
master-alarm-list]is ready for your response."
"The sum of the volumes is[the volume of tank-1 +
the spillage-volume of drainage-pipe]."
text value, as in this change the text of action:
change the text of the item-configuration of my-item to
"[the text of the item-configuration of workspace-label-free-text]"
text value any expression specified within the concatenation operator characters.
text value, by pressing Control + j within the two double quotes (") characters that enclose the value. However, including a newline character within the [ and ] concatenation operators only formats that line of code; G2 does not include the newline character in the literal text value. For example, this literal text value includes a newline character after the word "ready":
"[the public-name of the first alarm in the master-alarm-list]is ready
for your response."
"[the public-name of the first alarm in the
master-alarm-list]is ready for your response."
For example, this
inform action embeds a float value (the pressure of the tank) in a literal text value, with the float value formatted with four digits left and right of the decimal point:
if the pressure of any tank has a value
then inform the operator that "Pressure measurement of [the public-name
of T] is [the pressure of the tank as dddd.dddd]."
as {ddd.dddd-format | a time stamp | an interval}
For a float value, a ddd.dddd-format expression specifies the number of digits in the value to display left and right of the decimal point. For instance, the expression
dd.ddd specifies to format a number with two digits left of the decimal point and three digits right of the decimal point. dd.dddddd is 23.2337182e3.
![]() |
inform the operator that
"The last update occurred with a time-stamp of [ the update-time of
my-object as a time stamp ]."
the current time
the current real time
the current subsecond time
the current subsecond real time expression
as time stamp and as interval formatting expressions affect differently the display of the current time and a literal float value.
![]() |