Operators: Difference between revisions

From ASCEND
Jump to navigation Jump to search
Created page with "There are a number of operators available in the ASCEND language. == Declarative operators == The following operators apply in the declarative section of a MODEL: {| cl..."
 
Line 10: Line 10:
! operator !! usage
! operator !! usage
|-
|-
! = || equation, constraint (define an equation)
| = || equation, constraint (define an equation)
|-
|-
! < || less-than (not supported by many solvers yet -- possibly just [[IPOPT]]?)
| < || less-than (not supported by many solvers yet -- possibly just [[IPOPT]]?)
|-
|-
! > || greater-than (not supported by many solvers yet)
| > || greater-than (not supported by many solvers yet)
|-
|-
! >= || greater-than-or-equal (not supported by many solvers yet)
| >= || greater-than-or-equal (not supported by many solvers yet)
|-
|-
! <= || less-than-or-equal (not supported by many solvers yet)
| <= || less-than-or-equal (not supported by many solvers yet)
|-
|-
! <> || not-equal (not supported by any(?) solvers yet)
| <> || not-equal (not supported by any(?) solvers yet)
|-
|-
! . || member operator (eg to access variables belongin to a sub-model). The dot is used, as in PASCAL and C, to construct the names of nested objects. Examples: if object a has a part b, then the way to refer to b is as a.b. Tray[1].vle shows a dot following a square bracket; here Tray[1] has a part named vle.
| . || member operator (eg to access variables belongin to a sub-model). The dot is used, as in PASCAL and C, to construct the names of nested objects. Examples: if object a has a part b, then the way to refer to b is as a.b. Tray[1].vle shows a dot following a square bracket; here Tray[1] has a part named vle.
|-
|-
! .. || range operator (see [[Arrays and sets]]). Dot-dot or double dot. Integer range shorthand. For example, my_integer_set :== [1,2,3] and my_integer_set :== [1..3] are equivalent. If .. appears in a context requiring (), such as the ALIASES/IS_A statement, then the range is expanded and ordered as we would naturally expect.  
| .. || range operator (see [[Arrays and sets]]). Dot-dot or double dot. Integer range shorthand. For example, my_integer_set :== [1,2,3] and my_integer_set :== [1..3] are equivalent. If .. appears in a context requiring (), such as the ALIASES/IS_A statement, then the range is expanded and ordered as we would naturally expect.  
|-
|-
! <tt>:==</tt> || constant and set assignment. Both constants and sets are calculated during the instantiation process and after that can't be changed. This operator distinguishes definition of immutable values from those of mutable ones.
| <tt>:==</tt> || constant and set assignment. Both constants and sets are calculated during the instantiation process and after that can't be changed. This operator distinguishes definition of immutable values from those of mutable ones.
|-
|-
! <tt>==</tt> || logical equality.  
| <tt>==</tt> || logical equality.  
|-
|-
! <tt>!=</tt> || logical inequality.  
| <tt>!=</tt> || logical inequality.  
|-
|-
! <tt>+</tt> || plus. Numerical addition or set union.
| <tt>+</tt> || plus. Numerical addition or set union.
|-
|-
! <tt>-</tt> minus. Numerical subtraction or set difference.
| <tt>-</tt> minus. Numerical subtraction or set difference.
|-
|-
! <tt>*</tt> || times. Numerical multiplication or set intersection.
| <tt>*</tt> || times. Numerical multiplication or set intersection.
|-
|-
! <tt>/</tt> || divide. Numeric division. In most cases it implies real division and not integer
| <tt>/</tt> || divide. Numeric division. In most cases it implies real division and not integer
  division.
  division.
|-
|-
! <tt>^</tt> || power. Numeric exponentiation. If the value of y in x^y is not integer, then x must be greater than 0.0 and dimensionless.
| <tt>^</tt> || power. Numeric exponentiation. If the value of y in x^y is not integer, then x must be greater than 0.0 and dimensionless.
|-
|-
! <tt>-</tt> negative (unary operator).
| <tt>-</tt> negative (unary operator).
|-
|-
! <tt><nowiki>|</nowiki></tt> [[SUCH_THAT]] alias.
| <tt><nowiki>|</nowiki></tt> || [[SUCH_THAT]] alias.
|}
|}



Revision as of 09:24, 2 October 2012

There are a number of operators available in the ASCEND language.

Declarative operators

The following operators apply in the declarative section of a MODEL:

Declarative operators
operator usage
= equation, constraint (define an equation)
< less-than (not supported by many solvers yet -- possibly just IPOPT?)
> greater-than (not supported by many solvers yet)
>= greater-than-or-equal (not supported by many solvers yet)
<= less-than-or-equal (not supported by many solvers yet)
<> not-equal (not supported by any(?) solvers yet)
. member operator (eg to access variables belongin to a sub-model). The dot is used, as in PASCAL and C, to construct the names of nested objects. Examples: if object a has a part b, then the way to refer to b is as a.b. Tray[1].vle shows a dot following a square bracket; here Tray[1] has a part named vle.
.. range operator (see Arrays and sets). Dot-dot or double dot. Integer range shorthand. For example, my_integer_set :== [1,2,3] and my_integer_set :== [1..3] are equivalent. If .. appears in a context requiring (), such as the ALIASES/IS_A statement, then the range is expanded and ordered as we would naturally expect.
:== constant and set assignment. Both constants and sets are calculated during the instantiation process and after that can't be changed. This operator distinguishes definition of immutable values from those of mutable ones.
== logical equality.
!= logical inequality.
+ plus. Numerical addition or set union.
- minus. Numerical subtraction or set difference.
* times. Numerical multiplication or set intersection.
/ divide. Numeric division. In most cases it implies real division and not integer
division.
^ power. Numeric exponentiation. If the value of y in x^y is not integer, then x must be greater than 0.0 and dimensionless.
- negative (unary operator).
| SUCH_THAT alias.

Procedural section

The following operators can be used within METHODs:

Procedura operators
operator usage
:= value assignment (can also be part of a FIX statement)