From 0586dde917850c1238f57cdeb2f5b7578524ed62 Mon Sep 17 00:00:00 2001 From: "Stephen J. Maher" Date: Fri, 15 May 2026 14:32:54 +0100 Subject: [PATCH 1/3] more consistent whitespace --- ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl b/ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl index 72ab084..5d28e9b 100644 --- a/ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl +++ b/ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl @@ -114,6 +114,7 @@ function empty_cache!(cache) return cache end + ### ### Some defines used for specifying the supported constraints ### @@ -187,7 +188,6 @@ function MOI.empty!(model::Optimizer) end - ### ### get, set and supports functions for various Optimizer attributes ### @@ -204,6 +204,7 @@ function MOI.get(::Optimizer, ::MOI.SolverVersion)::String return string(major[], ".", minor[], ".", patch[]) end + # raw solver MOI.get(model::Optimizer, ::MOI.RawSolver) = model.inner.cntvect @@ -357,6 +358,7 @@ function MOI.supports_constraint( return true end + ### ### indicate the types of objectives that CONOPT supports ### @@ -381,6 +383,7 @@ function MOI.set(model::Optimizer, ::MOI.ObjectiveSense, sense::MOI.Optimization return nothing end + ### ### _EmptyNLPEvaluator ### @@ -555,6 +558,7 @@ function _setup_options!(dest::Optimizer) return dest.inner.license.license_string = dest.license_string end + """ function _update_variable_bounds!(model_data::ModelData, var_index::Int; lower::Float64 = -Inf, upper::Float64 = Inf) @@ -616,7 +620,6 @@ function _setup_variables!(dest::Optimizer, src::MOI.ModelLike) end - """ function _set_objective_sense!(model::Optimizer, sense::MOI.OptimizationSense) @@ -1008,7 +1011,6 @@ function setup_model!(dest::Optimizer, src::MOI.ModelLike) end - """ function setup_inner!(model::Optimizer) @@ -1026,7 +1028,6 @@ end ### Optimize ### - """ function MOI.optimize!(dest::Optimizer, src::MOI.ModelLike) @@ -1116,12 +1117,15 @@ function MOI.get(model::Optimizer, ::MOI.TerminationStatus) return MOI.OPTIMIZE_NOT_CALLED end + # raw status string explaining why the solver stopped MOI.get(model::Optimizer, ::MOI.RawStatusString) = model.inner.solution_status.raw_status + # solving time in seconds MOI.get(model::Optimizer, ::MOI.SolveTimeSec) = model.solve_time + # the primal status - the status of the primal solution function MOI.get(model::Optimizer, attr::MOI.PrimalStatus) if CONOPT.is_empty(model.inner) @@ -1298,7 +1302,6 @@ end ### Utilities ### - """ function print_model_representation(jac, data) From d5a694deb7c40266b7fe67045e3c7b7abf5bbce7 Mon Sep 17 00:00:00 2001 From: "Stephen J. Maher" Date: Fri, 15 May 2026 14:54:17 +0100 Subject: [PATCH 2/3] fixes formatter check --- .github/workflows/format_check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml index 1609b1c..3f67b20 100644 --- a/.github/workflows/format_check.yml +++ b/.github/workflows/format_check.yml @@ -20,7 +20,8 @@ jobs: using Pkg Pkg.add(PackageSpec(name="JuliaFormatter", version="2")) using JuliaFormatter - format("src/MOI_wrapper", verbose=true) + format("src") + format("ext/ConoptMathOptInterfaceExt", verbose=true) format("test", verbose=true) out = String(read(Cmd(`git diff`))) if isempty(out) From 93efb3badb311fcbf03806c475ec7075df3ed851 Mon Sep 17 00:00:00 2001 From: "Stephen J. Maher" Date: Fri, 15 May 2026 15:01:47 +0100 Subject: [PATCH 3/3] formatting --- .../ConoptMathOptInterfaceExt.jl | 3 +-- ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl | 12 ++++-------- src/C_wrapper.jl | 2 +- test/MOI_wrapper.jl | 13 ++++--------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/ext/ConoptMathOptInterfaceExt/ConoptMathOptInterfaceExt.jl b/ext/ConoptMathOptInterfaceExt/ConoptMathOptInterfaceExt.jl index e1bb211..9c8d8cf 100644 --- a/ext/ConoptMathOptInterfaceExt/ConoptMathOptInterfaceExt.jl +++ b/ext/ConoptMathOptInterfaceExt/ConoptMathOptInterfaceExt.jl @@ -35,8 +35,7 @@ PrecompileTools.@setup_workload begin # Add a nonlinear objective MOI.set(src, MOI.ObjectiveSense(), MOI.MAX_SENSE) f_nl = MOI.ScalarNonlinearFunction( - :+, - Any[MOI.ScalarNonlinearFunction(:sin, Any[x[i]]) for i in 1:3], + :+, Any[MOI.ScalarNonlinearFunction(:sin, Any[x[i]]) for i in 1:3] ) MOI.set(src, MOI.ObjectiveFunction{typeof(f_nl)}(), f_nl) diff --git a/ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl b/ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl index 5d28e9b..5bc7b30 100644 --- a/ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl +++ b/ext/ConoptMathOptInterfaceExt/MOI_wrapper.jl @@ -9,7 +9,7 @@ mutable struct Optimizer <: MOI.AbstractOptimizer name::String # name of the model # parameters - time_limit::Union{Real,Nothing} # time limit in seconds + time_limit::Union{Real, Nothing} # time limit in seconds log_level::Int # the log level threads::Int # number of threads (0 is default, tells CONOPT to use the maximum number of threads) silent::Bool # should the output be disabled @@ -119,11 +119,7 @@ end ### Some defines used for specifying the supported constraints ### -const _SETS = Union{ - MOI.GreaterThan{Float64}, - MOI.LessThan{Float64}, - MOI.EqualTo{Float64}, -} +const _SETS = Union{MOI.GreaterThan{Float64}, MOI.LessThan{Float64}, MOI.EqualTo{Float64}} const _FUNCTIONS = Union{ MOI.VariableIndex, @@ -602,7 +598,7 @@ function _setup_variables!(dest::Optimizer, src::MOI.ModelLike) dest.var_index_to_pos = zeros(Int, max_index) dest.inner.model_data.variable_primal_start = zeros(Float64, n_vars) - dest.inner.model_data.variable_lower = fill(-dest.lim_variable, n_vars) #= ah, that's probably where you would need lim_variable, because if the user chooses a different value for CONOPT, this would not be correct =# + dest.inner.model_data.variable_lower = fill(-dest.lim_variable, n_vars) dest.inner.model_data.variable_upper = fill(dest.lim_variable, n_vars) for (i, v) in enumerate(dest.variable_indices) @@ -1087,7 +1083,7 @@ function MOI.get(model::Optimizer, ::MOI.TerminationStatus) return MOI.DUAL_INFEASIBLE elseif model_status == CONOPT.ModelStatus_Infeasible #return MOI.INFEASIBLE_OR_UNBOUNDED # we don't return INFEASIBLE_OR_UNBOUNDED because - # CONOPT is a local solver. + # CONOPT is a local solver. return MOI.LOCALLY_INFEASIBLE elseif model_status == CONOPT.ModelStatus_Locally_Infeasible return MOI.LOCALLY_INFEASIBLE diff --git a/src/C_wrapper.jl b/src/C_wrapper.jl index 4688822..b2e4e88 100644 --- a/src/C_wrapper.jl +++ b/src/C_wrapper.jl @@ -192,7 +192,7 @@ mutable struct ConoptModel cntvect::Ref{Ptr{Cvoid}} # pointer to the CONOPT control vector silent::Bool # whether CONOPT output should be suppressed: affects the output callbacks of CONOPT log_level::Int # the log level for the CONOPT output. This matches the C++ verbosity levels - time_limit::Union{Float64,Nothing} # the solver time limit + time_limit::Union{Float64, Nothing} # the solver time limit threads::Int # the number of threads to use options::Dict{String, Any} # solver options option_offset::Int # offset for invalid options diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index ea58b6e..78ce77e 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -31,9 +31,7 @@ implemented or that your solver doesn't support. """ function test_runtests() model = MOI.instantiate( - CONOPT.Optimizer; - with_bridge_type=Float64, - with_cache_type=Float64, + CONOPT.Optimizer; with_bridge_type=Float64, with_cache_type=Float64 ) MOI.set(model, MOI.Silent(), true) config = MOI.Test.Config(; @@ -52,15 +50,12 @@ function test_runtests() ], ) MOI.Test.runtests( - model, - config; - exclude=[ + model, config; exclude=[ # CONOPT is a local solver r"^test_nonlinear_hs071_global$", - ], - verbose=true, + ], verbose=true ) - return + return nothing end """