Hi, think of sets as just labels, you can’t compare their numerical value directly. To do this, you can define a parameter.

```
set yearSet /2018,2028,2038/;
parameter Q;
variable V,z;
Q(yearSet)=1;
parameter actualYear(yearSet) /2018 2018,2028 2028,2038 2038/;
equation eq1;
Eq1.. z=E= sum(yearSet$(actualYear(yearSet)<2020),Q (yearSet)* V(yearSet))
+sum(yearSet$[actualYear(yearSet)<2021 and actualYear(yearSet)>2019],2*Q (yearSet)* V(yearSet))
+sum(yearSet$[actualYear(yearSet)<2022 and actualYear(yearSet)>2020],3*Q (yearSet)* V(yearSet))
+sum(yearSet$[actualYear(yearSet)>2021],4*Q (yearSet)* V(yearSet))
;
```

For question 1:

actualYear(yearSet) is to be able to do these type of numerical comparisons, which, as you have seen, you are not able to do on set elements directly:

```
yearSet$[actualYear(yearSet)<2021 and actualYear(yearSet)>2019]
```

vs

```
Year$[Year<2021 and Year>2019]
```

Repeating my reply:

think of sets as just labels

Your original code should be getting error “Incompatible operands for relational operator” on the comparison. Because you can’t compare a “set label” to a “numerical value”.

For question 2:

Summing or any type of indexing happens over sets (and not parameters like actualYear). This is why you sum over the set.

The conditional then checks that the value of actualYear associated to the current element of yearSet lies between the boundaries.