Optimization.jl icon indicating copy to clipboard operation
Optimization.jl copied to clipboard

More advanced MOI Constraints

Open AlCap23 opened this issue 7 months ago • 0 comments

Is your feature request related to a problem? Please describe.

Mathoptinterface offers automatic and well tested "advanced" constraints, e.g. SOS constraints. It would be nice to offer those within Optimzation.jl.

As a motivating example consider the sparse regression problem (😅), which can either be modeled with integer variables $z_i \in \lbrace 0, 1\rbrace$ using a big-M formulationin the constraints

$$ M^l_i z_i \leq \xi_i \leq M^u_i z_i $$

or with the special ordered set 1 type constraint

$$ \lbrace \xi_i , 1 - z_i \rbrace \in \text{SOS-1} $$

which mathoptinterface expands internally.

Describe the solution you’d like

I think the nicest solution would be something along

@variables begin 
   x::Float64 [description="Parameter with value"] 
   c::Int [bounds = (0,1), description = "Integer decision"]
end

constraint = [
   SOS1(x, 1-c)
]

which indicates the right constraints.

Given that these constraints add variables and might become complicated, a transformation step could be added in the expression simplifcation routine of OptimizationMOI. This way only "dummy" constraints must be added and registered.

# Something along the lines of 
...
if ex.args[1] == SOS1 
    MOI.add_constraint(..., ....)
end
...

Describe alternatives you’ve considered

Instead of relying on MOI we could add functions returning the internal representation of the constraint. This would be more universal, but might end buggy and adds to the maintenance stack.

AlCap23 avatar Dec 04 '23 05:12 AlCap23