Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
emmt committed Jan 29, 2024
1 parent 46bc9b5 commit 95be802
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
8 changes: 2 additions & 6 deletions ext/PRIMACUTEstExt.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
module PRIMACUTEstExt

if isdefined(Base, :get_extension)
using NLPModels
using CUTEst
using PRIMA
using PRIMA, CUTEst
else
using ..NLPModels
using ..CUTEst
using ..PRIMA
using ..PRIMA, ..CUTEst
end

for func in (:uobyqa, :newuoa, :bobyqa, :lincoa, :cobyla, :prima)
Expand Down
8 changes: 3 additions & 5 deletions ext/PRIMANLPModelsExt.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
module PRIMANLPModelsExt

if isdefined(Base, :get_extension)
using NLPModels
using PRIMA
using PRIMA, NLPModels
else
using ..NLPModels
using ..PRIMA
using ..PRIMA, ..NLPModels
end

# This structure is to wrap a non-linear problem model into a callable object.
struct ObjectiveFunction{F<:AbstractNLPModel} <: Function
nlp::F
end
(f::ObjectiveFunction)(x::AbstractVector) = obj(f.nlp, x)
(f::ObjectiveFunction)(x::AbstractVector) = NLPModels.obj(f.nlp, x)

function check_variables(nlp::AbstractNLPModel, x0::AbstractVector)
length(x0) == get_nvar(nlp) || error(
Expand Down

0 comments on commit 95be802

Please sign in to comment.