SciML / Optimization.jl

Mathematical Optimization in Julia. Local, global, gradient-based and derivative-free. Linear, Quadratic, Convex, Mixed-Integer, and Nonlinear Optimization in one simple, fast, and differentiable interface.
https://docs.sciml.ai/Optimization/stable/
MIT License
688 stars 75 forks source link

`MethodError: objects of type Nothing are not callable` when `lb` and `ub` are used with `NelderMead` #713

Closed rafaqz closed 1 month ago

rafaqz commented 4 months ago

Describe the bug 🐞

When optimizing with NelderMead() things work completely fine unless I use lb and ub keywords. When I try to enforce bounds (between zero and one for all parameters) Optimizatin.jl for some reason calls grad! some way into the optimization, but it looks like cache.f.grad here is nothing for NelderMead: https://github.com/SciML/Optimization.jl/blob/038c7b6bd34111cd4a2fdb74886bf7c05a026c30/lib/OptimizationOptimJL/src/OptimizationOptimJL.jl#L291

I'm not sure why grad! is called on a gradient free method.

Expected behavior

The optimisation should run as normal with lb/ub args

Minimal Reproducible Example πŸ‘‡

I have a complicated simulation behind the objective function, and the error only comes half way through optimizing it. So, not sure how to make an MWE. I'm not sure how this can happen or what is triggering it.

But this is essentially it, without the exact objective func:

ub = fill(Float32(1.0), 35)
lb = fill(Float32(0.0), 35)
x0 = rand(Float32, 35)
prob = OptimizationProblem(objective_func, x0, p; lb, ub)
@time sol = solve(prob, NelderMead())

Error & Stacktrace ⚠️

ERROR: MethodError: objects of type Nothing are not callable
Stacktrace:
  [1] (::OptimizationOptimJL.var"#20#24"{OptimizationCache{…}})(G::Vector{Float64}, ΞΈ::Vector{Float64})
    @ OptimizationOptimJL ~/.julia/packages/OptimizationOptimJL/yMF3E/src/OptimizationOptimJL.jl:291
  [2] gradient!!(obj::OnceDifferentiable{Float64, Vector{Float64}, Vector{Float64}}, x::Vector{Float64})
    @ NLSolversBase ~/.julia/packages/NLSolversBase/kavn7/src/interface.jl:63
  [3] gradient!
    @ ~/.julia/packages/NLSolversBase/kavn7/src/interface.jl:51 [inlined]
  [4] gradient!(obj::Optim.BarrierWrapper{OnceDifferentiable{Float64, Vector{Float64}, Vector{Float64}}, Optim.BoxBarrier{Vector{Float64}, Vector{Float64}}, Float64, Float64, Vector{Float64}}, x::Vector{Float
64})
    @ Optim ~/.julia/packages/Optim/EJwLF/src/multivariate/solvers/constrained/fminbox.jl:118
  [5] optimize(df::OnceDifferentiable{…}, l::Vector{…}, u::Vector{…}, initial_x::Vector{…}, F::Fminbox{…}, options::Optim.Options{…})
    @ Optim ~/.julia/packages/Optim/EJwLF/src/multivariate/solvers/constrained/fminbox.jl:327
  [6] __solve(cache::OptimizationCache{…})
    @ OptimizationOptimJL ~/.julia/packages/OptimizationOptimJL/yMF3E/src/OptimizationOptimJL.jl:306
  [7] solve!
    @ ~/.julia/packages/SciMLBase/wVDwN/src/solve.jl:179 [inlined]
  [8] #solve#596
    @ ~/.julia/packages/SciMLBase/wVDwN/src/solve.jl:96 [inlined]
  [9] solve(::OptimizationProblem{…}, ::NelderMead{…})
    @ SciMLBase ~/.julia/packages/SciMLBase/wVDwN/src/solve.jl:93
 [10] macro expansion
    @ ./timing.jl:279 [inlined]
 [11] top-level scope
    @ ./REPL[44]:1
Some type information was truncated. Use `show(err)` to see complete types.

Environment (please complete the following information):

  [85c772de] AbstractNumbers v0.2.5
  [79e6a3ab] Adapt v4.0.1
  [4c88cf16] Aqua v0.8.4
  [c9ce4bd3] ArchGDAL v0.10.2
  [69666777] Arrow v2.7.1
  [6e4b80f9] BenchmarkTools v1.4.0
  [336ed68f] CSV v0.10.12
  [052768ef] CUDA v5.2.0
  [13f3f980] CairoMakie v0.11.8
  [35d6a980] ColorSchemes v3.24.0
  [5ae59095] Colors v0.12.10
  [187b0558] ConstructionBase v1.5.4
  [f68482b8] Cthulhu v2.11.0
  [75c7ada1] DBFTables v1.2.4
  [a93c6f00] DataFrames v1.6.1
  [85a47980] Dictionaries v0.4.1
  [0703355e] DimensionalData v0.25.8 `~/.julia/dev/DimensionalData`
  [3c3547ce] DiskArrays v0.3.22 `~/.julia/dev/DiskArrays`
  [8797f018] Dispersal v0.7.0 `~/.julia/dev/Dispersal`
  [31c24e10] Distributions v0.25.107
  [a5dba43e] DynamicGrids v0.21.4 `~/.julia/dev/DynamicGrids`
  [411431e0] Extents v0.1.2
  [5789e2e9] FileIO v1.16.2
  [53c48c17] FixedPointNumbers v0.8.4
  [a8dd9ffe] GADM v1.1.0
  [dedd4f52] GBIF2 v0.2.1
  [38e38edf] GLM v1.9.0
  [e9467ef8] GLMakie v0.9.8
  [68eda718] GeoFormatTypes v0.4.2
  [cf35fbd7] GeoInterface v1.3.3
  [0edc0954] GeoInterfaceMakie v0.1.5
  [61d90e0f] GeoJSON v0.8.0
  [5c1252a2] GeometryBasics v0.4.10
  [3251bfac] GeometryOps v0.0.1-DEV `~/.julia/dev/GeometryOps`
  [714e3e49] Geomorphometry v0.6.0
  [cd3eb016] HTTP v1.10.2
  [82e4d734] ImageIO v0.6.7
βŒƒ [6218d12a] ImageMagick v1.2.1
  [80713f31] ImageSegmentation v1.7.0 `~/.julia/dev/ImageSegmentation`
  [41ab1584] InvertedIndices v1.3.0
  [033835bb] JLD2 v0.4.46
  [0f8b85d8] JSON3 v1.14.0
  [63c18a36] KernelAbstractions v0.9.15 `~/.julia/dev/KernelAbstractions`
  [10a95938] LandscapeChange v0.1.0 `~/.julia/dev/LandscapeChange`
βŒƒ [a90b1aa1] LibGEOS v0.8.5
  [30fc2ffe] LossFunctions v0.11.1
  [ee78f7c6] Makie v0.20.7
  [20f20a25] MakieCore v0.7.3
  [8315f7d3] MakieDraw v0.2.1 `~/.julia/dev/MakieDraw`
  [a6417e2b] MapRasterization v0.1.0 `~/.julia/dev/MapRasterization`
  [fea52e5a] MapTiles v1.0.1
  [4744a3fa] ModelParameters v0.4.0 `~/.julia/dev/ModelParameters`
  [5deeb4b9] Mousetrap v0.3.1 `~/.julia/dev/Mousetrap`
  [aebf437e] MousetrapMakie v0.1.0 `~/.julia/dev/MousetrapMakie`
βŒƒ [85f8d34a] NCDatasets v0.13.2
  [6fe1bfb0] OffsetArrays v1.13.0
  [5fb14364] OhMyREPL v0.5.24
  [7f7a1694] Optimization v3.22.0
  [36348300] OptimizationOptimJL v0.2.2
  [90014a1f] PDMats v0.11.31
  [14b8a8f1] PkgTemplates v0.7.48
  [91a5bcdd] Plots v1.40.1
  [c46f51b8] ProfileView v1.7.2
  [3cb90ccd] RasterDataSources v0.5.7
  [a3a2b9e3] Rasters v0.10.1 `~/.julia/dev/Rasters`
  [cbe49d4c] RemoteFiles v0.5.0
  [295af30f] Revise v3.5.14
  [6038ab10] Rotations v1.7.0
  [1bc83da4] SafeTestsets v0.1.0
  [daca4e5c] SegmentAnything v0.1.0
  [efcf1570] Setfield v1.1.1
  [8e980c4a] Shapefile v0.12.0
  [27459e48] SpaceInvaders v1.0.1
  [90137ffa] StaticArrays v1.9.2
  [a5f81324] StaticBitArrays v0.1.0 `~/.julia/dev/StaticBitArrays`
βŒ… [2913bbd2] StatsBase v0.33.21
  [f3b207a7] StatsPlots v0.15.7
  [264155e8] Stencils v0.2.4 `~/.julia/dev/Stencils`
  [bd369af6] Tables v1.11.1
  [0c614874] TerminalPager v0.5.1
  [ac1d9e8a] ThreadsX v0.1.12
  [263fe934] TileProviders v0.1.3
  [fce5fe82] Turing v0.30.5
  [e170d443] Tyler v0.1.1 `~/.julia/dev/Tyler`
  [bee2e7eb] TypeArrays v1.0.0-DEV `~/.julia/dev/TypeArrays`
  [1986cc42] Unitful v1.19.0
  [276b4fcb] WGLMakie v0.9.7
  [fdbf4ff8] XLSX v0.10.1
  [c21b50f5] YAXArrays v0.5.3
  [287f9a42] libmousetrap_jll v0.3.0+0 `https://github.com/clemapfel/mousetrap_jll#main`
  [47edcb42] ADTypes v0.2.6
  [a4c015fc] ANSIColoredPrinters v0.0.1
  [81770e7c] ASCIIrasters v0.1.1
  [621f4979] AbstractFFTs v1.5.0
  [398f06c4] AbstractLattices v0.3.0
  [80f14c24] AbstractMCMC v5.1.0
  [85c772de] AbstractNumbers v0.2.5
  [7a57a42e] AbstractPPL v0.7.0
  [1520ce14] AbstractTrees v0.4.5
  [7d9f7c33] Accessors v0.1.35
  [79e6a3ab] Adapt v4.0.1
  [0bf59076] AdvancedHMC v0.6.1
  [5b7e9947] AdvancedMH v0.8.1
  [576499cb] AdvancedPS v0.5.4
  [b5ca4192] AdvancedVI v0.2.4
  [27a7e980] Animations v0.4.1
  [4c88cf16] Aqua v0.8.4
  [c9ce4bd3] ArchGDAL v0.10.2
  [dce04be8] ArgCheck v2.3.0
  [c7e460c6] ArgParse v1.1.5
βŒ… [ec485272] ArnoldiMethod v0.2.0
  [7d9fca2a] Arpack v0.5.4
  [4fba245c] ArrayInterface v7.7.1
  [4c555306] ArrayLayouts v1.6.0
  [69666777] Arrow v2.7.1
  [31f734f8] ArrowTypes v2.3.0
  [bf4720bc] AssetRegistry v0.1.0
  [a9b6321e] Atomix v0.1.0
βŒ… [15f4f7f2] AutoHashEquals v0.2.0
  [67c07d97] Automa v1.0.3
βŒƒ [13072b0f] AxisAlgorithms v1.0.1
  [39de3d68] AxisArrays v0.4.7
βŒƒ [ab4f0b2a] BFloat16s v0.4.2
  [093aae92] BSplineKit v0.17.1
  [aae01518] BandedMatrices v1.5.0
βŒ… [198e06fe] BangBang v0.3.40
  [9718e550] Baselet v0.1.1
  [6e4b80f9] BenchmarkTools v1.4.0
  [76274a88] Bijectors v0.13.8
  [12aac903] BinaryBuilder v0.5.8
  [7f725544] BinaryBuilderBase v1.29.0
  [d1d4a3ce] BitFlags v0.1.8
  [c3b6d118] BitIntegers v0.3.1
  [824d6782] Bonito v3.0.4
βŒ… [fa961155] CEnum v0.4.2
  [179af706] CFTime v0.1.2
  [96374032] CRlibm v1.0.1
  [336ed68f] CSV v0.10.12
  [052768ef] CUDA v5.2.0
  [1af6417a] CUDA_Runtime_Discovery v0.2.3
  [159f3aea] Cairo v1.0.5
  [13f3f980] CairoMakie v0.11.8
  [49dc2e85] Calculus v0.5.1
  [aafaddc9] CatIndices v0.2.2
  [082447d4] ChainRules v1.63.0
  [d360d2e6] ChainRulesCore v1.22.0
  [9e997f8a] ChangesOfVariables v0.1.8
βŒ… [aaaa29a8] Clustering v0.14.4
  [da1fd8a2] CodeTracking v1.3.5
  [523fee87] CodecBzip2 v0.8.2
  [5ba52731] CodecLz4 v0.4.3
  [944b1d66] CodecZlib v0.7.4
  [6b39b394] CodecZstd v0.8.2
  [a2cac450] ColorBrewer v0.4.0
  [35d6a980] ColorSchemes v3.24.0
  [3da002f7] ColorTypes v0.11.4
βŒ… [c3611d14] ColorVectorSpace v0.9.10
  [5ae59095] Colors v0.12.10
  [861a8166] Combinatorics v1.0.2
βŒ… [1fbeeb36] CommonDataModel v0.2.5
  [38540f10] CommonSolve v0.2.4
  [bbf7d656] CommonSubexpressions v0.3.0
  [34da2185] Compat v4.13.0
  [a33af91c] CompositionsBase v0.1.2
  [ed09eef8] ComputationalResources v0.3.2
  [f0e56b4a] ConcurrentUtilities v2.3.1
  [992eb4ea] CondaPkg v0.2.22
  [88cd18e8] ConsoleProgressMonitor v0.1.2
  [187b0558] ConstructionBase v1.5.4
  [d38c429a] Contour v0.6.2
  [150eb455] CoordinateTransformations v0.6.3
  [a8cc5b0e] Crayons v4.1.1
  [f68482b8] Cthulhu v2.11.0
  [dc8bdbbb] CustomUnitRanges v1.0.2
  [1f15a43c] CxxWrap v0.14.2
  [75c7ada1] DBFTables v1.2.4
  [9a962f9c] DataAPI v1.16.0
  [124859b0] DataDeps v0.7.13
  [a93c6f00] DataFrames v1.6.1
  [864edb3b] DataStructures v0.18.16
  [e2d170a0] DataValueInterfaces v1.0.0
  [244e2a9f] DefineSingletons v0.1.2
  [927a84f5] DelaunayTriangulation v0.8.12
  [8bb1440f] DelimitedFiles v1.9.1
  [b429d917] DensityInterface v0.4.0
  [85a47980] Dictionaries v0.4.1
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.15.1
  [0703355e] DimensionalData v0.25.8 `~/.julia/dev/DimensionalData`
  [fcd2136c] DiskArrayTools v0.1.9
  [3c3547ce] DiskArrays v0.3.22 `~/.julia/dev/DiskArrays`
  [8797f018] Dispersal v0.7.0 `~/.julia/dev/Dispersal`
  [b4f34e82] Distances v0.10.11
  [31c24e10] Distributions v0.25.107
  [ced4e74d] DistributionsAD v0.6.54
  [ffbed154] DocStringExtensions v0.9.3
  [e30172f5] Documenter v1.2.1
  [fa6b7ba4] DualNumbers v0.6.8
  [a5dba43e] DynamicGrids v0.21.4 `~/.julia/dev/DynamicGrids`
  [366bfd00] DynamicPPL v0.24.7
  [cad2338a] EllipticalSliceSampling v2.0.0
  [4e289a0a] EnumX v1.0.4
  [429591f6] ExactPredicates v2.2.8
  [460bff9d] ExceptionUnwrapping v0.1.10
  [e2ba6199] ExprTools v0.1.10
  [411431e0] Extents v0.1.2
  [8f5d6c58] EzXML v1.2.0
  [c87230d0] FFMPEG v0.4.1
  [4f61f5a4] FFTViews v0.3.2
  [7a1cc6ca] FFTW v1.8.0
  [442a2c76] FastGaussQuadrature v1.0.2
  [bf96fef3] FieldMetadata v0.3.1
  [5789e2e9] FileIO v1.16.2
  [8fc22ac5] FilePaths v0.8.3
  [48062228] FilePathsBase v0.9.21
  [1a297f60] FillArrays v1.9.3
  [6a86dc24] FiniteDiff v2.22.0
  [53c48c17] FixedPointNumbers v0.8.4
  [08572546] FlameGraphs v1.0.0
  [4c728ea3] Flatten v0.4.3
  [1eca21be] FoldingTrees v1.2.1
  [59287772] Formatting v0.4.2
  [f6369f11] ForwardDiff v0.10.36
  [b38be410] FreeType v4.1.1
  [663a7486] FreeTypeAbstraction v0.10.1
  [069b7b12] FunctionWrappers v1.1.3
  [77dc65aa] FunctionWrappersWrappers v0.1.3
  [d9f16b24] Functors v0.4.7
  [a8dd9ffe] GADM v1.1.0
  [dedd4f52] GBIF2 v0.2.1
βŒƒ [add2ef01] GDAL v1.6.1
  [f7f18e0c] GLFW v3.4.1
  [38e38edf] GLM v1.9.0
  [e9467ef8] GLMakie v0.9.8
  [0c68f7d7] GPUArrays v10.0.2
  [46192b85] GPUArraysCore v0.1.6
βŒ… [61eb1bfa] GPUCompiler v0.25.0
βŒƒ [28b8d3ca] GR v0.72.8
  [68eda718] GeoFormatTypes v0.4.2
  [cf35fbd7] GeoInterface v1.3.3
  [0edc0954] GeoInterfaceMakie v0.1.5
  [0329782f] GeoInterfaceRecipes v1.0.2
  [61d90e0f] GeoJSON v0.8.0
  [5c1252a2] GeometryBasics v0.4.10
  [3251bfac] GeometryOps v0.0.1-DEV `~/.julia/dev/GeometryOps`
  [714e3e49] Geomorphometry v0.6.0
  [d7ba0133] Git v1.3.0
  [8f6bce27] GitForge v0.4.2
  [bc5e4493] GitHub v5.9.0
  [c27321d9] Glob v1.3.1
  [a2bd30eb] Graphics v1.1.2
  [86223c79] Graphs v1.9.0
  [3955a311] GridLayoutBase v0.10.0
  [42e2da0e] Grisu v1.0.2
  [4c0ca9eb] Gtk v1.3.0
βŒ… [8710efd8] GtkObservables v1.2.9
  [cd3eb016] HTTP v1.10.2
  [9fb69e20] Hiccup v0.2.2
  [6df8b67a] HistoricalStdlibVersions v1.2.2
  [34004b35] HypergeometricFunctions v0.3.23
  [47d2ed2b] Hyperscript v0.0.5
  [b5f81e59] IOCapture v0.2.4
  [615f187c] IfElse v0.1.1
  [2803e5a7] ImageAxes v0.6.11
βŒƒ [c817782e] ImageBase v0.1.5
βŒ… [a09fc81d] ImageCore v0.9.4
βŒƒ [6a3955dd] ImageFiltering v0.7.6
  [82e4d734] ImageIO v0.6.7
βŒƒ [6218d12a] ImageMagick v1.2.1
  [bc367c6b] ImageMetadata v0.9.9
βŒ… [787d08f9] ImageMorphology v0.3.2
  [80713f31] ImageSegmentation v1.7.0 `~/.julia/dev/ImageSegmentation`
  [313cdc1a] Indexing v1.1.1
  [9b13fd28] IndirectArrays v1.0.0
  [d25df0c9] Inflate v0.1.4
  [22cec73e] InitialValues v0.3.1
  [842dd82b] InlineStrings v1.4.0
  [505f98c9] InplaceOps v0.3.0
  [18e54dd8] IntegerMathUtils v0.1.2
  [85a1e053] Interfaces v0.3.0
βŒ… [a98d9a8b] Interpolations v0.14.0
βŒ… [d1acc4aa] IntervalArithmetic v0.22.5
  [8197267c] IntervalSets v0.7.10
  [3587e190] InverseFunctions v0.1.12
  [41ab1584] InvertedIndices v1.3.0
  [92d709cd] IrrationalConstants v0.2.2
  [f1662d9f] Isoband v0.1.1
  [c8e1da08] IterTools v1.10.0
  [82899510] IteratorInterfaceExtensions v1.0.0
  [033835bb] JLD2 v0.4.46
  [1019f520] JLFzf v0.1.7
  [692b3bcd] JLLWrappers v1.5.0
  [682c06a0] JSON v0.21.4
  [0f8b85d8] JSON3 v1.14.0
  [b835a17e] JpegTurbo v0.1.5
  [aa1ae85d] JuliaInterpreter v0.9.29
  [70703baa] JuliaSyntax v0.4.8
  [63c18a36] KernelAbstractions v0.9.15 `~/.julia/dev/KernelAbstractions`
  [5ab0869b] KernelDensity v0.6.8
  [929cbde3] LLVM v6.5.0
  [8b046642] LLVMLoopInfo v1.0.0
  [8ac3fa9e] LRUCache v1.6.1
  [b964fa9f] LaTeXStrings v1.3.1
  [10a95938] LandscapeChange v0.1.0 `~/.julia/dev/LandscapeChange`
  [23fbe1c1] Latexify v0.16.1
  [0e77f7df] LazilyInitializedFields v1.2.2
  [50d2b5c4] Lazy v0.15.1
  [8cdb02fc] LazyModules v0.3.1
  [1d6d02ad] LeftChildRightSiblingTrees v0.2.0
βŒƒ [a90b1aa1] LibGEOS v0.8.5
  [6f1fad26] Libtask v0.8.6
  [9c8b4983] LightXML v0.9.1
  [d3d80556] LineSearches v7.2.0
  [9b3f67b0] LinearAlgebraX v0.2.7
βŒ… [085fde7c] LocalFilters v1.2.2
  [6fdf6af0] LogDensityProblems v2.1.1
  [996a588d] LogDensityProblemsAD v1.7.0
  [2ab3a3ac] LogExpFunctions v0.3.27
  [e6f89c97] LoggingExtras v1.0.3
  [30fc2ffe] LossFunctions v0.11.1
  [6f1432cf] LoweredCodeUtils v2.4.4
  [c7f686f2] MCMCChains v6.0.5
  [be115224] MCMCDiagnosticTools v0.3.10
  [e80e1ace] MLJModelInterface v1.9.5
  [1914dd2f] MacroTools v0.5.13
  [ee78f7c6] Makie v0.20.7
  [20f20a25] MakieCore v0.7.3
  [8315f7d3] MakieDraw v0.2.1 `~/.julia/dev/MakieDraw`
  [a6417e2b] MapRasterization v0.1.0 `~/.julia/dev/MapRasterization`
  [fea52e5a] MapTiles v1.0.1
  [dbb5928d] MappedArrays v0.4.2
  [d0879d2d] MarkdownAST v0.1.2
  [b8f27783] MathOptInterface v1.25.3
  [0a4f8689] MathTeXEngine v0.5.7
  [739be429] MbedTLS v1.1.9
  [442fdcdd] Measures v0.3.2
  [7269a6da] MeshIO v0.4.11
  [626554b9] MetaGraphs v0.7.2
  [85b6ec6f] MethodAnalysis v0.4.13
βŒ… [128add7d] MicroCollections v0.1.4
  [0b3b1443] MicroMamba v0.1.14
  [e1d29d7a] Missings v1.1.0
  [ff71e718] MixedModels v4.22.3
  [7e9fb7ac] MixedModelsDatasets v0.1.0
  [78c3b35d] Mocking v0.7.7
  [4744a3fa] ModelParameters v0.4.0 `~/.julia/dev/ModelParameters`
  [66fc600b] ModernGL v1.1.7
  [7475f97c] Mods v2.2.4
  [e94cdb99] MosaicViews v0.3.4
  [5deeb4b9] Mousetrap v0.3.1 `~/.julia/dev/Mousetrap`
  [aebf437e] MousetrapMakie v0.1.0 `~/.julia/dev/MousetrapMakie`
  [99f44e22] MsgPack v1.2.1
  [3b2b4ff1] Multisets v0.4.4
  [6f286f6a] MultivariateStats v0.10.2
  [ffc61752] Mustache v1.0.19
  [d8a4904e] MutableArithmetics v1.4.1
  [a975b10e] Mux v1.0.1
βŒƒ [85f8d34a] NCDatasets v0.13.2
  [d41bc354] NLSolversBase v7.8.3
  [76087f3c] NLopt v1.0.1
  [872c559c] NNlib v0.9.12
  [5da4648a] NVTX v0.3.4
  [77ba4419] NaNMath v1.0.2
  [86f7a689] NamedArrays v0.10.0
  [c020b1a1] NaturalSort v1.0.0
  [b8a86587] NearestNeighbors v0.4.16
  [f09324ee] Netpbm v1.1.1
  [d8793406] ObjectFile v0.4.1
  [510215fc] Observables v0.5.5
  [6fe1bfb0] OffsetArrays v1.13.0
  [5fb14364] OhMyREPL v0.5.24
  [a15396b6] OnlineStats v1.6.3
  [925886fa] OnlineStatsBase v1.6.2
  [52e1d378] OpenEXR v0.3.2
  [4d8831e6] OpenSSL v1.4.1
  [429524aa] Optim v1.9.2
  [3bd65402] Optimisers v0.3.2
  [7f7a1694] Optimization v3.22.0
  [36348300] OptimizationOptimJL v0.2.2
  [bac558e1] OrderedCollections v1.6.3
  [6c11c7d4] OutputCollectors v0.1.1
  [90014a1f] PDMats v0.11.31
  [f57f5aa1] PNGFiles v0.4.3
  [19eb6ba3] Packing v0.5.0
  [5432bcbf] PaddedViews v0.5.12
  [fad6cfc8] ParallelUtilities v0.8.6
  [d96e819e] Parameters v0.12.3
  [69de0a69] Parsers v2.8.1
  [2ae35dd2] Permutations v0.4.20
  [fa939f87] Pidfile v1.3.0
  [3bbf5609] PikaParser v0.6.1
  [b98c9c47] Pipe v1.3.0
  [fc669557] PkgLicenses v0.2.0
  [14b8a8f1] PkgTemplates v0.7.48
  [eebad327] PkgVersion v0.3.3
  [ccf2f8ad] PlotThemes v3.1.0
  [995b91a9] PlotUtils v1.4.0
  [91a5bcdd] Plots v1.40.1
  [647866c9] PolygonOps v0.1.2
  [f27b6e38] Polynomials v4.0.6
  [2dfb63ee] PooledArrays v1.4.3
  [85a6dd25] PositiveFactorizations v0.2.4
  [aea7be01] PrecompileTools v1.2.0
  [21216c6a] Preferences v1.4.1
  [08abe8d2] PrettyTables v2.3.1
  [27ebfcd6] Primes v0.5.5
  [c46f51b8] ProfileView v1.7.2
  [33c8b6b6] ProgressLogging v0.1.4
  [92933f4c] ProgressMeter v1.9.0
  [c94c279d] Proj v1.7.0
  [6099a3de] PythonCall v0.9.15
  [4b34888f] QOI v1.0.0
  [1fd47b50] QuadGK v2.9.4
  [94ee1d12] Quaternions v0.7.6
  [74087812] Random123 v1.6.2
  [e6cf234a] RandomNumbers v1.5.3
  [b3c3ace0] RangeArrays v0.3.2
  [3cb90ccd] RasterDataSources v0.5.7
  [a3a2b9e3] Rasters v0.10.1 `~/.julia/dev/Rasters`
  [c84ed2f1] Ratios v0.4.5
  [c1ae055f] RealDot v0.1.0
  [3cdcf5f2] RecipesBase v1.3.4
  [01d81517] RecipesPipeline v0.6.12
  [731186ca] RecursiveArrayTools v3.8.1
  [189a3867] Reexport v1.2.2
  [42d2dcc6] Referenceables v0.1.3
  [dee08c22] RegionTrees v0.3.2
  [4418983a] Registrator v1.9.3
  [2792f1a3] RegistryInstances v0.1.0
  [d1eb7eb1] RegistryTools v2.2.3
  [05181044] RelocatableFolders v1.0.1
  [cbe49d4c] RemoteFiles v0.5.0
  [ae029012] Requires v1.3.0
  [295af30f] Revise v3.5.14
  [286e9d63] RingLists v0.2.8
  [79098fc4] Rmath v0.7.1
  [f2b01f46] Roots v2.1.2
  [6038ab10] Rotations v1.7.0
  [5eaf0fd0] RoundingEmulator v0.2.1
  [d5f540fe] RoundingIntegers v1.1.0
  [7e49a35a] RuntimeGeneratedFunctions v0.5.12
  [1bc83da4] SafeTestsets v0.1.0
  [0bca4576] SciMLBase v2.26.1
  [c0aeaf25] SciMLOperators v0.3.7
  [30f210dd] ScientificTypesBase v3.0.0
  [6c6a2e73] Scratch v1.2.1
  [daca4e5c] SegmentAnything v0.1.0
  [91c51154] SentinelArrays v1.4.1
  [efcf1570] Setfield v1.1.1
  [65257c39] ShaderAbstractions v0.4.1
  [8e980c4a] Shapefile v0.12.0
  [1277b4bf] ShiftedArrays v2.0.0
  [992d4aef] Showoff v1.0.3
  [73760f76] SignedDistanceFields v0.4.0
  [777ac1f9] SimpleBufferStream v1.1.0
  [55797a34] SimpleGraphs v0.8.6
  [ec83eff0] SimplePartitions v0.3.1
  [cc47b68c] SimplePolynomials v0.2.17
  [a6525b86] SimpleRandom v0.3.1
  [699a6c99] SimpleTraits v0.9.4
  [ce78b400] SimpleUnPack v1.1.0
  [47aef6b3] SimpleWeightedGraphs v1.4.0
  [45858cf5] Sixel v0.1.3
  [2133526b] SodiumSeal v0.1.1
  [a2af1166] SortingAlgorithms v1.2.1
  [27459e48] SpaceInvaders v1.0.1
  [dc90abb0] SparseInverseSubset v0.1.2
  [276daf66] SpecialFunctions v2.3.1
  [03a91e81] SplitApplyCombine v1.2.3
  [171d559e] SplittablesBase v0.1.15
  [c5dd0088] StableHashTraits v1.1.8
  [cae243ae] StackViews v0.1.1
  [aedffcd0] Static v0.8.10
  [90137ffa] StaticArrays v1.9.2
  [1e83bf80] StaticArraysCore v1.4.2
  [a5f81324] StaticBitArrays v0.1.0 `~/.julia/dev/StaticBitArrays`
  [64bff920] StatisticalTraits v3.2.0
  [82ae8749] StatsAPI v1.7.0
βŒ… [2913bbd2] StatsBase v0.33.21
  [4c63d2b9] StatsFuns v1.3.1
  [3eaba693] StatsModels v0.7.3
  [f3b207a7] StatsPlots v0.15.7
  [264155e8] Stencils v0.2.4 `~/.julia/dev/Stencils`
  [892a3eda] StringManipulation v0.3.4
  [09ab397b] StructArrays v0.6.17
  [53d494c1] StructIO v0.3.0
  [856f2bd8] StructTypes v1.10.0
  [2efcf032] SymbolicIndexingInterface v0.3.6
  [dc5dba14] TZJData v1.1.0+2023d
  [ab02a1b2] TableOperations v1.2.0
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.11.1
  [62fd8b95] TensorCore v0.1.1
  [5d786b92] TerminalLoggers v0.1.7
  [0c614874] TerminalPager v0.5.1
  [b718987f] TextWrap v1.0.1
  [b189fb0b] ThreadPools v2.1.1
  [4239201d] ThreadSafeDicts v0.1.4
  [ac1d9e8a] ThreadsX v0.1.12
βŒ… [731e570b] TiffImages v0.6.8
  [263fe934] TileProviders v0.1.3
βŒ… [06e1c1a7] TiledIteration v0.3.1
  [37f0c46e] TimeToLive v0.3.0
  [f269a46b] TimeZones v1.13.0
  [a759f4b9] TimerOutputs v0.5.23
  [9f7883ad] Tracker v0.2.31
  [3bb67fe8] TranscodingStreams v0.10.3
βŒƒ [28d57a85] Transducers v0.4.80
  [410a4b4d] Tricks v0.1.8
  [981d1d27] TriplotBase v0.1.0
  [781d530d] TruncatedStacktraces v1.4.0
  [9d95972d] TupleTools v1.5.0
  [fce5fe82] Turing v0.30.5
  [e170d443] Tyler v0.1.1 `~/.julia/dev/Tyler`
  [bee2e7eb] TypeArrays v1.0.0-DEV `~/.julia/dev/TypeArrays`
  [d265eb64] TypedSyntax v1.2.4
  [9d95f2ec] TypedTables v1.4.6
  [5c2747f8] URIs v1.5.1
  [3a884ed6] UnPack v1.0.2
  [1cfade01] UnicodeFun v0.4.1
  [ebadf6b4] UnicodeGraphics v0.2.1
  [1986cc42] Unitful v1.19.0
  [45397f5d] UnitfulLatexify v1.6.3
  [013be700] UnsafeAtomics v0.2.1
  [d80eeb9a] UnsafeAtomicsLLVM v0.1.3
  [e17b2a0c] UnsafePointers v1.0.0
  [41fe7b60] Unzip v0.2.0
  [276b4fcb] WGLMakie v0.9.7
  [ea10d353] WeakRefStrings v1.4.2
  [bbac0a1f] WeightedOnlineStats v0.6.3
  [cc8bc4a8] Widgets v0.6.6
  [eead4739] WidgetsBase v0.1.4
  [b8c1c048] WidthLimitedIO v1.0.1
βŒ… [efce3f68] WoodburyMatrices v0.5.6
  [76eceee3] WorkerUtilities v1.6.1
  [fdbf4ff8] XLSX v0.10.1
  [90b8fcef] YAXArrayBase v0.6.1
  [c21b50f5] YAXArrays v0.5.3
  [c2297ded] ZMQ v1.2.2
βŒ… [a5390f91] ZipFile v0.9.4
  [700de1a5] ZygoteRules v0.2.5
  [7b86fcea] ATK_jll v2.38.0+0
βŒ… [68821587] Arpack_jll v3.5.1+1
  [8ce61222] Arrow_jll v10.0.0+1
  [1fd713ca] Attr_jll v2.5.1+0
  [6e34b625] Bzip2_jll v1.0.8+1
  [4e9b3aee] CRlibm_jll v1.0.1+0
  [4ee394cb] CUDA_Driver_jll v0.7.0+1
  [76a88914] CUDA_Runtime_jll v0.11.1+0
  [83423d85] Cairo_jll v1.16.1+1
  [ee1fde0b] Dbus_jll v1.12.16+3
  [04572ae6] Deno_jll v1.33.4+0
  [5ae413db] EarCut_jll v2.2.4+0
  [2702e6a9] EpollShim_jll v0.0.20230411+0
  [2e619515] Expat_jll v2.5.0+0
βŒ… [b22a6f82] FFMPEG_jll v4.4.2+2
  [f5851436] FFTW_jll v3.3.10+0
  [a3f928ae] Fontconfig_jll v2.13.93+0
  [d7e528f0] FreeType2_jll v2.13.1+0
  [559328eb] FriBidi_jll v1.0.10+0
βŒƒ [a7073274] GDAL_jll v301.600.200+0
βŒ… [d604d12d] GEOS_jll v3.11.2+0
  [bde7f898] GLEW_jll v2.2.0+0
  [0656b61e] GLFW_jll v3.3.9+0
  [bd17208b] GLU_jll v9.0.1+0
βŒ… [d2c73de3] GR_jll v0.72.8+0
  [77ec8976] GTK3_jll v3.24.31+0
βŒƒ [6ebb71f1] GTK4_jll v4.12.4+0
  [78b55507] Gettext_jll v0.21.0+0
  [61579ee1] Ghostscript_jll v9.55.0+4
βŒƒ [f8c6e375] Git_jll v2.36.1+2
  [7746bdde] Glib_jll v2.76.5+0
  [75302f13] Graphene_jll v1.10.6+0
  [3b182d85] Graphite2_jll v1.3.14+0
  [be1be57a] Gzip_jll v1.13.0+0
βŒ… [0234f1f7] HDF5_jll v1.12.2+2
  [2e76f6c2] HarfBuzz_jll v2.8.1+1
βŒ… [c73af94c] ImageMagick_jll v6.9.12+4
  [905a6f67] Imath_jll v3.1.7+0
  [1d5cc7b8] IntelOpenMP_jll v2024.0.2+0
  [aacddb02] JpegTurbo_jll v3.0.1+0
  [9c1d0b0a] JuliaNVTXCallbacks_jll v0.2.1+0
  [b39eb1a6] Kerberos_krb5_jll v1.19.3+0
  [c1c5ebd0] LAME_jll v3.100.1+0
  [88015f11] LERC_jll v3.0.0+1
  [dad2f222] LLVMExtra_jll v0.0.28+0
  [1d63c593] LLVMOpenMP_jll v15.0.7+0
  [dd4b983a] LZO_jll v2.10.1+0
βŒƒ [08be9ffa] LibPQ_jll v14.3.0+1
  [42c93a91] Libepoxy_jll v1.5.10+0
βŒ… [e9f186c6] Libffi_jll v3.2.2+1
  [d4300ac3] Libgcrypt_jll v1.8.7+0
  [7e76a0d4] Libglvnd_jll v1.6.0+0
  [7add5ba3] Libgpg_error_jll v1.42.0+0
  [94ce4f54] Libiconv_jll v1.17.0+0
  [4b2f31a3] Libmount_jll v2.35.0+0
  [925c91fb] Librsvg_jll v2.54.5+0
βŒ… [89763e89] Libtiff_jll v4.4.0+0
  [38a345b3] Libuuid_jll v2.36.0+0
βŒƒ [d3a379c0] LittleCMS_jll v2.12.0+0
  [5ced341a] Lz4_jll v1.9.4+0
  [856f044c] MKL_jll v2024.0.0+0
  [079eb43e] NLopt_jll v2.7.1+0
  [e98f9f5b] NVTX_jll v3.1.0+2
βŒ… [7243133f] NetCDF_jll v400.902.5+1
  [e7412a2a] Ogg_jll v1.3.5+1
  [18a262bb] OpenEXR_jll v3.1.4+0
  [cc7be9be] OpenGLMathematics_jll v0.9.9+0
βŒƒ [643b3616] OpenJpeg_jll v2.4.0+0
βŒ… [458c3c95] OpenSSL_jll v1.1.23+0
  [efe28fd5] OpenSpecFun_jll v0.5.5+0
  [91d4177d] Opus_jll v1.3.2+0
βŒ… [58948b4f] PROJ_jll v900.100.0+0
  [36c8627f] Pango_jll v1.50.14+0
  [30392449] Pixman_jll v0.42.2+0
  [ea2cea3b] Qt5Base_jll v5.15.3+2
  [f50d1b31] Rmath_jll v0.4.0+0
  [76ed43ae] SQLite_jll v3.45.0+0
  [9b64493d] Tar_jll v1.35.0+0
βŒ… [e0b8ae26] Thrift_jll v0.16.0+0
  [a2964d1f] Wayland_jll v1.21.0+1
  [2381bf8a] Wayland_protocols_jll v1.31.0+0
  [02c8fc9c] XML2_jll v2.12.2+0
  [aed1982a] XSLT_jll v1.1.34+0
  [ffd25f8a] XZ_jll v5.4.6+0
  [4f6342f7] Xorg_libX11_jll v1.8.6+0
  [0c0b7dd1] Xorg_libXau_jll v1.0.11+0
  [3c9796d7] Xorg_libXcomposite_jll v0.4.5+4
  [935fb764] Xorg_libXcursor_jll v1.2.0+4
  [0aeada51] Xorg_libXdamage_jll v1.1.5+4
  [a3789734] Xorg_libXdmcp_jll v1.1.4+0
  [1082639a] Xorg_libXext_jll v1.3.4+4
  [d091e8ba] Xorg_libXfixes_jll v5.0.3+4
  [a51aa0fd] Xorg_libXi_jll v1.7.10+4
  [d1454406] Xorg_libXinerama_jll v1.1.4+4
  [ec84b674] Xorg_libXrandr_jll v1.5.2+4
  [ea2f1a96] Xorg_libXrender_jll v0.9.10+4
  [b6f176f1] Xorg_libXtst_jll v1.2.3+4
  [14d82f49] Xorg_libpthread_stubs_jll v0.1.1+0
  [c7cfdc94] Xorg_libxcb_jll v1.15.0+0
  [cc61e674] Xorg_libxkbfile_jll v1.1.2+0
  [12413925] Xorg_xcb_util_image_jll v0.4.0+1
  [2def613f] Xorg_xcb_util_jll v0.4.0+1
  [975044d2] Xorg_xcb_util_keysyms_jll v0.4.0+1
  [0d47668e] Xorg_xcb_util_renderutil_jll v0.3.9+1
  [c22f9ab0] Xorg_xcb_util_wm_jll v0.4.1+1
  [35661453] Xorg_xkbcomp_jll v1.4.6+0
  [33bec58e] Xorg_xkeyboard_config_jll v2.39.0+0
  [c5fb5394] Xorg_xtrans_jll v1.5.0+0
  [8f1865be] ZeroMQ_jll v4.3.4+0
  [3161d3a3] Zstd_jll v1.5.5+0
βŒ… [b437f822] adwaita_icon_theme_jll v3.33.93+0
  [de012916] at_spi2_atk_jll v2.34.1+4
  [0fc3237b] at_spi2_core_jll v2.34.0+4
βŒ… [28df3c45] boost_jll v1.76.0+1
  [214eeab7] fzf_jll v0.43.0+0
βŒƒ [da03df04] gdk_pixbuf_jll v2.42.8+0
  [07c12ed4] ghr_jll v0.14.0+0
  [059c91fe] hicolor_icon_theme_jll v0.17.0+3
  [bf975903] iso_codes_jll v4.15.1+0
  [9a68df92] isoband_jll v0.2.3+0
  [583852a3] libadwaita_jll v1.3.6+0
  [a4ae2306] libaom_jll v3.4.0+0
  [0ac62f75] libass_jll v0.15.1+0
βŒ… [3eaa8342] libcxxwrap_julia_jll v0.11.2+0
  [f638f0a6] libfdk_aac_jll v2.0.2+0
βŒƒ [06c338fa] libgeotiff_jll v100.700.100+0
  [287f9a42] libmousetrap_jll v0.3.0+0 `https://github.com/clemapfel/mousetrap_jll#main`
  [b53b4c65] libpng_jll v1.6.42+0
  [075b6546] libsixel_jll v1.10.3+0
  [a9144af2] libsodium_jll v1.0.20+0
  [f27f6e37] libvorbis_jll v1.3.7+1
  [f8abcde7] micromamba_jll v1.4.9+0
  [0e90efc8] mousetrap_jll v0.3.0+0
  [1bc43ea1] pigz_jll v2.8.0+0
  [fe1e1685] snappy_jll v1.1.9+1
  [88f77b66] unzip_jll v6.0.2+0
  [1270edf5] x264_jll v2021.5.5+0
  [dfaa095f] x265_jll v3.5.0+0
  [d8fb68d0] xkbcommon_jll v1.4.1+1
  [0dad84c5] ArgTools v1.1.1
  [56f22d72] Artifacts
  [2a0f44e3] Base64
  [8bf52ea8] CRC32c
  [ade2ca70] Dates
  [8ba89e20] Distributed
  [f43a241f] Downloads v1.6.0
  [7b1f6079] FileWatching
  [9fa8497b] Future
  [b77e0a4c] InteractiveUtils
  [4af54fe1] LazyArtifacts
  [b27032c2] LibCURL v0.6.4
  [76f85450] LibGit2
  [8f399da3] Libdl
  [37e2e46d] LinearAlgebra
  [56ddb016] Logging
  [d6f4376e] Markdown
  [a63ad114] Mmap
  [ca575930] NetworkOptions v1.2.0
  [44cfe95a] Pkg v1.10.0
  [de0858da] Printf
  [9abbd945] Profile
  [3fa0cd96] REPL
  [9a3f8284] Random
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization
  [1a1011a3] SharedArrays
  [6462fe0b] Sockets
  [2f01184e] SparseArrays v1.10.0
  [10745b16] Statistics v1.10.0
  [4607b0f0] SuiteSparse
  [fa267f1f] TOML v1.0.3
  [a4e569a6] Tar v1.10.0
  [8dfed614] Test
  [cf7118a7] UUIDs
  [4ec0a83e] Unicode
  [e66e0078] CompilerSupportLibraries_jll v1.0.5+1
  [deac9b47] LibCURL_jll v8.0.1+1
  [e37daf67] LibGit2_jll v1.6.4+0
  [29816b5a] LibSSH2_jll v1.11.0+1
  [c8ffd9c3] MbedTLS_jll v2.28.2+1
  [14a3606d] MozillaCACerts_jll v2023.1.10
  [4536629a] OpenBLAS_jll v0.3.23+2
  [05823500] OpenLibm_jll v0.8.1+2
  [efcefdf7] PCRE2_jll v10.42.0+1
  [bea87d4a] SuiteSparse_jll v7.2.0+1
  [83775a58] Zlib_jll v1.2.13+1
  [8e850b90] libblastrampoline_jll v5.8.0+1
  [8e850ede] nghttp2_jll v1.52.0+1
  [3f19e933] p7zip_jll v17.4.0+2
julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 Γ— Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 12 default, 0 interactive, 6 GC (on 12 virtual cores)
Environment:
  JULIA_NUM_THREADS = 6
  JULIA_EDITOR = vim

Additional context

Add any other context about the problem here.

rafaqz commented 4 months ago

Ok here's a MWE with rosenbrock:

julia> rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
rosenbrock (generic function with 2 methods)

julia> x0 = zeros(2)
2-element Vector{Float64}:
 0.0
 0.0

julia> lb = fill(-1.0, 2)
2-element Vector{Float64}:
 -1.0
 -1.0

julia> ub = fill(200.0, 2)
2-element Vector{Float64}:
 200.0
 200.0

julia> _p = [1.0, 100.0]
2-element Vector{Float64}:
   1.0
 100.0

julia> 

julia> l1 = rosenbrock(x0, _p)
1.0

julia> prob = OptimizationProblem(rosenbrock, x0, _p; lb, ub)
OptimizationProblem. In-place: true
u0: 2-element Vector{Float64}:
 0.0
 0.0

julia> solve(prob, NelderMead())
ERROR: MethodError: objects of type Nothing are not callable
Stacktrace:
  [1] (::OptimizationOptimJL.var"#20#24"{OptimizationCache{…}})(G::Vector{Float64}, ΞΈ::Vector{Float64})
    @ OptimizationOptimJL ~/.julia/packages/OptimizationOptimJL/yMF3E/src/OptimizationOptimJL.jl:291
  [2] gradient!!(obj::OnceDifferentiable{Float64, Vector{Float64}, Vector{Float64}}, x::Vector{Float64})
    @ NLSolversBase ~/.julia/packages/NLSolversBase/kavn7/src/interface.jl:63
  [3] gradient!
    @ ~/.julia/packages/NLSolversBase/kavn7/src/interface.jl:51 [inlined]
  [4] gradient!(obj::Optim.BarrierWrapper{OnceDifferentiable{Float64, Vector{Float64}, Vector{Float64}}, Optim.BoxBarrier{Vector{Float64}, Vector{Float64}}, Float64, Float64, Vector{Float64}}, x::Vector{Float
64})
    @ Optim ~/.julia/packages/Optim/EJwLF/src/multivariate/solvers/constrained/fminbox.jl:118
  [5] optimize(df::OnceDifferentiable{…}, l::Vector{…}, u::Vector{…}, initial_x::Vector{…}, F::Fminbox{…}, options::Optim.Options{…})
    @ Optim ~/.julia/packages/Optim/EJwLF/src/multivariate/solvers/constrained/fminbox.jl:327
  [6] __solve(cache::OptimizationCache{…})
    @ OptimizationOptimJL ~/.julia/packages/OptimizationOptimJL/yMF3E/src/OptimizationOptimJL.jl:306
  [7] solve!
    @ ~/.julia/packages/SciMLBase/wVDwN/src/solve.jl:179 [inlined]
  [8] #solve#596
    @ ~/.julia/packages/SciMLBase/wVDwN/src/solve.jl:96 [inlined]
  [9] solve(::OptimizationProblem{…}, ::NelderMead{…})
    @ SciMLBase ~/.julia/packages/SciMLBase/wVDwN/src/solve.jl:93
 [10] top-level scope
    @ REPL[104]:1
Some type information was truncated. Use `show(err)` to see complete types.
Vaibhavdixit02 commented 4 months ago

This is from https://github.com/SciML/Optimization.jl/issues/558. The fallback for handling box constraints when a solver doesn't support it directly is to wrap it in Fminbox which requires gradients. You can work around this by passing a OptimizationFunction with AD backend for now, we should update the wrapping as mentioned in the linked issue

rafaqz commented 2 months ago

A fix to the MWE above might help make this clearer?

Im not sure what you mean "passing a OptimizationFunction with AD backend"

Edit I guess you mean something like:

using SciMLBase, Optimization
julia> prob = OptimizationProblem(OptimizationFunction(rosenbrock, SciMLBase.NoAD()), x0, _p; lb, ub)

No... that doesn't work either! Surely NoAD() should mean dont call f.grad ??

My actual problems are not differentiable so NoAD() is really what I need.

rafaqz commented 2 months ago

This works fine just using Optim directly:

using Optim
rosenbrock(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
lower, upper = [-100, -100], [100, 100]
result = optimize(rosenbrock, lower, upper, zeros(2), NelderMead())

Also works with Fminbox

result = optimize(rosenbrock, lower, upper, zeros(2), Fminbox(NelderMead()))
Vaibhavdixit02 commented 2 months ago

No... that doesn't work either! Surely NoAD() should mean dont call f.grad ??

I can see how the name might have confused you but it is intended (and is not part of the public API just used in the internals) to mean that derivatives are provided and not use AD for generating them.

Im not sure what you mean "passing a OptimizationFunction with AD backend"

I meant a valid AD backend from https://docs.sciml.ai/Optimization/stable/API/ad/

The reason is for this error is still https://github.com/SciML/Optimization.jl/issues/558

You should use SAMIN https://julianlsolvers.github.io/Optim.jl/stable/algo/samin/ if your objective is not differentiable

rafaqz commented 2 months ago

Thanks. I also found that it works with the NLopt nelder-mead,

But a fix of this would be good... it does work fine in Optim.jl, even if you use Fminbox(). So switching from Optim to Optimization this is just the first thing I would try to test a derivative free optimisation.

Vaibhavdixit02 commented 2 months ago

The point is not that it doesn't work with Optim, in Optim the gradients are automatically calculated if the method needs it https://github.com/JuliaNLSolvers/Optim.jl/blob/01b9391383c562078f3ada4d3c5aeee76af6ca8a/src/multivariate/solvers/constrained/fminbox.jl#L83 - always with ForwardDiff, in Optimization.jl you need to specify the AD library you want to use, so the right way to use it is provide a valid AD choice there. The issue is that the error should be better there's work in progress for that already by @ParasPuneetSingh, hopefully, we can finish that up pretty soon and do a release.

rafaqz commented 2 months ago

You should use SAMIN https://julianlsolvers.github.io/Optim.jl/stable/algo/samin/ if your objective is not differentiable

FYI SAMIN doesnt support box constraints. oops thats SimulatedAnnealing() SAMIN() seems to be working!!

JohannesNaegele commented 1 month ago

Fyi I ran into the same bug trying to switch from Optim.jl to Optimization.jl.