Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking changes for MOI 0.10.0 #422

Merged
merged 1 commit into from
Sep 8, 2021
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"

[compat]
CEnum = "0.3, 0.4"
MathOptInterface = "~0.9.19"
MathOptInterface = "~0.10"
julia = "1"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion src/MOI_wrapper/MOI_callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ end
# ==============================================================================

function MOI.set(model::Optimizer, ::MOI.LazyConstraintCallback, cb::Function)
MOI.set(model, MOI.RawParameter("LazyConstraints"), 1)
MOI.set(model, MOI.RawOptimizerAttribute("LazyConstraints"), 1)
model.lazy_callback = cb
return
end
Expand Down
29 changes: 13 additions & 16 deletions src/MOI_wrapper/MOI_indicator_constraint.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
function _info(
model::Optimizer,
c::MOI.ConstraintIndex{
MOI.VectorAffineFunction{Float64},
<:MOI.IndicatorSet,
},
c::MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},<:MOI.Indicator},
)
if haskey(model.indicator_constraint_info, c.value)
return model.indicator_constraint_info[c.value]
Expand All @@ -14,15 +11,15 @@ end
function MOI.supports_constraint(
::Optimizer,
::Type{MOI.VectorAffineFunction{Float64}},
::Type{<:MOI.IndicatorSet{A,S}},
::Type{<:MOI.Indicator{A,S}},
) where {A,S<:_SUPPORTED_SCALAR_SETS}
return true
end

function MOI.is_valid(
model::Optimizer,
c::MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},S},
) where {S<:MOI.IndicatorSet}
) where {S<:MOI.Indicator}
info = get(model.indicator_constraint_info, c.value, nothing)
if info === nothing
return false
Expand All @@ -33,7 +30,7 @@ end
function MOI.get(
model::Optimizer,
::MOI.ConstraintSet,
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.IndicatorSet},
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.Indicator},
)
MOI.throw_if_not_valid(model, c)
return _info(model, c).set
Expand All @@ -42,7 +39,7 @@ end
function MOI.get(
model::Optimizer,
::MOI.ConstraintFunction,
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.IndicatorSet},
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.Indicator},
)
MOI.throw_if_not_valid(model, c)
_update_if_necessary(model)
Expand Down Expand Up @@ -89,7 +86,7 @@ end
function MOI.add_constraint(
model::Optimizer,
func::MOI.VectorAffineFunction{Float64},
s::MOI.IndicatorSet{A,S},
s::MOI.Indicator{A,S},
) where {A,S<:_SUPPORTED_SCALAR_SETS}
if !iszero(func.constants[1])
error(
Expand All @@ -112,10 +109,10 @@ function MOI.add_constraint(
"be 1.0. Got $(term.coefficient).",
)
end
binvar = Cint(column(model, term.variable_index) - 1)
binvar = Cint(column(model, term.variable) - 1)
else
@assert row == 2
vars[i] = Cint(column(model, term.variable_index) - 1)
vars[i] = Cint(column(model, term.variable) - 1)
vals[i] = term.coefficient
i += 1
end
Expand Down Expand Up @@ -146,7 +143,7 @@ end
function MOI.get(
model::Optimizer,
::MOI.ListOfConstraintIndices{<:MOI.VectorAffineFunction,S},
) where {S<:MOI.IndicatorSet}
) where {S<:MOI.Indicator}
indices = MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},S}[
MOI.ConstraintIndex{MOI.VectorAffineFunction{Float64},S}(key) for
(key, info) in model.indicator_constraint_info if isa(info.set, S)
Expand All @@ -157,14 +154,14 @@ end
function MOI.get(
model::Optimizer,
::MOI.NumberOfConstraints{MOI.VectorAffineFunction{Float64},S},
) where {S<:MOI.IndicatorSet}
) where {S<:MOI.Indicator}
return count(x -> isa(x.set, S), values(model.indicator_constraint_info))
end

function MOI.get(
model::Optimizer,
::MOI.ConstraintName,
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.IndicatorSet},
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.Indicator},
)
MOI.throw_if_not_valid(model, c)
return _info(model, c).name
Expand All @@ -175,7 +172,7 @@ function MOI.set(
::MOI.ConstraintName,
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,S},
name::String,
) where {S<:MOI.IndicatorSet}
) where {S<:MOI.Indicator}
MOI.throw_if_not_valid(model, c)
_update_if_necessary(model)
info = _info(model, c)
Expand All @@ -190,7 +187,7 @@ end

function MOI.delete(
model::Optimizer,
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.IndicatorSet},
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.Indicator},
)
MOI.throw_if_not_valid(model, c)
row = _info(model, c).row
Expand Down
2 changes: 1 addition & 1 deletion src/MOI_wrapper/MOI_multi_objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function MOI.set(
num_vars = length(model.variable_info)
obj = zeros(Float64, num_vars)
for term in f.terms
column = _info(model, term.variable_index).column
column = _info(model, term.variable).column
obj[column] += term.coefficient
end
indices, coefficients = _indices_and_coefficients(model, f)
Expand Down
Loading