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

Gams math GAMS中的问题(错误669、8、37、409),gams-math,Gams Math,我的代码中有一些错误(与Matlab接口),我无法解决它们 26 $if exists $ include matdata.gms **** $668 1-无法理解此错误,也无法找到有关此错误的信息 58 PiCalc(b,t).. Pi(b,t) =e= P(b,t) + c(b,t) - d(b,t); **** $37,409 37 '=l='

我的代码中有一些错误(与Matlab接口),我无法解决它们

26  $if exists $ include matdata.gms
****            $668
1-无法理解此错误,也无法找到有关此错误的信息

 58  PiCalc(b,t)..                    Pi(b,t) =e= P(b,t) + c(b,t) - d(b,t);
****                                     $37,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));
****                                                                    $8,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:

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

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

 37  '=l=' or '=e=' or '=g=' operator expected
错误668的解释文本是:“$if[NOT]unquoted命令不明确,请在表达式周围使用引号”。问题是,这里的语法有点不正确。你可能想写以下内容

$if exist matdata.gms $include matdata.gms
2/3:

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

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

您不定义任何名为
pi
的符号。但是有一个名为
pi
的GAMS“函数”:它没有任何参数,因此开头的
会在此处导致错误。因此您可能会错过“您的”的声明
pi
将覆盖GAMS
pi
。您的第3点有相同的原因

您显示的都是GAMS代码,因此我现在删除了MATLAB标记。如果有任何迹象表明MATLAB与此错误有任何关联,请共享相关的MATLAB部分。