How can I do this in GAMS?

Problems with modeling
Post Reply
Abdullah
User
User
Posts: 1
Joined: 4 years ago

How can I do this in GAMS?

Post by Abdullah »

I am mimicking a GAMS model that was introduced in [1] to compare my new model with its results.

In a nutshell, assume we have a variable t that is supposed to only takes certain discrete values from the set D where D={0.12 0.22 0.32 0.42 0.52 0.62}.

The proposed method is to relax t and make it a continuous variable between two upper and lower limits min(D) <= t <= max(D) and then add a penalty function to the model objective function to force the solver to allocate only discrete values for t.

The penalty function is sin([t/(upr-lwr) ] * pi)^2

where:

upr : is the upper closest values for t in D.

lwr : is the lower closest values for t in D.

This clever trick will make the penalty function take positive values if the allocated value for t is not discrete, and zero if t is discrete.

During the optimization process, when the solver allocates a values for t, it needs to find the two closest elements from D to the allocated value of t. Let say it gives t=0.14, then it has to find the upper and lower values of t from D which are (lwr=0.12) and (upr=0.22). This has to be done during the optimization process not after it finish like in some iterative methods.

So, my question is how to code this in GAMS. how can I tell the solver to find the upper and lower values of a variable from a set during the optimization process. In MATLAB we use the function "find" but it is NOT effective.

Thank you.

[1] Soler, Edilaine Martins, Eduardo N. Asada, and Geraldo RM Da Costa. "Penalty-based nonlinear solver for optimal reactive power dispatch with discrete controls." IEEE Transactions on Power Systems 28.3 (2013): 2174-2182.
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: How can I do this in GAMS?

Post by bussieck »

This is very tricky and would require more effort (and lots of binary variables) than just modeling "t from D" directly. So why not model "t from D" directly, is it possible to have a t not in D in an optimal solution?

Code: Select all

Integer variable di; di.lo=1 di.up=6;
variable t;
equation deft; deft.. t =e= 0.2 + di/10;
Don't be afraid of discrete variables, MINLP solvers are pretty good nowadays.

-Michael
Post Reply