-1

I'm getting a few errors in my code (which is interfaced with Matlab) and I'm unable to solve them.

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

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

 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 - I don't understand what the problem is here as I clearly use a '=e=' operator.

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 - Again, I don't understand the missing ')' when It's present.

Any feedback is appreciated.

Full code is bellow:

** 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
norbitrial
  • 14,716
  • 7
  • 32
  • 59
MiguelL
  • 79
  • 7
  • All you show is GAMS code, thus I removed the MATLAB tag for now. If there is any indication that MATLAB is in any way related to this error, please share the relevant MATLAB parts as well. – Adriaan Nov 20 '19 at 16:09

1 Answers1

0

1:

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

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

The explanation text for error 668 is: "$if [NOT] unquoted command is ambiguous, use quotes around expression". The problem is, that you are a little off the correct syntax here. You probably want to write the following?

$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);
****                                     $37,409

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

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

You do not define any symbol called pi. But there is a GAMS "function" called pi: https://www.gams.com/latest/docs/UG_Parameters.html#INDEX_functions_22_pi This does not have any arguments, so that the opening ( causes the error here. So you probably miss the declaration of "your" pi which would overwrites the GAMS pi. Your point 3 has the same cause

Lutz
  • 2,197
  • 1
  • 10
  • 12