Hi, I am having trouble to implement the following constraint (with two inequalities). Does JuMP accept this kind of expression?

@constraint(model, con4[i in Vtotal, j in Vcustomer; i != j], x[i,j] * Menergy[i,j] - (1-x[i,j])*Q

<= y[i] - y[j] <= x[i,j] * Menergy[i,j] + (1-x[i,j])*Q)

Happy new year and welcome,

I don’t know if JuMP supports such constraints, but you could split them up into two sets of constraints, e.g.,

```
@constraint(model, con4[i in Vtotal, j in Vcustomer; i != j], x[i,j] * Menergy[i,j] - (1-x[i,j])*Q
<= y[i] - y[j] )
```

and

```
@constraint(model, con5[i in Vtotal, j in Vcustomer; i != j], y[i] - y[j] <= x[i,j] * Menergy[i,j] + (1-x[i,j])*Q)
```

(Note that I did not check if the above syntax is correct)

You may also consider using expression definitions for complicated terms:

https://jump.dev/JuMP.jl/stable/manual/expressions/

https://jump.dev/JuMP.jl/stable/reference/expressions/#JuMP.@expression

(or if you’re expression is not linear or quadratic, see Nonlinear Modeling · JuMP)

1 Like