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.