Skip to content
Closed
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
72 changes: 72 additions & 0 deletions src/ParametricOptInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,78 @@ function MOI.set(
MOI.set(model.optimizer, MOI.ConstraintFunction(), c, f)
return
end
function MOI.set(
model::Optimizer,
::MOI.ConstraintFunction,
c::MOI.ConstraintIndex{MOI.ScalarAffineFunction{T},S},
f::F,
) where {T,S<:MOI.AbstractSet,F}
if haskey(model.affine_added_cache, c)
MOI.set(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks too simple, don't we have any other data cached for affine function in the POI.Optimizer?

model.optimizer,
MOI.ConstraintFunction(),
model.affine_added_cache[c],
f,
)
else
MOI.set(model.optimizer, MOI.ConstraintFunction(), c, f)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also strange, you might have parameters in f

end
return
end
function MOI.set(
model::Optimizer,
::MOI.ConstraintFunction,
c::MOI.ConstraintIndex{MOI.ScalarQuadraticFunction{T},S},
f::F,
) where {T,S<:MOI.AbstractSet,F}
if haskey(model.quadratic_added_cache, c)
MOI.set(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

model.optimizer,
MOI.ConstraintFunction(),
model.quadratic_added_cache[c],
f,
)
else
MOI.set(model.optimizer, MOI.ConstraintFunction(), c, f)
end
return
end
function MOI.set(
model::Optimizer,
::MOI.ConstraintSet,
c::MOI.ConstraintIndex{MOI.ScalarQuadraticFunction{T},S},
s::S,
) where {T,S<:MOI.AbstractSet}
if haskey(model.quadratic_added_cache, c)
MOI.set(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

model.optimizer,
MOI.ConstraintSet(),
model.quadratic_added_cache[c],
s,
)
else
MOI.set(model.optimizer, MOI.ConstraintSet(), c, s)
end
return
end
function MOI.set(
model::Optimizer,
::MOI.ConstraintSet,
c::MOI.ConstraintIndex{MOI.ScalarAffineFunction{T},S},
s::S,
) where {T,S<:MOI.AbstractSet}
if haskey(model.affine_added_cache, c)
MOI.set(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

model.optimizer,
MOI.ConstraintSet(),
model.affine_added_cache[c],
s,
)
else
MOI.set(model.optimizer, MOI.ConstraintSet(), c, s)
end
return
end
function MOI.set(
model::Optimizer,
::MOI.ConstraintSet,
Expand Down