Assistance Needed with Correcting Dimension and Operand Errors in Lines 97-101

Hello Everyone,

I am currently working on a project where I am using the GAMS 41.5.0 to create a model for optimizing production scheduling. While defining the constraints for my model, I encountered some errors in lines 97 to 101 which I am unable to resolve. Here is a snippet of the problematic part of the code:

96 inventoryBalance(p,s,t)…
97 I(t,p,s) =e= I(t-1,p,s) + X(t,p,s) - sum(s_1$(s_1 = sPrec(p,s) and s_1<>s), X(t-rt(s,s_1),p,s_1)*a(p,s)) - d(t,p,s);
**** $148,135 148,135,148,135 98 99 100 productionSynchronization(p,s,s_1,t)(s_1<>s and s_1 = sPrec(p,s))…
**** $148,135,148,135,148,135
101 a(p,s)*X(t,p,s) =l= X(t-rt(s,s_1),p,s_1)*a(p,s_1);



The error messages I am receiving are:

Error 135: Incompatible operands for the relational operator.
Error 148: Dimension different - The symbol is referenced with more/less indices as declared.
I suspect that the issue might be related to the way I have structured the conditional statements inside the sum functions and the relational operators used in the equations.

I am having trouble formulating these constraints correctly to avoid these errors. Could anyone please assist me in correcting the formulation of these constraints to adhere to the proper syntax and logic?

Complete Code is in the Attachments

Thank you for your time and assistance!
Final_model_An improved model and heuristic for capacitated lot-sizing and scheduling in job shop problems.gms (5.59 KB)

The listing file points you nicely to the issue and gives a reasonable explanation “Incompatible operands for relational operator”:

  95  inventoryBalance(p,s,t)..
  96      I(t,p,s) =e= I(t-1,p,s) + X(t,p,s) - sum(s_1$(s_1 = sPrec(p,s) and s_1<>s), X(t-rt(s,s_1),p,s_1)*a(p,s)) - d(t,p,s);
****                                                        $148,135             $148,135,148,135
**** 135  Incompatible operands for relational operator
**** 148  Dimension different - The symbol is referenced with more/less
****         indices as declared

You interpret the string label s_1 as a numerical value and compare. That does not work in GAMS, similar you can’t compare labels (s_1<>s). If your string labels allow for a numerical interpretation you can use the .val attribute. For label comparison you need to use the predefined symbols sameAs:

inventoryBalance(p,s,t)..
    I(t,p,s) =e= I(t-1,p,s) + X(t,p,s) - sum(s_1$(s_1.val = sPrec(p,s) and not sameAs(s_1,s)), X(t-rt(s,s_1),p,s_1)*a(p,s)) - d(t,p,s);

There were more of these in the equation syntax, but I hope this gets you over the hump.

-Michael