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

Refactor GRBupdatemodel calls #552

Merged
merged 10 commits into from Mar 26, 2024
8 changes: 4 additions & 4 deletions src/MOI_wrapper/MOI_indicator_constraint.jl
Expand Up @@ -140,7 +140,7 @@ function MOI.add_constraint(
model.last_constraint_index += 1
info = _ConstraintInfo(length(model.indicator_constraint_info) + 1, s)
model.indicator_constraint_info[model.last_constraint_index] = info
_require_update(model)
_require_update(model, model_change = true)
return MOI.ConstraintIndex{typeof(func),typeof(s)}(
model.last_constraint_index,
)
Expand Down Expand Up @@ -180,22 +180,22 @@ function MOI.set(
name::String,
) where {S<:MOI.Indicator}
MOI.throw_if_not_valid(model, c)
_update_if_necessary(model)
_update_if_necessary(model, check_attribute_change = false)
info = _info(model, c)
info.name = name
if !isempty(name)
row = Cint(_info(model, c).row - 1)
ret = GRBsetstrattrelement(model, "GenConstrName", row, name)
_check_ret(model, ret)
end
_require_update(model, attribute_change = true)
return
end

function MOI.delete(
model::Optimizer,
c::MOI.ConstraintIndex{<:MOI.VectorAffineFunction,<:MOI.Indicator},
)
_update_if_necessary(model)
MOI.throw_if_not_valid(model, c)
row = _info(model, c).row
ind = Ref{Cint}(row - 1)
Expand All @@ -207,6 +207,6 @@ function MOI.delete(
info.row -= 1
end
end
_require_update(model)
_update_if_necessary(model, force = true)
return
end
1 change: 0 additions & 1 deletion src/MOI_wrapper/MOI_multi_objective.jl
Expand Up @@ -36,7 +36,6 @@ function MOI.set(
obj[column] += term.coefficient
end
indices, coefficients = _indices_and_coefficients(model, f)
_update_if_necessary(model)
ret = GRBsetobjectiven(
model,
Cint(attr.index - 1),
Expand Down