two conditional statement in a summation Topic is solved

Problems with syntax of GAMS
Post Reply
shaparak
User
User
Posts: 8
Joined: 1 month ago

two conditional statement in a summation

Post by shaparak » 1 month ago

Hello
I want to add a conditional range summation equation, which has two conditional statements as mentioned below:

Code: Select all

 Con23(bus).. 
sum (node $ ( conex(bus,node) and  (node>bus) ) ,lambda(bus,node)/branch(bus,node,'x') =e= 0 ;
There is no problem with the conditional sumation with first condition:

Code: Select all

conex(bus,node)
but when I run the code with second one:

Code: Select all

(node>bus)
, also with both of the conditions, I get this error (error code 148):
"dimension different: the symbol is referenced with more/less indices as declared."
It is worth mentioning both "bus" and "node" sets are exactly equal, and I don't know which indices are more/less.

abhosekar
Moderator
Moderator
Posts: 176
Joined: 8 months ago

Re: two conditional statement in a summation

Post by abhosekar » 1 month ago

what do you want to achieve with node > bus? Are these sets with numerical values?

You can consider using ord(node) > ord(bus)
or
node.val > bus.val

ord() gives position of the element .val understands that the set element is a number and uses that value.

Hope this helps.

- Atharv

shaparak
User
User
Posts: 8
Joined: 1 month ago

Re: two conditional statement in a summation

Post by shaparak » 4 weeks ago

abhosekar wrote:
1 month ago
what do you want to achieve with node > bus? Are these sets with numerical values?

You can consider using ord(node) > ord(bus)
or
node.val > bus.val

ord() gives position of the element .val understands that the set element is a number and uses that value.

Hope this helps.

- Atharv
Thank you! The error is resolved

Post Reply