Summation over a Intervall

I want to do a summation over the intervall FE(i) to SE(i). My idea was to solve it like this (the whole code you can find at the end of the text):

TEST(i)=sum(t$(t ge FE(i) and t le SE(i)),1;

This returns errors. How can i code it whitout using card()? Since I want to make use of the value and not the postition of the set member.

Thank you in advance :slight_smile:


set i /14/;
set t /1
100/;

parameter FE(i) /1 3
2 8
3 10
4 15/;

parameter SE(i) /1 5
2 11
3 14
4 20/;

parameter TEST(i);

TEST(i)=sum(t$(t ge FE(i) and t le SE(i)),1;

Hi

Use the ord operator (t is not an integer, but treated as a character/string):

TEST(i)=sum(t$(ord(t) ge FE(i) and ord(t) le SE(i)),1);

Cheers
Renger

Thank you for you reply. :slight_smile:

But sorry I made a mistake. I meant how can I solve it whitout using ord() but wrote without using card().

Isn’t it possible to treat t as a value?

You can also use t.val if the set element is an integer.

TEST(i)=sum(t$(t.val ge FE(i) and t.val le SE(i)),1);

Cheers
Renger

Thank you very much!