What do I do wrong
julia> import Pkg
julia> Pkg.activate(;temp=true)
Activating new project at `C:\Users\LOCAL_~4\Temp\jl_cF3P4l`
(jl_cF3P4l) pkg> add Optimization, ForwardDiff
...
[f6369f11] + ForwardDiff v0.10.36
[7f7a1694] + Optimization v3.19.3
julia> using ForwardDiff, Optimization
julia> Optimization.OptimizationFunction((x,p) -> x^2, Optimization.AutoForwardDiff())
ERROR: MethodError: no method matching (OptimizationFunction{true})(::var"#13#14", ::AutoForwardDiff{nothing, Nothing})
Closest candidates are:
(OptimizationFunction{iip})(::Any) where iip
@ SciMLBase C:\Users\KaisermayerV\.julia\packages\SciMLBase\QqtZA\src\scimlfunctions.jl:3583
(OptimizationFunction{iip})(::Any, ::SciMLBase.AbstractADType; grad, hess, hv, cons, cons_j, cons_h, lag_h, hess_prototype, cons_jac_prototype, cons_hess_prototype, lag_hess_prototype, syms, paramsyms, observed,
hess_colorvec, cons_jac_colorvec, cons_hess_colorvec, lag_hess_colorvec, expr, cons_expr, sys) where iip
@ SciMLBase C:\Users\KaisermayerV\.julia\packages\SciMLBase\QqtZA\src\scimlfunctions.jl:3583
Stacktrace:
[1] OptimizationFunction(::Function, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ SciMLBase C:\Users\KaisermayerV\.julia\packages\SciMLBase\QqtZA\src\scimlfunctions.jl:3581
[2] OptimizationFunction(::Function, ::Vararg{Any})
@ SciMLBase C:\Users\KaisermayerV\.julia\packages\SciMLBase\QqtZA\src\scimlfunctions.jl:3581
[3] top-level scope
@ REPL[19]:1
Can’t seem to be able to reproduce.
julia> import Pkg
julia> Pkg.activate(;temp=true)
Activating new project at `/var/folders/b0/fzxgrbb90sl9792hlrn8wcs00000gn/T/jl_Ij7X3F`
(jl_Ij7X3F) pkg> add Optimization, ForwardDiff
Resolving package versions...
Updating `/private/var/folders/b0/fzxgrbb90sl9792hlrn8wcs00000gn/T/jl_Ij7X3F/Project.toml`
[f6369f11] + ForwardDiff v0.10.36
[7f7a1694] + Optimization v3.19.3
Updating `/private/var/folders/b0/fzxgrbb90sl9792hlrn8wcs00000gn/T/jl_Ij7X3F/Manifest.toml`
[47edcb42] + ADTypes v0.2.5
[1520ce14] + AbstractTrees v0.4.4
[7d9f7c33] + Accessors v0.1.33
[79e6a3ab] + Adapt v3.7.1
[4fba245c] + ArrayInterface v7.5.1
[38540f10] + CommonSolve v0.2.4
[bbf7d656] + CommonSubexpressions v0.3.0
[34da2185] + Compat v4.10.0
[a33af91c] + CompositionsBase v0.1.2
[2569d6c7] + ConcreteStructs v0.2.3
[88cd18e8] + ConsoleProgressMonitor v0.1.2
[187b0558] + ConstructionBase v1.5.4
[9a962f9c] + DataAPI v1.15.0
[864edb3b] + DataStructures v0.18.15
[e2d170a0] + DataValueInterfaces v1.0.0
[8bb1440f] + DelimitedFiles v1.9.1
[163ba53b] + DiffResults v1.1.0
[b552c78f] + DiffRules v1.15.1
[ffbed154] + DocStringExtensions v0.9.3
[4e289a0a] + EnumX v1.0.4
[e2ba6199] + ExprTools v0.1.10
[1a297f60] + FillArrays v1.7.0
[f6369f11] + ForwardDiff v0.10.36
[069b7b12] + FunctionWrappers v1.1.3
[77dc65aa] + FunctionWrappersWrappers v0.1.3
[46192b85] + GPUArraysCore v0.1.5
[18e54dd8] + IntegerMathUtils v0.1.2
[3587e190] + InverseFunctions v0.1.12
[92d709cd] + IrrationalConstants v0.2.2
[82899510] + IteratorInterfaceExtensions v1.0.0
[692b3bcd] + JLLWrappers v1.5.0
[73f95e8e] + LatticeRules v0.0.1
[50d2b5c4] + Lazy v0.15.1
[1d6d02ad] + LeftChildRightSiblingTrees v0.2.0
[2ab3a3ac] + LogExpFunctions v0.3.26
[e6f89c97] + LoggingExtras v1.0.3
[1914dd2f] + MacroTools v0.5.11
[e1d29d7a] + Missings v1.1.0
[77ba4419] + NaNMath v1.0.2
[7f7a1694] + Optimization v3.19.3
[bac558e1] + OrderedCollections v1.6.2
[aea7be01] + PrecompileTools v1.2.0
[21216c6a] + Preferences v1.4.1
[27ebfcd6] + Primes v0.5.5
[33c8b6b6] + ProgressLogging v0.1.4
[92933f4c] + ProgressMeter v1.9.0
[8a4e6c94] + QuasiMonteCarlo v0.3.3
[3cdcf5f2] + RecipesBase v1.3.4
[731186ca] + RecursiveArrayTools v2.38.10
[189a3867] + Reexport v1.2.2
[ae029012] + Requires v1.3.0
[7e49a35a] + RuntimeGeneratedFunctions v0.5.12
[0bca4576] + SciMLBase v2.8.2
[c0aeaf25] + SciMLOperators v0.3.7
[efcf1570] + Setfield v1.1.1
[ed01d8cd] + Sobol v1.5.0
[a2af1166] + SortingAlgorithms v1.2.0
[276daf66] + SpecialFunctions v2.3.1
[1e83bf80] + StaticArraysCore v1.4.2
[82ae8749] + StatsAPI v1.7.0
[2913bbd2] + StatsBase v0.34.2
[2efcf032] + SymbolicIndexingInterface v0.2.2
[3783bdb8] + TableTraits v1.0.1
[bd369af6] + Tables v1.11.1
[5d786b92] + TerminalLoggers v0.1.7
[410a4b4d] + Tricks v0.1.8
[781d530d] + TruncatedStacktraces v1.4.0
[efe28fd5] + OpenSpecFun_jll v0.5.5+0
[0dad84c5] + ArgTools v1.1.1
[56f22d72] + Artifacts
[2a0f44e3] + Base64
[ade2ca70] + Dates
[8ba89e20] + Distributed
[f43a241f] + Downloads v1.6.0
[7b1f6079] + FileWatching
[9fa8497b] + Future
[b77e0a4c] + InteractiveUtils
[b27032c2] + LibCURL v0.6.3
[76f85450] + LibGit2
[8f399da3] + Libdl
[37e2e46d] + LinearAlgebra
[56ddb016] + Logging
[d6f4376e] + Markdown
[a63ad114] + Mmap
[ca575930] + NetworkOptions v1.2.0
[44cfe95a] + Pkg v1.9.2
[de0858da] + Printf
[3fa0cd96] + REPL
[9a3f8284] + Random
[ea8e919c] + SHA v0.7.0
[9e88b42a] + Serialization
[6462fe0b] + Sockets
[2f01184e] + SparseArrays
[10745b16] + Statistics v1.9.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+0
[deac9b47] + LibCURL_jll v7.84.0+0
[29816b5a] + LibSSH2_jll v1.10.2+0
[c8ffd9c3] + MbedTLS_jll v2.28.2+0
[14a3606d] + MozillaCACerts_jll v2022.10.11
[4536629a] + OpenBLAS_jll v0.3.21+4
[05823500] + OpenLibm_jll v0.8.1+0
[bea87d4a] + SuiteSparse_jll v5.10.1+6
[83775a58] + Zlib_jll v1.2.13+0
[8e850b90] + libblastrampoline_jll v5.8.0+0
[8e850ede] + nghttp2_jll v1.48.0+0
[3f19e933] + p7zip_jll v17.4.0+0
julia> using ForwardDiff, Optimization
julia> Optimization.OptimizationFunction((x,p) -> x^2, Optimization.AutoForwardDiff())
(::OptimizationFunction{true, AutoForwardDiff{nothing, Nothing}, var"#3#4", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}) (generic function with 1 method)
Can you check if the SciMLBase being used in your case, maybe from the base environment is very old, that seems most likely?
So it would seem: SciMLBase v1.81.0
.
Since I have the same versions for Optimization.jl and ForwardDiff.jl, compat seems incorrect.