### Controlling set elements

Posted:

**Thu Jul 25, 2019 11:46 am**Hi, I want to return the set element that corresponds to a particular parameter. More specifically, I have a set (sHours) from 1 to 8760 hours in a year. I want to find the hour of peak demand and then find the available generation capacity that corresponds to that hour. I can find the maximum demand and the maximum available generation capacity in a region (see code below) but I cannot figure out how to find the hour of maximum demand in the region and use that to find the available generation in the region in the hour. Many thanks for any ideas!!

Code: Select all

```
pAnnRegCapBal(sRegions, sYearsMod, "Avail Cap")= smax(sHours, sum(sGensets$(pGenRegion(sGenSets, sRegions)=1), vInstalledCap.l(sYearsMod, sGenSets) * pGenAvailFinal(sYearsMod, sHours, sGenSets)));
pAnnRegCapBal(sRegions, sYearsMod, "Peak Dem") = smax(sHours, pHlyDemand(sRegions, sYearsMod, sHours));
```