diff --git a/src/build_sequences.jl b/src/build_sequences.jl index a8157cfc577b97f732a10c97cf103def5018e789..be3da753647a2ca8ae76aa23de6b794c6148bc93 100644 --- a/src/build_sequences.jl +++ b/src/build_sequences.jl @@ -71,16 +71,16 @@ function build_sequence(f::Function, scanner::Union{Nothing, Scanner}, model::Mo end end -function build_sequence(f::Function, ::Nothing; optimise=false) - build_sequence(f, nothing, global_model(), optimise) -end - -function build_sequence(f::Function, scanner::Scanner, optimiser_constructor; optimise=true, kwargs...) - model = Model(optimizer_with_attributes(optimiser_constructor, [string(k) => v for (k, v) in kwargs]...)) +function build_sequence(f::Function, scanner::Union{Nothing, Scanner}, optimiser_constructor; optimise=true, kwargs...) + if optimise || GLOBAL_MODEL[] == IGNORE_MODEL + model = Model(optimizer_with_attributes(optimiser_constructor, [string(k) => v for (k, v) in kwargs]...)) + else + model = global_model() + end build_sequence(f, scanner, model, optimise) end -function build_sequence(f::Function, scanner::Scanner; print_level=2, kwargs...) +function build_sequence(f::Function, scanner::Union{Nothing, Scanner}; print_level=2, kwargs...) build_sequence(f, scanner, Ipopt.Optimizer; print_level=print_level, kwargs...) end