GAMSで累乗(冪乗)()を計算する方法。私もルールについてよくわすれるのでメモしておきます。
x**n
これがGAMSにおけるの一つの表現方法であるが、これはが正であるときにしか使えない。が負である
ときに x**n
という表現を利用すると、次のようなエラーが出る。
**** Exec Error at line 14: rPower: FUNC DOMAIN: x**y, x < 0
GAMS User Manual では **
というオペレータについて次のように説明されている。
x**n
is equivalent to the function callrPower(x,y)
and is calculated inside GAMS asexp[n*log(x)]
. This operation is not defined ifx
has a negative value, and an error will result. If the possibility of negative values forx
is to be admitted and the exponent is known to be an integer, then a function call,power(x,n)
, is available.
power(x,n)
x
が負の値をとるときには、power(x,n)
という命令を利用すればよい。ただし、この場合には、n
は整数でなければならない。