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?

## Issue of select members from sets

### Re: Issue of select members from sets

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.
populate its elements based on your needs.

You will then declare con(r, r) but to differentiate between indices of two tds() you will need to declare an alias.
Now you can write the following equation
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

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);
```

Code: Select all

```
r1('5','1') = yes;
r1('4','2') = yes;
r1('1','3') = yes;
```

Code: Select all

```
alias(r, rr);
```

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;
```

- Atharv

### Re: Issue of select members from sets

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