How to avoid complementarity constraints in continuous nonlinear program?

In my two-stage continuous NLP problem, I have a constraint in second stage:

$$X_{g,k}$$ = $$X_{g,0} + a_{g} d_{g}$$, if $$X_{g,k} \in [X_g^u,X_g^l]$$

$$X_{g,k} = X_g^u$$, if $$X_{g,k} \geq X_g^u$$

$$X_{g,k} = X_g^l$$, if $$X_{g,k} \leq X_g^l$$

Here $$a_{g}$$ is a predefined factor between {0,1}, and $$d_{g}$$ is an unbounded variable. $$X_{g,0}$$ is a first-stage value of variable $$X_{g,k}$$. It can be implemented using two binary variables but I want to keep the problem continues for efficient computation. How can I handle such constraints?