Skip to content
Merged
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
11 changes: 11 additions & 0 deletions src/Utilities/cachingoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ MOI.is_empty(m::CachingOptimizer) = MOI.is_empty(m.model_cache)

function MOI.optimize!(m::CachingOptimizer)
if m.mode == AUTOMATIC && m.state == EMPTY_OPTIMIZER
# Here is a special case for callbacks: we can't use the two-argument
# call to optimize! because we need the `optimizer_to_model_map` to be
# set _prior_ to starting the optimization process. Therefore, we need
# to check if we have an `AbstractCallback` set and attach the optimizer
# before recalling `MOI.optimize!`.
for attr in MOI.get(m, MOI.ListOfModelAttributesSet())
if attr isa MOI.AbstractCallback
attach_optimizer(m)
return MOI.optimize!(m)
end
end
indexmap, copied = MOI.optimize!(m.optimizer, m.model_cache)
if copied
m.state = ATTACHED_OPTIMIZER
Expand Down