Issue of select members from sets

Problems with modeling
Post Reply
KhB
User
User
Posts: 4
Joined: 4 weeks ago

Issue of select members from sets

Post by KhB » 4 weeks ago

Hello,

I'm a beginner to GAMS, I have a question about select members from sets.

For examples,
Set
r relays / 1*6 /

Variables tds(r);
con13.. ((tds('5') * 0.14) / (vcPower((384 / (5* 40)),0.02) - 1)) -
((tds('1') * 0.14) / (vcPower((1978.9 / (2 * 60)),0.02) - 1)) =g= 0.2;

con14.. ((tds('4') * 0.14) / (vcPower((466.17 / (5 * 60)),0.02) - 1)) -
((tds('2') * 0.14) / (vcPower((1525.7 / (3* 40)),0.02) - 1)) =g= 0.2;

con15.. ((tds('1') * 0.14) / (vcPower((175 / (5* 60)),0.02) - 1)) -
((tds('3') * 0.14) / (vcPower((1683.9 / (2 * 40)),0.02) - 1)) =g= 0.2;

So, I do have a huge set of constraints, how I can introduce a specific sequence for the equations, instead of having a large number of equations?

abhosekar
Moderator
Moderator
Posts: 209
Joined: 1 year ago

Re: Issue of select members from sets

Post by abhosekar » 4 weeks ago

It is a good practice to index your equations but in your case, it needs some work. I can give you an outline on how to do it.

The aim should be to write con(r);

first let's look at the terms tds (in first equation, you have tds(5) and tds(1), in second you have 4,2 and in so on.... I don't see any programming logic here so you will need to declare a 2D set.

Code: Select all

set r1(r, r);
populate its elements based on your needs.

Code: Select all

r1('5','1') = yes;
r1('4','2') = yes;
r1('1','3') = yes;
You will then declare con(r, r) but to differentiate between indices of two tds() you will need to declare an alias.

Code: Select all

alias(r, rr);
Now you can write the following equation

Code: Select all

con(r, rr)$r1(r,rr).. ((tds(r) * 0.14) / (vcPower((384 / (5* 40)),0.02) - 1)) -
((tds(rr) * 0.14) / (vcPower((1978.9 / (2 * 60)),0.02) - 1)) =g= 0.2;
Finally, I see that the parameters in your equations also change in equations. You will also need to declare parameters over a set (based on hwo they are calculated).

- Atharv

KhB
User
User
Posts: 4
Joined: 4 weeks ago

Re: Issue of select members from sets

Post by KhB » 3 weeks ago

Indeed there is not any programming logic. Thanks it works for me.

Post Reply