z + (y-z)*0.5*(1+tanh(k*(x1-x2)))
where k is a large constant (e.g. k=1000). This will allow you to use NLP and CNS model types instead of DNLP.
See also: http://en.wikipedia.org/wiki/Heaviside_step_function
The logistic function (http://en.wikipedia.org/wiki/Logistic_function) can be expressed in two ways:
- f(x,k) = (1+tanh(k·x))/2
- f(x,k) = 1/(1+exp(-2k·x))
The exp() version can overflow more easily. Newer versions of GAMS implement a version of exp() that does not overflow (by truncation) so either choice should work.
This approximation can be used also for max(x,y) and min(x,y) as we have:
- max(x,y) = ifthen(x>y, x, y)
- min(x,y) = ifthen( y>x, x, y)