Skip to content

Commit

Permalink
fixes empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinKaisermayer committed Oct 26, 2022
1 parent 051fc87 commit 106c7c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/OptimizationMOI/src/OptimizationMOI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function _create_new_optimizer(model::MOI.OptimizerWithAttributes)
end

function _create_new_optimizer(model::MOI.AbstractOptimizer)
MOI.empty!(model) # important! ensure that the optimizer is empty
if MOI.supports_incremental_interface(model)
return model
end
Expand All @@ -36,8 +37,7 @@ function _create_new_optimizer(model::MOI.AbstractOptimizer)
end

function __map_optimizer_args(cache,
opt::Union{MOI.AbstractOptimizer, MOI.OptimizerWithAttributes
};
opt::Union{MOI.AbstractOptimizer, MOI.OptimizerWithAttributes};
maxiters::Union{Number, Nothing} = nothing,
maxtime::Union{Number, Nothing} = nothing,
abstol::Union{Number, Nothing} = nothing,
Expand Down
6 changes: 3 additions & 3 deletions lib/OptimizationMOI/src/moi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function MOIOptimizationCache(prob::OptimizationProblem, opt)
opt)
end

function reinit!(cache::MOIOptimizationCache; p = nothing)
SciMLBase.has_reinit(cache::MOIOptimizationCache) = true
function SciMLBase.reinit!(cache::MOIOptimizationCache; p = nothing)
if !isnothing(p)
cache.p = p
end
Expand Down Expand Up @@ -93,7 +94,6 @@ function SciMLBase.solve(cache::MOIOptimizationCache;
kwargs...)
maxiters = Optimization._check_and_convert_maxiters(maxiters)
maxtime = Optimization._check_and_convert_maxtime(maxtime)
MOI.empty!(cache.opt) # important! ensure that the optimizer is empty
opt_setup = __map_optimizer_args(cache,
cache.opt;
abstol = abstol,
Expand Down Expand Up @@ -308,7 +308,7 @@ end

function is_equality(expr::Expr)
expr.head == :call || throw(MalformedExprException("$expr"))
expr.args[1] == :(=)
expr.args[1] in [:(==), :(=)]
end

function is_inequality(expr::Expr)
Expand Down
4 changes: 2 additions & 2 deletions lib/OptimizationMOI/src/nlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ function MOIOptimizationNLPCache(prob::OptimizationProblem, opt)
return MOIOptimizationNLPCache(evaluator, opt)
end

function reinit!(cache::MOIOptimizationNLPCache; p = nothing)
SciMLBase.has_reinit(cache::MOIOptimizationNLPCache) = true
function SciMLBase.reinit!(cache::MOIOptimizationNLPCache; p = nothing)
if !isnothing(p)
cache.evaluator.reinit_cache.p = p
end
Expand Down Expand Up @@ -326,7 +327,6 @@ function SciMLBase.solve(cache::MOIOptimizationNLPCache;
kwargs...)
maxiters = Optimization._check_and_convert_maxiters(maxiters)
maxtime = Optimization._check_and_convert_maxtime(maxtime)
MOI.empty!(cache.opt) # important! ensure that the optimizer is empty
opt_setup = __map_optimizer_args(cache,
cache.opt;
abstol = abstol,
Expand Down

0 comments on commit 106c7c6

Please sign in to comment.