diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index ec735d3..564f113 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -1177,6 +1177,7 @@ function MOI.optimize!(model::Optimizer) eval_jac_g_cb, has_hessian ? eval_h_cb : nothing, num_linear_constraints, + objective_scale == -1 ? :Max : :Min, model.options ) options = model.inner.parameters diff --git a/src/algorithms/sqp_trust_region.jl b/src/algorithms/sqp_trust_region.jl index 09a0efa..fd39b06 100644 --- a/src/algorithms/sqp_trust_region.jl +++ b/src/algorithms/sqp_trust_region.jl @@ -606,7 +606,8 @@ function print(sqp::AbstractSqpTrOptimizer, status_mark = " ") st = ifelse(sqp.feasibility_restoration, "FR", status_mark) @printf("%2s%6d", st, sqp.iter) @printf("%1s", ifelse(sqp.step_acceptance, "a", "r")) - @printf(" %+6.8e", sqp.f) + objective_scale = sqp.problem.sense == :Min ? 1 : -1 + @printf(" %+6.8e", sqp.f * objective_scale) @printf(" %+6.8e", sqp.phi) @printf(" %+6.8e", sqp.μ) @printf(" %+6.8e", norm(sqp.lambda,Inf)) diff --git a/src/model.jl b/src/model.jl index 979a082..397b374 100644 --- a/src/model.jl +++ b/src/model.jl @@ -49,6 +49,7 @@ mutable struct Model{T,TD} <: AbstractSqpModel eval_jac_g::Function, eval_h::Union{Function,Nothing}, num_linear_constraints::Int, + sense::Symbol, # {:Min, :Max} parameters::Parameters ) where {T, TD<:AbstractArray{T}} = new{T,TD}( n, m, @@ -60,7 +61,7 @@ mutable struct Model{T,TD} <: AbstractSqpModel -5, eval_f, eval_g, eval_grad_f, eval_jac_g, eval_h, num_linear_constraints, - nothing, :Min, + nothing, sense, parameters, Dict{String,Any}() )