Dear All,
In my GAMS code, I have written two equations with which I am calculating the total costs of a energy system [variable TC on the domain j (fuel type) and i (technology)] and TCmin which allows me to determine the cheapest of the different configurations:
TotCost(i,j).. TC(i,j) =e=Eg(i)*C(i)+coi(i,'IC')+coj(j,'P')*V(i,j) ;
MinTotcost.. TCmin=e=smin((i,j),TC(i,j));
So far so good.
But to be totally happy with my code, I would like it to return not only the price of the cheapest configuration but also the details of that configuration: the corresponding set elements i and j .
As set elements are stored as string data type, I don't know how I possibly could get GAMS to give me a specific (i;j) subset as output data.
Any suggestion?
Thank you
How to find the set elements that verify a condition

 User
 Posts: 55
 Joined: 10 months ago
Re: How to find the set elements that verify a condition
Hi Lenilein,
Is TC(i,j) a parameter (fixed in an instance of a solve) or a variable ? I get from your question that you intend to use it as a variable. Be aware that if it is a variable in your model, the smin() operator would require a DNLP solver (http://old.gams.com/latest/docs/usergui ... __smax.htm).
If you manage to do this either by defining the model to be DNLP or through a reformulation, you can use this code to store the (i,j) pair in a set (an option among many). This also assumes TC (and therefore TCmin are "variables").
set whichIsMin(*,*);
whichIsMin(i,j)=YES$(TC.l(i,j)=TCmin.l);
If they are in fact parameters, you don't need to use equations for their definition.
Good luck
Is TC(i,j) a parameter (fixed in an instance of a solve) or a variable ? I get from your question that you intend to use it as a variable. Be aware that if it is a variable in your model, the smin() operator would require a DNLP solver (http://old.gams.com/latest/docs/usergui ... __smax.htm).
If you manage to do this either by defining the model to be DNLP or through a reformulation, you can use this code to store the (i,j) pair in a set (an option among many). This also assumes TC (and therefore TCmin are "variables").
set whichIsMin(*,*);
whichIsMin(i,j)=YES$(TC.l(i,j)=TCmin.l);
If they are in fact parameters, you don't need to use equations for their definition.
Good luck

 User
 Posts: 4
 Joined: 7 months ago
Re: How to find the set elements that verify a condition
Hi cladelpino,
Excellent, it worked!!
TC(i,j) and TCmin are indeed both variables in my model.
Thanks a lot for your help!
Excellent, it worked!!
TC(i,j) and TCmin are indeed both variables in my model.
Thanks a lot for your help!
Who is online
Users browsing this forum: No registered users and 1 guest