Semi-continuous variables: JuMP and Cplex solver

Hello,
I have a semi-continuous variable, the domain is {0} U [l,u]. Example is:

using JuMP
using CPLEX

MyModel = Model(with_optimizer(CPLEX.Optimizer))
@variable(MyModel, zz)
@constraint(MyModel, zz in MOI.Semicontinuous(2.5, 3.5))

It didn’t work. Error was:

ERROR: Constraints of type MathOptInterface.SingleVariable-in-MathOptInterface.Semicontinuous{Float64} are not supported by the solver and there are no bridges that can reformulate it into supported constraints.

I tried without solver:

MyModel2 = Model()
@variable(MyModel2, zz)
@constraint(MyModel2, zz in MOI.Semicontinuous(2.5, 3.5));

There was no error.

I had a look inside the Cplex solver user guide, then it is possible to create a semi continuous variable.

I have two questions:

  • What are the juMP available solvers that can take into account semi-continuous variable?
  • Is it possible to reformulate the constraint to keep semi-continuous variable and Cplex solver?

Thank you in advance!
Warmest Regards.

JuMP: v0.19.1
Cplex studio : v12.8.0
Julia v1.1.0

The MathOptInterface wrapper is claiming that it is not supported. See https://github.com/JuliaOpt/CPLEX.jl/issues/241 for an idea how to fix it.

Thank you, it works well with Cplex.

I also tried to do it withCbc, however I’ve got the same issue. I do not know exatly where to modify the MOI.Wrapper. I added MOI.Semicontinuous[Float64} inside:

function MOI.supports_constraint(
::Optimizer, ::Type{MOI.SingleVariable}, ::Type{<:Union{
MOI.EqualTo{Float64}, MOI.LessThan{Float64},
MOI.GreaterThan{Float64}, MOI.Interval{Float64},
MOI.ZeroOne, MOI.Integer}})
return true
end

Do I need to add it in an other function?

Regards