# How to define hybrid variables without using additional binary variables?

I am working on a large NLP model with equilibrium equations in which the variables are defined in the following form: $$x_i \in [L_B, U_B] \cup\{0\} \quad \text{where} \quad L_B \ \& \ U_B \in\Bbb R^+ \quad \text{and } \quad 0

Is there any way to define such a hybrid (mixed discrete, continuous) domain for variables in Pyomo or Ampl? I know that it's possible to define binary variables as indicators but this approach added a big number of binary variables to the model which is already hard to be solved.

One idea is to implement something like an MPEC or variational inequalities (mpec package of Pyomo) approach where XOR has been defined for sets of constraints. But is it possible for variables?

An alternative approach to binary variables or semicontinuous variables is the following cubic polynomial inequality: $$x(x-L_B)(U_B-x)\ge 0$$ Because $$x \ge 0$$, this constraint enforces $$(x = 0) \lor (x - L_B \ge 0 \land U_B - x \ge 0),$$ as desired. The case $$(x - L_B \le 0 \land U_B - x \le 0)$$ is prevented by $$L_B < U_B$$.
After further consideration, I realized that a quadratic constraint and simple bounds are enough. We want to enforce $$(x = 0) \lor (x \ge L_B \land x \le U_B).$$ Distribute the $$\lor$$ to rewrite in conjunctive normal form: $$(x = 0 \lor x \ge L_B) \land (x = 0 \lor x \le U_B).$$ Because $$U_B > 0$$, this reduces to $$(x = 0 \lor x \ge L_B) \land (x \le U_B),$$ which you can enforce via \begin{align} x(x-L_B) &\ge 0 \\ 0 \le x &\le U_B \end{align} (For comparison, the usual big-M approach instead would replace the quadratic constraint with a binary variable and linear constraints to enforce the disjunction.)