Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ List of supported constraint types:
* [`MOI.VariableIndex`](@ref) in [`MOI.Interval{Float64}`](@ref)
* [`MOI.VariableIndex`](@ref) in [`MOI.LessThan{Float64}`](@ref)
* [`MOI.VariableIndex`](@ref) in [`MOI.ZeroOne`](@ref)
* [`MOI.VectorOfVariables`](@ref) in [`MOI.Complements`](@ref)
* [`MOI.VectorAffineFunction`](@ref) in [`MOI.Complements`](@ref)
* [`MOI.VectorQuadraticFunction`](@ref) in [`MOI.Complements`](@ref)
* [`MOI.VectorNonlinearFunction`](@ref) in [`MOI.Complements`](@ref)

List of supported model attributes:

Expand All @@ -115,7 +119,7 @@ List of supported model attributes:

Note that some solver executables may not support the full list of constraint
types. For example, `Ipopt_jll` does not support `MOI.Integer` or `MOI.ZeroOne`
constraints.
constraints, nor does it support the `MOI.Complements` set.

## Options

Expand Down
38 changes: 7 additions & 31 deletions src/AmplNLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,42 +223,18 @@ function MOI.set(model::Optimizer, attr::MOI.RawOptimizerAttribute, value)
return
end

const _SCALAR_FUNCTIONS = Union{
MOI.VariableIndex,
MOI.ScalarAffineFunction{Float64},
MOI.ScalarQuadraticFunction{Float64},
MOI.ScalarNonlinearFunction,
}

const _SCALAR_SETS = Union{
MOI.LessThan{Float64},
MOI.GreaterThan{Float64},
MOI.EqualTo{Float64},
MOI.Interval{Float64},
}

function MOI.supports_constraint(
::Optimizer,
::Type{<:_SCALAR_FUNCTIONS},
::Type{<:_SCALAR_SETS},
)
return true
model::Optimizer,
::Type{F},
::Type{S},
) where {F<:MOI.AbstractFunction,S<:MOI.AbstractSet}
return MOI.supports_constraint(model.inner, F, S)
end

function MOI.supports_constraint(
::Optimizer,
::Type{MOI.VariableIndex},
::Type{<:Union{MOI.ZeroOne,MOI.Integer}},
)
return true
function MOI.supports(model::Optimizer, attr::MOI.AbstractModelAttribute)
return MOI.supports(model.inner, attr)
end

MOI.supports(::Optimizer, ::MOI.ObjectiveFunction{<:_SCALAR_FUNCTIONS}) = true

MOI.supports(::Optimizer, ::MOI.ObjectiveSense) = true

MOI.supports(::Optimizer, ::MOI.NLPBlock) = true

function MOI.supports(
::Optimizer,
::MOI.VariablePrimalStart,
Expand Down
11 changes: 11 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ function test_ipopt_runtests()
"_SOS2_",
"test_linear_integer_",
"test_cpsat_",
# Ipopt doesn't support complementarity
"_complementarity",
],
)
return
Expand Down Expand Up @@ -293,6 +295,15 @@ function test_supports_incremental_interface()
return
end

function test_supports_complements()
model = AmplNLWriter.Optimizer()
inner = MOI.FileFormats.NL.Model()
F, S = MOI.VectorOfVariables, MOI.Complements
@test MOI.supports_constraint(model, F, S) ==
MOI.supports_constraint(inner, F, S)
return
end

end # module

TestMOIWrapper.runtests()
Loading