8000 Issue in running OptimizationFunction · Issue #686 · SciML/Optimization.jl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Issue in running OptimizationFunction #686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lakshaya17 opened this issue Jan 25, 2024 · 13 comments
Closed

Issue in running OptimizationFunction #686

lakshaya17 opened this issue Jan 25, 2024 · 13 comments
Labels
bug Something isn't working

Comments

@lakshaya17
Copy link

I am trying to run the example in the README, but I am getting the following error:

MethodError: no method matching (OptimizationFunction{true})(::typeof(rosenbrock), ::AutoForwardDiff{nothing, Nothing})

Some of the types have been truncated in the stacktrace for improved reading. To emit complete information
in the stack trace, evaluate `TruncatedStacktraces.VERBOSE[] = true` and re-run the code.

Closest candidates are:
  (OptimizationFunction{iip})(::Any) where iip at C:\Users\lakshay\.julia\packages\SciMLBase\zXEYU\src\scimlfunctions.jl:3907
  (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 at C:\Users\lakshay\.julia\packages\SciMLBase\zXEYU\src\scimlfunctions.jl:3907

Stacktrace:
 [1] OptimizationFunction(::Function, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ SciMLBase C:\Users\lakshay\.julia\packages\SciMLBase\zXEYU\src\scimlfunctions.jl:3905
 [2] OptimizationFunction(::Function, ::Vararg{Any})
   @ SciMLBase C:\Users\lakshay\.julia\packages\SciMLBase\zXEYU\src\scimlfunctions.jl:3905
 [3] top-level scope
   @ In[15]:2

Particularly I am running this code:

using ForwardDiff
f = OptimizationFunction(rosenbrock, Optimization.AutoForwardDiff())
prob = OptimizationProblem(f, x0, p)
sol = solve(prob, BFGS())

I would be obliged if someone could help me with the same.

Regards

@lakshaya17 lakshaya17 added the bug Something isn't working label Jan 25, 2024
@lakshaya17 lakshaya17 changed the title Issue in running OptimizationProblem Issue in running OptimizationFunction Jan 25, 2024
@SebastianM-C
Copy link
Contributor

I ran the code with recent versions of the packages and it works for me?
What does ]st -m Optimization SciMLBase show for you.

@lakshaya17
Copy link
Author

⌅ [7f7a1694] Optimization v3.19.3
⌅ [0bca4576] SciMLBase v1.89.0

@SebastianM-C
Copy link
Contributor
SebastianM-C commented Jan 26, 2024

Oh, you have am old SciMLBase (pre v2). @ChrisRackauckas I think that

SciMLBase = "1.79.0, 2"
is not really correct and it should drop the 2 require 2, I tried

Edit: v2 should be required, not dropped, sorry for the confusion.

(jl_8TnPqU) pkg> st
Status `C:\Users\sebastian\AppData\Local\Temp\jl_8TnPqU\Project.toml`
  [f6369f11] ForwardDiff v0.10.36
⌃ [7f7a1694] Optimization v3.19.3
⌃ [0bca4576] SciMLBase v1.89.0
Info Packages marked with ⌃ have new versions available and may be upgradable.

and I can reproduce the error mentioned above:

julia> f = OptimizationFunction(rosenbrock, Optimization.AutoForwardDiff())
ERROR: MethodError: no method matching (OptimizationFunction{true})(::typeof(rosenbrock), ::AutoForwardDiff{nothing, Nothing})

Closest candidates are:
  (OptimizationFunction{iip})(::Any; ...) where iip
   @ SciMLBase C:\Users\sebastian\.julia\packages\SciMLBase\zXEYU\src\scimlfunctions.jl:3907
  (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\sebastian\.julia\packages\SciMLBase\zXEYU\src\scimlfunctions.jl:3907

Stacktrace:
 [1] OptimizationFunction(::Function, ::Vararg{Any}; kwargs::@Kwargs{})
   @ SciMLBase C:\Users\sebastian\.julia\packages\SciMLBase\zXEYU\src\scimlfunctions.jl:3905
 [2] top-level scope
   @ REPL[15]:1

@lakshaya17 You can see what packages are holding back SciMLBase with ]st -m --outdated SciMLBase.

@ChrisRackauckas
Copy link
Member

Yes, that should get bumped to require v2. In fact, we need the full downgrade CI here.

@Vaibhavdixit02
Copy link
Member

There is downgrade CI here already.

Tbh I don't get the issue here, how did you end up with those versions @lakshaya17?

is not really correct and it should drop the 2, I tried
(jl_8TnPqU) pkg> st
Status C:\Users\sebastian\AppData\Local\Temp\jl_8TnPqU\Project.toml
[f6369f11] ForwardDiff v0.10.36
⌃ [7f7a1694] Optimization v3.19.3
⌃ [0bca4576] SciMLBase v1.89.0
Info Packages marked with ⌃ have new versions available and may be upgradable.
and I can reproduce the error mentioned above:

I am probably misunderstanding but doesn't this mean that v2 should be there and should have been used but somehow the OP ended up with <v2 and that led to the error?

@lakshaya17
Copy link
Author

I tried that and updated the Julia version as well. Still no luck. I checked the outdated packages, and they showing me this:

(@v1.10) pkg> status --outdated
Status `C:\Users\lakshay\.julia\environments\v1.10\Project.toml`
⌅ [764a87c0] BoundaryValueDiffEq v4.0.1 (<v5.6.1): DifferentialEquations
⌃ [a6e380b2] ControlSystems v1.10.0 (<v1.10.1)
⌃ [0c46a032] DifferentialEquations v7.10.0 (<v7.12.0)
⌅ [76087f3c] NLopt v0.6.5 (<v1.0.1): OptimizationNLopt
⌃ [7f7a1694] Optimization v3.19.3 (<v3.21.2)
⌃ [fd9f6733] OptimizationMOI v0.1.16 (<v0.3.4)
⌃ [4e6fcdb7] OptimizationNLopt v0.1.8 (<v0.2.0)
⌃ [1dea7af3] OrdinaryDiffEq v6.58.2 (<v6.69.0)
⌅ [0bca4576] SciMLBase v1.98.1 (<v2.21.0): BoundaryValueDiffEq, DiffEqBase, Integrals, ModelingToolkit, StochasticDiffEq
⌃ [1ed8b502] SciMLSensitivity v7.51.0 (<v7.53.0)

With the command:

st -m --outdated SciMLBase

Its giving me this:

[0bca4576] SciMLBase v1.98.1 (<v2.21.0): BoundaryValueDiff 8000 Eq, DiffEqBase, Integrals, ModelingToolkit, StochasticDiffEq

When I am trying to update these, they are either giving me compatibility issues.

@Vaibhavdixit02
Copy link
Member

Does just ]up give you compatibility issues?

@lakshaya17
Copy link
Author

No. I just ran this:

(@v1.10) pkg> up
    Updating registry at `C:\Users\lakshay\.julia\registries\General.toml`
  No Changes to `C:\Users\lakshay\.julia\environments\v1.10\Project.toml`
  No Changes to `C:\Users\lakshay\.julia\environments\v1.10\Manifest.toml`

@Vaibhavdixit02
Copy link
Member

You should restart the julia session and try this

@lakshaya17
Copy link
Author

@Vaibhavdixit02 I ran that after restarting Julia session only.

@SebastianM-C
Copy link
Contributor

doesn't this mean that v2 should be there and should have been used but somehow the OP ended up with <v2 and that led to the error?

@Vaibhavdixit02 yeah, it should require v2 and OP somehow ended up with <v2, sorry for the confusion.

@lakshaya17 what do you get if you try to explicitly ]add SciMLBase@v2?

@lakshaya17
Copy link
Author

@SebastianM-C I am getting this:

(@v1.10) pkg> add SciMLBase@v2
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Integrals [de52edbc]:
 Integrals [de52edbc] log:
 ├─possible versions are: 3.0.0-4.1.0 or uninstalled
 ├─restricted to versions 3.1.0-3 by SciMLExpectations [afe9f18d], leaving only versions: 3.1.0-3.9.0
 │ └─SciMLExpectations [afe9f18d] log:
 │   ├─possible versions are: 2.1.0 or uninstalled
 │   └─SciMLExpectations [afe9f18d] is fixed to version 2.1.0
 └─restricted by compatibility requirements with SciMLBase [0bca4576] to versions: 4.0.0-4.1.0 or uninstalled — no versions left

@SebastianM-C
Copy link
Contributor

It looks like SciMLExpectations is holding back Integrals to a version pre SciMLBase@v2. If you don't need SciMLExpectations in this environment, removing it and updating should hopefully resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants
0