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
-----------------------------------------------------------------------------------------------------------------------------------------------
set i /1*4/;
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;
Summation over a Intervall Topic is solved
Re: Summation over a Intervall
Hi
Use the ord operator (t is not an integer, but treated as a character/string):
Cheers
Renger
Use the ord operator (t is not an integer, but treated as a character/string):
Code: Select all
TEST(i)=sum(t$(ord(t) ge FE(i) and ord(t) le SE(i)),1);
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: Summation over a Intervall
Thank you for you reply.
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?
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?
Re: Summation over a Intervall
You can also use t.val if the set element is an integer.
Cheers
Renger
Code: Select all
TEST(i)=sum(t$(t.val ge FE(i) and t.val le SE(i)),1);
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist