# Constraintlist with two Options Pyomo

I recently started with Pyomo and I have the following Problem:

I want to construct a ConstraintList with an if statement. I already learned, that it's not possible. But the problem still exists... My first code (with the if statement) was the following one:

m.Constraint10=pyo.ConstraintList()
for i in m.Stunde:
for j in m.Kraftwerk:
if pyo.value(m.Kraftwerkseinsatz[i,j]) != 0:


m.Stunde and m. Kraftwerk are indices.

m.Kraftwerkseinsatz is a variable!

m.MinOutput is a parameter.

In other words, my variable must be greater than the MinOutput parameter or zero (for every hour and every power plant).

I already thought of reframing the constraint like this: m.Kraftwerkseinsatz[i,j] must not be between 0.1 and m.MinOutput.

But I don't know how to code this either. Can anyone help me?

A variable that can assume values of zero or between some lower and upper bound is called a semi-continuous variable. Most high-end solvers have direct support for this type of variable. If not supported, you can model this with an additional binary variable: \begin{align} & \color{darkblue}L\cdot \color{darkred}\delta \le \color{darkred}x \le \color{darkblue}U \cdot \color{darkred}\delta \\ & \color{darkred}\delta \in \{0,1\} \\ &\color{darkred}x\in [0,\color{darkblue}U]\end{align}
Note: in the bounds for $$\color{darkred}x$$, I assumed $$\color{darkblue}L\gt 0$$. We can make this more general by stating $$\color{darkred}x \in [\min(0,\color{darkblue}L),\max(0,\color{darkblue}U)].$$