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
26 changes: 18 additions & 8 deletions src/Utilities/cachingoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,15 @@ end
# ConstraintSet and ConstraintFunction methods, but allows us to strongly type
# the third and fourth arguments of the set methods so that we only support
# setting the same type of set or function.
function replace_constraint_function_or_set(
function _replace_constraint_function_or_set(
m::CachingOptimizer,
attr,
cindex,
replacement,
)
replacement_optimizer = map_indices(m.model_to_optimizer_map, replacement)
if m.state == ATTACHED_OPTIMIZER
replacement_optimizer =
map_indices(m.model_to_optimizer_map, replacement)
if m.mode == AUTOMATIC
try
MOI.set(
Expand Down Expand Up @@ -587,25 +588,34 @@ function MOI.set(
cindex::CI{F,S},
set::S,
) where {F,S}
replace_constraint_function_or_set(m, MOI.ConstraintSet(), cindex, set)
_replace_constraint_function_or_set(m, MOI.ConstraintSet(), cindex, set)
return
end

function MOI.set(
m::CachingOptimizer,
model::CachingOptimizer,
::MOI.ConstraintFunction,
cindex::CI{F},
cindex::MOI.ConstraintIndex{F,S},
func::F,
) where {F}
replace_constraint_function_or_set(
m,
) where {F,S}
Copy link
Member

@blegat blegat Jul 6, 2021

Choose a reason for hiding this comment

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

What's the point of having S here ?

_replace_constraint_function_or_set(
model,
MOI.ConstraintFunction(),
cindex,
func,
)
return
end

function MOI.set(
::CachingOptimizer,
::MOI.ConstraintFunction,
::MOI.ConstraintIndex{MOI.SingleVariable,S},
::MOI.SingleVariable,
) where {S}
return throw(MOI.SettingSingleVariableFunctionNotAllowed())
end

function MOI.modify(
m::CachingOptimizer,
obj::MOI.ObjectiveFunction,
Expand Down
Loading