Trying to use the new optimization algorithm: Sophia

I am trying to use the new optimization algorithm in Optimization.jl called Sophia, which is the first algorithm that shows up in the link below.

However, I seem to get an error message that Sophia is an undefined variable. Shouldn’t it be enough to just call the algorithm as I have done below?

odeoutmodel = Optimization.solve(optprob,
                                        Sophia(),
                                        progress = true,
                                        maxiters = 1000)

Sophia is apparently not exported. Try OptimizationOptimisers.Sophia

I get a similar error when using OptimizationOptimisers.Sophia. I suppose we have to wait until it is exported.

Strange. What I get is

julia> using Optimization, OptimizationOptimisers
julia> OptimizationOptimisers.Sophia()
OptimizationOptimisers.Sophia(0.001, (0.9, 0.999), 1.0e-8, 0.1, 10, 0.04)

Status `/private/var/folders/sh/h134ydrd1gzbtd4qflbl50km0000gn/T/jl_fXjMwL/Project.toml`
  [3bd65402] Optimisers v0.3.2
  [7f7a1694] Optimization v3.22.0
  [42dfb2eb] OptimizationOptimisers v0.2.1
1 Like

are you on an old version of the package?

Seems weird to define a new algorithm within OptimizationOptimisers.jl, since that’s supposed to be just a wrapper of Optimisers.jl …

Seems like I am on an old version. Despite updating OptimizationOptimisers as I have shown below, the version does not change. Do you have any advice for how to get the correct version installed?


julia> Pkg.status("OptimizationOptimisers")
βŒƒ [42dfb2eb] OptimizationOptimisers v0.1.2
Info Packages marked with βŒƒ have new versions available and may be upgradable.


julia> Pkg.update("OptimizationOptimisers")
    Updating registry at `C:\Users\.julia\registries\General.toml`
  No Changes to `C:\Users\.julia\environments\v1.10\Project.toml`
  No Changes to `C:\Users\.julia\environments\v1.10\Manifest.toml`
Precompiling project...
  ? DomainSets
  ? DiffEqSensitivity
  ? SciMLSensitivity
  ? Symbolics
  ? ModelingToolkit
  ? DataInterpolations β†’ DataInterpolationsSymbolicsExt
  ? DataDrivenDiffEq
  ? DiffEqFlux
  ? DataDrivenSparse


julia> Pkg.status("OptimizationOptimisers")
βŒƒ [42dfb2eb] OptimizationOptimisers v0.1.2
Info Packages marked with βŒƒ have new versions available and may be upgradable.

If there are new versions available after Pkg.update, they should be indicated with a βŒ….
To find out which dependencies prevent others from updating, try status --outdated. That produces a report like the following:

(MismatchMM) pkg> status --outdated
Project MismatchMM v2.2.0
Status `~/Documents/projects/p2022/mismatch/MismatchMM/Project.toml`
βŒƒ [13f3f980] CairoMakie v0.11.6 (<v0.11.8)
βŒ… [ffbed154] DocStringExtensions v0.8.6 (<v0.9.3): MultiStartLH
βŒ… [e30172f5] Documenter v0.27.25 (<v1.2.1): MultiStartLH, StructLH, UtilityFunctionsLH, ValueHistoriesLH
βŒƒ [5903a43b] Infiltrator v1.6.4 (<v1.7.0)
βŒƒ [033835bb] JLD2 v0.4.45 (<v0.4.46)
βŒ… [86f7a689] NamedArrays v0.9.8 (<v0.10.0) [compat]
βŒƒ [f2b01f46] Roots v2.1.1 (<v2.1.2)

In this example, DocStringExtensions cannot update because of a restriction in MultiStartLH’s compat entries.

1 Like

Alright thanks! I tried what you suggested and tried to for instance update Flux as I have shown below however, even here it does not update despite its dependency OptimizationFlux is not in need of an update, therefore Flux should be able to update, right?

(@v1.10) pkg> update Flux
    Updating registry at `C:\Users\.julia\registries\General.toml`
  No Changes to `C:\Users\.julia\environments\v1.10\Project.toml`
  No Changes to `C:\Users\environments\v1.10\Manifest.toml`
Precompiling project...
  ? DomainSets
  ? SciMLSensitivity
  ? Symbolics
  ? DiffEqSensitivity
  ? ModelingToolkit
  ? DataInterpolations β†’ DataInterpolationsSymbolicsExt
  ? DiffEqFlux
  ? DataDrivenDiffEq
  ? DataDrivenSparse

(@v1.10) pkg> status --outdated
Status `C:\Users\.julia\environments\v1.10\Project.toml`
βŒƒ [b0b7db55] ComponentArrays v0.13.7 (<v0.15.9)
βŒƒ [2445eb08] DataDrivenDiffEq v1.0.2 (<v1.3.0)
βŒƒ [a93c6f00] DataFrames v1.3.6 (<v1.6.1)
βŒ… [2b5f629d] DiffEqBase v6.108.0 (<v6.147.0): OrdinaryDiffEq
βŒƒ [aae7a2af] DiffEqFlux v2.4.0 (<v3.3.1)
βŒƒ [0c46a032] DifferentialEquations v7.6.0 (<v7.12.0)
βŒ… [587475ba] Flux v0.13.17 (<v0.14.11): OptimizationFlux
βŒƒ [b2108857] Lux v0.5.5 (<v0.5.17)
βŒ… [f1d291b0] MLUtils v0.3.1 (<v0.4.4): DataDrivenDiffEq
βŒƒ [961ee093] ModelingToolkit v8.36.0 (<v8.75.0)
βŒƒ [50b5cf9e] NLLSsolver v3.1.2 (<v4.0.0)
βŒ… [3bd65402] Optimisers v0.2.20 (<v0.3.2): Flux, OptimizationOptimisers
βŒƒ [7f7a1694] Optimization v3.14.0 (<v3.22.0)
βŒƒ [253f991c] OptimizationFlux v0.1.4 (<v0.2.1)
βŒƒ [4e6fcdb7] OptimizationNLopt v0.1.5 (<v0.2.0)
βŒƒ [36348300] OptimizationOptimJL v0.1.8 (<v0.2.2)
βŒƒ [42dfb2eb] OptimizationOptimisers v0.1.2 (<v0.2.1)
βŒƒ [1dea7af3] OrdinaryDiffEq v6.33.3 (<v6.71.0)
βŒƒ [1ed8b502] SciMLSensitivity v7.16.0 (<v7.55.0)
βŒƒ [102930c3] SmoothingSplines v0.3.1 (<v0.3.2)
βŒ… [2913bbd2] StatsBase v0.33.21 (<v0.34.2): DataDrivenDiffEq, Forecast, LearnBase, MLDataPattern, MLDataUtils, MLLabelUtils, MLUtils, SmoothingSplines

That report basically says:

Optimization, OptimizationOptimisers can be updated (try that)

Optimisers cannot be updated b/c of Flux
Flux cannot be updated b/c of OptimizationFlux

So one option is to update OptimizationFlux and keep your fingers crossed.

But then: why don’t you update all the packages?
You want to use the latest optimizers, but not the latest versions of other packages? Any specific reasons to pin dependencies at outdated versions?

2 Likes

I have tried to update OptimizationOptimisers and Optimization however as the snippet below shows, the version of OptimizationOptimisers remains unchanged. As I mentioned earlier, this is where I am currently stuck. Theoretically this should work since there are not restrictions to updating OptimizationOptimisers, right ?

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

(@v1.9) pkg> status OptimizationOptimisers
Status `C:\Users\.julia\environments\v1.9\Project.toml`
βŒƒ [42dfb2eb] OptimizationOptimisers v0.1.2
Info Packages marked with βŒƒ have new versions available and may be upgradable.

If possible I would like to update all packages but thought of starting with these for now.

Strange … what do your compat entries look like?

What happens if you just update everything?

Sorry for the late reply, I hadn’t seen your response. So when I run compat I get the following output:

(@v1.10) pkg> compat
  Select an entry to edit:
 >            julia                  none
   [fbb218c0] BSON                   none
   [336ed68f] CSV                    none
   [b0b7db55] ComponentArrays        none
   [717857b8] DSP                    none
   [2445eb08] DataDrivenDiffEq       none
   [5b588203] DataDrivenSparse       none
   [a93c6f00] DataFrames             none
   [2b5f629d] DiffEqBase             none
   [aae7a2af] DiffEqFlux             none
   [41bf760c] DiffEqSensitivity      none
   [0c46a032] DifferentialEquations  none
   [31c24e10] Distributions          none
   [5789e2e9] FileIO                 none
   [587475ba] Flux                   none
   [6efb3b9f] Forecast               none
   [f6369f11] ForwardDiff            none
   [a75be94c] GalacticOptim          none
   [7073ff75] IJulia                 none
   [6a3955dd] ImageFiltering         none
   [a98d9a8b] Interpolations         none
   [033835bb] JLD2                   none
   [7f56f5a3] LSODA                  none
   [0fc2ff8b] LeastSquaresOptim      none
   [2fda8390] LsqFit                 none
   [b2108857] Lux                    none
   [10e44e05] MATLAB                 none
   [f0e99cf1] MLBase                 none
   [cc2ba9b6] MLDataUtils            none
   [f1d291b0] MLUtils                none
   [961ee093] ModelingToolkit        none
   [50b5cf9e] NLLSsolver             none
   [2774e3e8] NLsolve                none
   [a15396b6] OnlineStats            none
   [429524aa] Optim                  none
   [3bd65402] Optimisers             none
   [7f7a1694] Optimization           none
   [253f991c] OptimizationFlux       none
   [4e6fcdb7] OptimizationNLopt      none
   [36348300] OptimizationOptimJL    none
   [42dfb2eb] OptimizationOptimisers none
   [1dea7af3] OrdinaryDiffEq         none
   [f0f68f2c] PlotlyJS               none
   [91a5bcdd] Plots                  none
   [f27b6e38] Polynomials            none
   [49802e3a] ProgressBars           none
   [438e738f] PyCall                 none
   [d330b81b] PyPlot                 none
   [1ed8b502] SciMLSensitivity       none
   [012d725f] Smoothers              none
   [102930c3] SmoothingSplines       none
   [860ef19b] StableRNGs             none
   [10745b16] Statistics             none
   [2913bbd2] StatsBase              none
   [9ff05d80] TickTock               none
   [770da0de] UpdateJulia            none
   [fdbf4ff8] XLSX                   none
   [e88e6eb3] Zygote                 none
   [0518478a] deSolveDiffEq          none

When trying to update all packages using up, I get the following message:

(@v1.10) pkg> up
    Updating registry at `C:\Users\user\.julia\registries\General.toml`
    Updating git-repo `https://github.com/SciML/deSolveDiffEq.jl`
  No Changes to `C:\Users\user\.julia\environments\v1.10\Project.toml`
  No Changes to `C:\Users\user\.julia\environments\v1.10\Manifest.toml`
Precompiling project...
  ? DomainSets
  ? SciMLSensitivity
  ? DiffEqSensitivity
  ? Symbolics
  ? ModelingToolkit
  ? DataInterpolations β†’ DataInterpolationsSymbolicsExt
  ? DiffEqFlux
  ? DataDrivenDiffEq
  ? DataDrivenSparse

So it seems like nothing really happens.

I tried to update some of my other packages such as FileIO and it was successful. However when I try to update the other packages nothing changes.