About how to extract signs

Hello, I have the following formula,
image

I just want to get the sign of the expression, 12-yf[i,j]
but if I divide the absolute value like this, (12-yf[i,j])/abs(12-yf[i,j])
when yf[i,j]=12, the denominator will appear to be 0,and ampl may report an error, what should I do?

How is yr defined in your model? It makes a difference whether yr is a param or a var, and whether it is continuous or integer-valued.

image

var and continuous

Is this the mathematical description of the function that you are trying to use in your constraint?

-log_{10} (exp(200\times sign(12-yr_{ij}))+10^{12})

Rounded to 10 decimal places, it can take only two values:

if yr_{ij} < 12 then -log_{10} (exp(200)+10^{12}) = -86.8588963807
if yr_{ij} = 12 then -log_{10} (exp(0)+10^{12}) = -12
if yr_{ij} > 12 then -log_{10} (exp(-200)+10^{12}) = -12

This would be easy to write using an AMPL if-then-else expression:

(xr[i,j] - large_radius) >=
   if yr[i,j] >= 12 then -12 else -86.8588963807