GAMS 中的问题(错误 669、8、37、409)

Problems in GAMS (errors 669, 8, 37, 409)

我的代码(与 Matlab 接口)中出现了一些错误,但我无法解决它们。

26  $if exists $ include matdata.gms
****            8

1 - 无法理解此错误,也找不到相关信息。

 58  PiCalc(b,t)..                    Pi(b,t) =e= P(b,t) + c(b,t) - d(b,t);
****                                     ,409

 37  '=l=' or '=e=' or '=g=' operator expected

2 - 我不明白这里的问题是什么,因为我清楚地使用了“=e=”运算符。

59  P_linhaCalc(l,t)..               P_linha(l,t) =e= sum(b, A(l,b)*Pi(b,t));
****                                                                    ,409
 8  ')' expected
 409  Unrecognizable item - skip to find a new statement
       looking for a ';' or a key word to get started again

3 - 同样,我不明白缺少的 ')' 是什么时候出现的。

欢迎任何反馈。

完整代码如下:

** Define the structure to connect with the matlab code
*$onempty
$include matglobs.gms
*$if exists $ include matdata.gms

set      t /1*%timeSteps%/,
         b /1*%bus%/,
         l /1*%lines%/
         ;

Positive Variable d(b,t),
                  c(b,t)
                  ;

Free Variable res;

parameters       size(b), rate(b),lim_linhas(l), P(b,t), A(l,b),
                 cost, soc(b,t),
                 P_linha(l,t),
                 pen, bat(b), preco(t)
                 ;

$if exists $ include matdata.gms

Equations

socCalc1(b,t)
socCalc2(b,t)
maxDischarge(b,t)
maxCharge(b,t)
PiCalc(b,t)
P_linhaCalc(l,t)
penCalc(l,t)
Con10(b)
Con11
Obj
;

socCalc1(b,t)$(ord(t)=1)..      soc(b,t) =e= size(b)/2;
socCalc2(b,t)$(ord(t)>1)..      soc(b,t) =e= soc(b,t-1) + c(b,t) - d(b,t);

maxDischarge(b,t)..              d(b,t) =l= rate(b)*size(b);
maxCharge(b,t)..                 c(b,t) =l= rate(b)*size(b);

PiCalc(b,t)..                    Pi(b,t) =e= P(b,t)+c(b,t)-d(b,t);

P_linhaCalc(l,t)..               P_linha(l,t) =e= sum(b, A(l,b)*Pi(b,t));

penCalc(l,t)$(P_linha(l,t) > lim_linhas(l))..  pen =e= pen - (P_linha(l,t) - lim_linhas(l))*100000;

Con10(b)..                       sum(t, d(b,t)*preco(t) - c(b,t)*preco(t)) =e= bat(b);
Con11..                          sum(b, bat(b)) =e= cost;

Obj..                            cost + pen =e= res;

Model Opt_Bat /all/;

Solve Opt_Bat using MINLP minimizing res;

$libinclude matout res.l

1:

26  $if exists $ include matdata.gms
****            8

1 - Can't understand this error and cant find information about it.

错误 668 的解释文本是:“$if [NOT] unquoted command is ambiguous, use quotes around expression”。问题是,您在这里的语法有点不正确。您可能想写以下内容?

$if exist matdata.gms $include matdata.gms

2/3:

58  PiCalc(b,t)..                    Pi(b,t) =e= P(b,t) + c(b,t) - d(b,t);
****                                     ,409

 37  '=l=' or '=e=' or '=g=' operator expected

2 - I dont understand whats the problem here as I clearly use a '=e=' operator.

您没有定义任何名为 pi 的符号。但是有一个GAMS "function"叫pihttps://www.gams.com/latest/docs/UG_Parameters.html#INDEX_functions_22_pi这个没有任何参数,所以开(导致这里报错。所以你可能错过了 "your" pi 的声明,它会覆盖 GAMS pi。您的第 3 点具有相同的原因