Solved

Summation problem


Badge

Hello everyone, I contact you because I have a problem with my AIMMS code and I can not fix it.

Here is the constraint I want to write :

FlowPlant1,

index domain : (b,l,t) | ord(t)>1

Definition : sum(j | j>= ConvTime(t-1)+1 and j<=ConvTime(t), X(b,l,j))+IPlant(b,l,t-1)=sum(d, Z(b,l,d,t))+IPlant(b,l,t)

I suppose the problem comes from the first sum as the error message is : “There is no operation defined for operator ">=" with arguments of data type element and data type numeric; the arguments themselves are "j" and "ConvTime(t-1) + 1".” , but I don’t understand it well.

Can someone help please?

icon

Best answer by deannezhang 16 May 2022, 05:04

View original

2 replies

Userlevel 4
Badge +3

Since j is an index, it is an element data type; and ConvTime(t-1) + 1 is a numeric data type, it cannot be compared. You can use the val function on j to convert it to numerical. 

sum(j | val(j)>= ConvTime(t-1)+1 and val(j)<=ConvTime(t), X(b,l,j))+IPlant(b,l,t-1)=sum(d, Z(b,l,d,t))+IPlant(b,l,t).

or you can also make the set, which j is defined on, a subset of Integers, then your original formula should work.

 

Userlevel 5
Badge +6

Exactly as @deannezhang said. Or even compare j using ElementCast or StringToElement to change ConvTime(t-1)+1 to an element. 

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator