Alternative for Smin function in MINLP

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Alternative for Smin function in MINLP

Post by Archiver »


Dear GAMS community,


I am working with a rather nasty MINLP problem. In MINLP, I cannot use the Smin-function of GAMS, which would allow computing an equation only for the element of a certain set which has the smallest value compared to the other set elements. I am now trying to find ideas for alternative ways to make GAMS compute this equation only for the set element with the smallest value. If you have any ideas on how this could be achieved I’d be very thankful!




Below are some more detailed information:


I am programming a bio-economic model of subsistence farm-households, where the level of soil fertility of the household’s land is measured as a continuous variable that serves as an input to the production function. At the same time, production and farm management choices (inputs, technology, fallow) effect soil fertility. This relationship is simulated via a simple linear function.For each modelled time period, I calculate an average Soil Fertility value for the entire land of the household. This avoids the need for the spatially explicit modelling of separate plots.Soil Fertility is approximated by the level of the three macro-nutrients N, P and K, which are the elements of a set called Nutrients. Following Liebig’s Law of the Minimum, the level of Soil Fertility is determined by the level of that nutrient pool which has the lowest availability.

In a LP model, this could look like:


Var_SoilFertility =l= Smin (nutrient, Var_Nutrientlevel(nutrient) ) ;



where nutrient is a set with the elements / N, P, K /.



Other equations determine the level of the variable Var_Nutrientlevel(nutrient) depending on the chosen management option:


Var_Nutrientlevel(nutrient) =l= Sum (technology, Sum (InputUse, Var_AreaOfMgmt(technology,InputUse) * Par_NutrientImpact(nutrient,technology, InputUse) ));


Where the variable “Area under a certain farm-management-option” (e.g. use of inputs or soil conserving technologies) is multiplied by a fixed Parameter “Par_Nut-...” which describes the mean impact of the management option upon the pools of the three nutrients N, P and K (positive and negative). To keep things simply I excluded any time-lags, fallow periods and dynamic formulations of the original model.


My model is rather big and the soil fertility function is at its heart, with links to many other equations of the model. Therefore I don’t post the entire code here, but just the example above.

It would be greatly appreciated if anyone had an idea how an alternative to the Smin-function could look like, e.g. a set of alternative equations, commands or conditional statements.



Thanks a lot for any hint or idea!

Benjamin



P.S.: My system specifics:


GAMS version: GAMS Release 24.3.3 r48116 WEX-WEI x86 64bit/MS Windows

SOLVER: BARON Version 14.0.3

System: Win 7 (Professional) 64-bit





--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Alternative for Smin function in MINLP

Post by Archiver »


Hi,

I might miss something here, but why not just unroll the one equation into card(nutrient) ones:

eq(nutrient).. Var_SoilFertility =l= Var_Nutrientlevel(nutrient);

Michael Bussieck - GAMSWorld Coordinator

On Thursday, March 3, 2016 at 4:55:00 AM UTC-5, jakatri@gmx.de wrote:

Dear GAMS community,


I am working with a rather nasty MINLP problem. In MINLP, I cannot use the Smin-function of GAMS, which would allow computing an equation only for the element of a certain set which has the smallest value compared to the other set elements. I am now trying to find ideas for alternative ways to make GAMS compute this equation only for the set element with the smallest value. If you have any ideas on how this could be achieved I’d be very thankful!




Below are some more detailed information:


I am programming a bio-economic model of subsistence farm-households, where the level of soil fertility of the household’s land is measured as a continuous variable that serves as an input to the production function. At the same time, production and farm management choices (inputs, technology, fallow) effect soil fertility. This relationship is simulated via a simple linear function.For each modelled time period, I calculate an average Soil Fertility value for the entire land of the household. This avoids the need for the spatially explicit modelling of separate plots.Soil Fertility is approximated by the level of the three macro-nutrients N, P and K, which are the elements of a set called Nutrients. Following Liebig’s Law of the Minimum, the level of Soil Fertility is determined by the level of that nutrient pool which has the lowest availability.

In a LP model, this could look like:


Var_SoilFertility =l= Smin (nutrient, Var_Nutrientlevel(nutrient) ) ;



where nutrient is a set with the elements / N, P, K /.



Other equations determine the level of the variable Var_Nutrientlevel(nutrient) depending on the chosen management option:


Var_Nutrientlevel(nutrient) =l= Sum (technology, Sum (InputUse, Var_AreaOfMgmt(technology,InputUse) * Par_NutrientImpact(nutrient,technology, InputUse) ));


Where the variable “Area under a certain farm-management-option” (e.g. use of inputs or soil conserving technologies) is multiplied by a fixed Parameter “Par_Nut-...” which describes the mean impact of the management option upon the pools of the three nutrients N, P and K (positive and negative). To keep things simply I excluded any time-lags, fallow periods and dynamic formulations of the original model.


My model is rather big and the soil fertility function is at its heart, with links to many other equations of the model. Therefore I don’t post the entire code here, but just the example above.

It would be greatly appreciated if anyone had an idea how an alternative to the Smin-function could look like, e.g. a set of alternative equations, commands or conditional statements.



Thanks a lot for any hint or idea!

Benjamin



P.S.: My system specifics:


GAMS version: GAMS Release 24.3.3 r48116 WEX-WEI x86 64bit/MS Windows

SOLVER: BARON Version 14.0.3

System: Win 7 (Professional) 64-bit





--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Alternative for Smin function in MINLP

Post by Archiver »


Dear Michael Bussiek,


Thanks a lot for your answer! It made me realize that I made quite an embarrassing mistake: A while ago I reformulated the model in such a way that I now look for the lowest value of a variable and not the set argument with the lowest value. Thus even the Smin function would not work for me anymore...


In fact I now look for the smallest value of the variable Var_Nutrientlevel(nutrient), i.e. the smallest of the following three possibilities: either Var_Nutrientvalue(“N”) or Var_Nutrientvalue(“P”) or Var_Nutrientvalue(“K”).


I am sure I will find a solution for this problem. Thanks again!


Benjamin

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Alternative for Smin function in MINLP

Post by Archiver »


Benjamin,

I think the SMIN would still work if you make it an equality: "Var_SoilFertility =e= smin(nutrient, Var_Nutrientlevel(nutrient));". This is indeed a harder problem to reformulate. In many cases you don't have to and the relaxation "Var_SoilFertility =l= smin(nutrient, Var_Nutrientlevel(nutrient));" (which is easy to reformulate, see my first reply) automatically achieves the =e=. This is the case if the optimization functions wants the variable Var_SoilFertility to be as big as possible and no other constraints will keep Var_SoilFertility away from achieving equality. If this relaxation is not equivalent with the original model you need to model a disjunction:

eq(nutrient).. Var_SoilFertility =l= Var_Nutrientlevel(nutrient);

plus the disjunction

Var_SoilFertility =e= Var_Nutrientlevel('N") or Var_SoilFertility =e= Var_Nutrientlevel('P") or Var_SoilFertility =e= Var_Nutrientlevel('K")

There is a ton of literature about disjunctions, but here is what I usually do. Introduce slack variables for the disjunction constraint and make sure at least one of the slack variables has value 0. I assume you can nicely bound the slack variables (e.g. the bound of the Var_Nutrientlevel variables):

positive variable slack(nutrient);
binary variable indslack(nutrient);

eq1(nutrient).. Var_SoilFertility =l= Var_Nutrientlevel(nutrient);
eq2(nutrient).. Var_SoilFertility =e= Var_Nutrientlevel(nutrient) - slack(nutrient);
eq3(nutrient).. slack(nutrient) =l= indslack(nutrient)*Var_Nutrientlevel.up(nutrient); // or some other bound on the slack
eq4.. sum(nutrient, indslack(nutrient)) =l= card(nutrient) - 1;

eq4 makes sure that at least one indslack is 0. This means that the slack of this nutrient is 0 (eq3) , and hence we achieve equality for at least one nutrient in eq2. Equation eq1 is actually not required (because eq2 with positive slack imply this).

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator



On Thursday, March 3, 2016 at 9:37:24 AM UTC-5, jakatri@gmx.de wrote:

Dear Michael Bussiek,


Thanks a lot for your answer! It made me realize that I made quite an embarrassing mistake: A while ago I reformulated the model in such a way that I now look for the lowest value of a variable and not the set argument with the lowest value. Thus even the Smin function would not work for me anymore...


In fact I now look for the smallest value of the variable Var_Nutrientlevel(nutrient), i.e. the smallest of the following three possibilities: either Var_Nutrientvalue(“N”) or Var_Nutrientvalue(“P”) or Var_Nutrientvalue(“K”).


I am sure I will find a solution for this problem. Thanks again!


Benjamin

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Alternative for Smin function in MINLP

Post by Archiver »


Dear Michael,

You helped a lot! The model solves and I can optimize over all three nutrient pools now.
Thank you very much for your help and efforts,

Benjamin



--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Post Reply