The second constraint will force p to be 0 when the sum is 0, the first constraint will force p to be 1 when sum is not zero.
Define a variable v(w,t) that will be s(w, t) when p is 0 and s(w, t)/sum(W_w, x(W_w, T))) when p is 1. You can do this as follows:
g(w,t) =l= s(w, t) + Mp and g(w,t) =g= s(w, t) - Mp
These will force the condition when p is 0 and keep g(w,t) unbounded when p is 1.
g(w,t) =l= s(w,t)/sum(W_w, x(W_w, T))) + M*(1-p)
g(w,t) =g= s(w,t)/sum(W_w, x(W_w, T))) - M*(1-p)
Finally, now that you are sure that you would use the term sum(W_w, x(W_w, T))) in the denominator only when it is not zero, you can add a very small number to it so that the solver does not give you division by zero error.
I understand your trick, Big-M, but that’s not the ultimate solution.
The Big-M trick’s logic is right, but GAMS cannot reflect the logic because of 2 equations.
Because eventually there exists a touble(division by zero) in GAMS
at this two equations.
g(W,T) =l= s(W,T)/(sum(W_w, x(W_w, T))) + M*(1-k(T))
g(W,T) =g= s(W,T)/(sum(W_w, x(W_w, T))) - M*(1-k(T)) ;
Hi, I explained the same in the last part of my answer that you can add a small number to the denominator e.g., sum(W_w, x(W_w, T))) + M*(1-k(T) + 0.0000001. Why did we do big-M trick then? Because for sum(W_w, x(W_w, T))) = 0, w(s,t)/(sum(W_w, x(W_w, T)))+ 0.0000001) would give us a very large number and you need it to be w(s,t).