Skip to main content
Solved

Summation problem

  • May 14, 2022
  • 2 replies
  • 91 views

Forum|alt.badge.img

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?

Best answer by deannezhang

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.

 

2 replies

deannezhang
AIMMS Champ
Forum|alt.badge.img+3
  • AIMMS Champ
  • 61 replies
  • Answer
  • May 16, 2022

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.

 


gabiservidone
Administrator
Forum|alt.badge.img+6
  • AIMMSian
  • 256 replies
  • May 17, 2022

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



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

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