3.2 Symbolic expressions

Symbolic expression is a rule for computing a single symbolic value represented in the form of character string.

The primary symbolic expression may be a string literal, dummy index, unsubscripted parameter, subscripted parameter, built-in function reference, conditional symbolic expression, or another symbolic expression enclosed in parentheses.

It is also allowed to use a numeric expression as the primary symbolic expression, in which case the resultant value of the numeric expression is automatically converted to the symbolic type.


'May 2003'(string literal)
j(dummy index)
p(unsubscripted parameter)
s['abc',j+1](subscripted parameter)
substr(name[i],k+1,3)(function reference)
if i in I then s[i,j] else t[i+1](conditional expression)
((10 * b[i,j]) & '.bis')(parenthesized expression)

More general symbolic expressions containing two or more primary symbolic expressions may be constructed by using the concatenation operator.


'abc[' & i & ',' & j & ']'
"from " & city[i] & " to " & city[j]

The principles of evaluation of symbolic expressions are completely analogous to that ones given for numeric expressions (see above).

Function references

In MathProg there are the following built-in functions which may be used in symbolic expressions:

substr(xy)substring of x starting from position y
substr(x, y, z)substring of x starting from position y and having length z
time2str(t, f)converting calendar time to character string4

The first argument of substr must be a symbolic expression while its second and optional third arguments must be numeric expressions.

The first argument of time2str must be a numeric expression, and its second argument must be a symbolic expression.

The resultant value of the symbolic expression, which is a function reference, is the result of applying the function to its arguments.

Symbolic operators

Currently in MathProg there is the only symbolic operator:

x & y

where x and y are symbolic expressions. This operator means concatenation of its two symbolic operands, which are character strings.

Hierarchy of operations

The following list shows the hierarchy of operations in symbolic expressions:

Evaluation of numeric operations1st-7th
Concatenation (&)8th
Conditional evaluation (if $\dots$ then $\dots$ else)9th

This hierarchy has the same meaning as explained in Section “Numeric expressions”.



For details see See Converting calendar time to character string.