Equation Domain Restriction

Problems with syntax of GAMS
Post Reply
PauloRodriguez
User
User
Posts: 4
Joined: 3 years ago

Equation Domain Restriction

Post by PauloRodriguez »

Hi guys, i have a set j from j=1 to j=20 (j=1, 2, 3...20)

And i have a constraint:

const(j)... equation


But i need to apply this constraint just for specific j. In this const. just for j=1, j=4, j=7, j=10, j=13, j=16, j=19 (the last one plus 3)

How can i implement this?
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Equation Domain Restriction

Post by abhosekar »

You can simply write
const(i)$(mod(ord(i), 3) eq 1).. equation

mod(a, b) gives remainder when a is divided by b.
The above mentioned constraint is valid only for the elements 1,4, 7,... and so on
You can similarly use any condition on the set using $ and ord.

Hope this helps

- Atharv
Post Reply