Controlling set elements Topic is solved

Problems with modeling
Post Reply
nickelms
User
User
Posts: 2
Joined: 1 month ago

Controlling set elements

Post by nickelms » 1 month ago

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

User avatar
Renger
Posts: 360
Joined: 2 years ago

Re: Controlling set elements

Post by Renger » 1 month ago

Hi

Here a suggestion

Code: Select all

set i /1*8760/;

parameter test(i), maxtest, hour;

test(i) = uniform(0,100);

maxtest = smax(i, test(i));

display maxtest;

loop(i$(maxtest = test(i)),

  hour = i.val;
);

display hour;
Cheers
Renger
____________________________________
Enjoy modeling even more: The lazy economist

nickelms
User
User
Posts: 2
Joined: 1 month ago

Re: Controlling set elements

Post by nickelms » 1 month ago

Thanks, that works perfectly. I used nested loops for the 3 dimensions of the sets and it worked.

Post Reply