# Lotka_Volterra tutorial

Hi, I tried the first tutorial: "Optimizing parameters of an ODE for an Optimal Control Problem. I executed all the functions up to and including "p = [1.5, 1.0, 3.0, 1.0]. Then I typed:

`````` prob = ODEProblem(lotka_volterra, u0, tspan, p)
``````

and got the following error message, which I cannot figure out.
I am using Julia 1.4 (perhaps that is the reason?)

julia> prob = ODEProblem(lotka_volterra, u0, tspan, p)
soERROR: l MethodError: no method matching promote_tspan(::Array{Float64,1})
Closest candidates are:
promote_tspan(::Nothing) at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/problem_utils.jl:9
promote_tspan(::Tuple{T,S}) where {T, S} at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/problem_utils.jl:7
promote_tspan(::Number) at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/problem_utils.jl:8

Stacktrace:=
[1] ODEProblem{true,tType,isinplace,P,F,K,PT} where PT where K where F where P where isinplace where tType(::ODEFunction{true,typeof(lotka_volterra),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::DiffEqBase.StandardODEProblem; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/ode_problems.jl:34
[2] ODEProblem{true,tType,isinplace,P,F,K,PT} where PT where K where F where P where isinplace where tType(::ODEFunction{true,typeof(lotka_volterra),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::DiffEqBase.StandardODEProblem) at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/ode_problems.jl:34 (repeats 2 times)
[3] ODEProblem(::ODEFunction{true,typeof(lotka_volterra),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/ode_problems.jl:72
[4] ODEProblem(::ODEFunction{true,typeof(lotka_volterra),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}) at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/ode_problems.jl:72
[5] ODEProblem(::Function, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/ode_problems.jl:76
[6] ODEProblem(::Function, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}) at /Users/erlebach/.julia/packages/DiffEqBase/LNYfU/src/problems/ode_problems.jl:76
[7] top-level scope at none:0

Did you make `tspan` an array instead of a tuple? I.e., `(0.0,10.0)` vs `[0.0,10.0]`?

I do not know, Chris, and I returned to Julia 1.3 to try it out again. This time, I will pay more attention. If it works, I will return to Julia 1.4 .

Side question: the recompiling of libraries already drives me nuts. What must I do (with version 1.4 I assume) to have the libraries maintained in their compiled state? Or is this automatic and they are kept somewhere under ~/.julia?

I will reply to the very nice email you sent me at a later time. I wanted to develop some more knowledge before commenting again.

Using version 1.3 of Julia, I got further, so I must have typed […] instead of (…] for tspan. Thank you, Chris. Must be a common error.

However, I could not add the DiffEqFlux package in Julia 1.3 . Is that expected? Thanks.

Resolving package versions…
ERROR: Unsatisfiable requirements detected for package DiffEqSensitivity [41bf760c]:
DiffEqSensitivity [41bf760c] log:
├─possible versions are: [2.0.0, 2.1.0-2.1.1, 2.2.0, 2.3.0, 2.4.0, 3.0.0-3.0.2, 3.1.0, 3.2.0-3.2.4, 3.3.0-3.3.2, 4.0.0-4.0.1, 4.1.0-4.1.3, 4.2.0, 4.3.0, 4.4.0, 5.0.0, 5.1.0-5.1.3, 6.0.0-6.0.1, 6.1.0, 6.2.0, 6.3.0, 6.4.0, 6.5.0-6.5.3, 6.6.0-6.6.2] or uninstalled
├─restricted by compatibility requirements with DiffEqFlux [aae7a2af] to versions: [2.0.0, 2.1.0-2.1.1, 2.2.0, 2.3.0, 2.4.0, 3.0.0-3.0.2, 3.1.0, 3.2.0-3.2.4, 3.3.0-3.3.2, 4.0.0-4.0.1, 4.1.0-4.1.3, 4.2.0, 4.3.0, 4.4.0, 5.0.0, 5.1.0-5.1.3]
│ └─DiffEqFlux [aae7a2af] log:
│ ├─possible versions are: [0.0.1, 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0-0.5.2, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.10.2, 1.0.0, 1.1.0-1.1.1, 1.2.0-1.2.2, 1.3.0-1.3.2] or uninstalled
│ ├─restricted to versions * by an explicit requirement, leaving only versions [0.0.1, 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0-0.5.2, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.10.2, 1.0.0, 1.1.0-1.1.1, 1.2.0-1.2.2, 1.3.0-1.3.2]
│ ├─restricted by compatibility requirements with Juno [e5e0dc1b] to versions: [0.0.1, 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0-0.5.2, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.10.2, 1.0.0, 1.1.0-1.1.1, 1.3.2] or uninstalled, leaving only versions: [0.0.1, 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0-0.5.2, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.10.2, 1.0.0, 1.1.0-1.1.1, 1.3.2]
│ │ └─Juno [e5e0dc1b] log:
│ │ ├─possible versions are: [0.5.0-0.5.5, 0.6.0, 0.7.0-0.7.2, 0.8.0] or uninstalled
│ │ └─restricted to versions 0.8.0 by an explicit requirement, leaving only versions 0.8.0
│ ├─restricted by compatibility requirements with Flux [587475ba] to versions: [0.0.1, 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0-0.5.2, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.10.2] or uninstalled, leaving only versions: [0.0.1, 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0-0.5.2, 0.6.0-0.6.1, 0.7.0, 0.8.0-0.8.1, 0.9.0, 0.10.0-0.10.2]
│ │ └─Flux [587475ba] log:
│ │ ├─possible versions are: [0.4.1, 0.5.0-0.5.4, 0.6.0-0.6.10, 0.7.0-0.7.3, 0.8.0-0.8.3, 0.9.0, 0.10.0-0.10.1] or uninstalled
│ │ └─restricted to versions 0.9.0 by an explicit requirement, leaving only versions 0.9.0
│ └─restricted by compatibility requirements with RecursiveArrayTools [731186ca] to versions: [0.0.1, 0.1.0, 0.2.0, 0.3.0, 1.0.0, 1.1.0-1.1.1, 1.2.0-1.2.2, 1.3.0-1.3.2] or uninstalled, leaving only versions: [0.0.1, 0.1.0, 0.2.0, 0.3.0]
│ └─RecursiveArrayTools [731186ca] log:
│ ├─possible versions are: [0.16.0-0.16.3, 0.17.0-0.17.2, 0.18.0-0.18.6, 0.19.0-0.19.1, 0.20.0, 1.0.0-1.0.2, 1.1.0-1.1.1, 1.2.0-1.2.1, 2.0.0-2.0.5, 2.1.0] or uninstalled
│ ├─restricted by compatibility requirements with DifferentialEquations [0c46a032] to versions: [2.0.0-2.0.5, 2.1.0]
│ │ └─DifferentialEquations [0c46a032] log:
│ │ ├─possible versions are: [5.0.0, 5.1.0, 5.2.0-5.2.1, 5.3.0-5.3.1, 6.0.0, 6.1.0, 6.2.0, 6.3.0, 6.4.0, 6.6.0, 6.7.0, 6.8.0, 6.9.0, 6.10.0-6.10.1, 6.11.0] or uninstalled
│ │ └─restricted to versions 6.11.0 by an explicit requirement, leaving only versions 6.11.0
│ └─restricted by compatibility requirements with RecipesBase [3cdcf5f2] to versions: 2.1.0 or uninstalled, leaving only versions: 2.1.0
│ └─RecipesBase [3cdcf5f2] log:
│ ├─possible versions are: [0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0] or uninstalled
│ └─restricted by compatibility requirements with Plots [91a5bcdd] to versions: 0.8.0
│ └─Plots [91a5bcdd] log:
│ ├─possible versions are: [0.12.1-0.12.4, 0.13.0-0.13.1, 0.14.0-0.14.2, 0.15.0-0.15.1, 0.16.0, 0.17.0-0.17.4, 0.18.0, 0.19.0-0.19.3, 0.20.0-0.20.6, 0.21.0, 0.22.0-0.22.5, 0.23.0-0.23.2, 0.24.0, 0.25.0-0.25.3, 0.26.0-0.26.3, 0.27.0-0.27.1, 0.28.0-0.28.4, 0.29.0-0.29.1] or uninstalled
│ └─restricted to versions 0.29.1 by an explicit requirement, leaving only versions 0.29.1
├─restricted by compatibility requirements with RecursiveArrayTools [731186ca] to versions: [4.3.0, 6.3.0, 6.4.0, 6.5.0-6.5.3, 6.6.0-6.6.2] or uninstalled, leaving only versions: 4.3.0
│ └─RecursiveArrayTools [731186ca] log: see above
└─restricted by compatibility requirements with DiffEqFlux [aae7a2af] to versions: [2.0.0, 2.1.0-2.1.1, 2.2.0, 2.3.0, 2.4.0, 3.0.0-3.0.2, 3.1.0, 3.2.0-3.2.4, 3.3.0-3.3.2] — no versions left
└─DiffEqFlux [aae7a2af] log: see above

Ehh, probably only common from those coming from MATLAB, but still worth putting in some explicit handling. I made a PR and the next release will catch this for you:

Definitely not expected. However,

Is there a reason why your Flux has to be 0.9.0?

Absolutely no reason why there should be any restriction to 0.9. I certainly did not do anything (conscious) to make this happen. I do not yet have enough knowledge. How does one list this restriction?

Can you post your `]st`? And you ran `]up` to make sure the package registry is up to date?

(v1.3) pkg> status
Status `~/.julia/environments/v1.3/Project.toml`
[c52e3926] Atom v0.12.6
[0c46a032] DifferentialEquations v6.11.0
[e5e0dc1b] Juno v0.8.0
[429524aa] Optim v0.20.1
[91a5bcdd] Plots v0.29.1

I have since fixed the problem. I “activate NewProject” within Pkg, and added Flux first. I got 0.10.x
Then I added DifferentialEquations. I hope this will do the trick.

That’s only done once after a package updates. DifferentialEquations.jl is an especially long one, but if you only update every once in a blue moon then it’s no big deal. I think it should be added as part of the package update process. FWIW, you can call `]precompile` to precompile all packages.

As for the issue, how did you run into it? I swapped the order but can’t recreate it:

``````(v1.3) pkg> activate Tester
Activating new environment at `D:\OneDrive\Computer\Desktop\Tester\Project.toml`

Resolving package versions...
Installed Requires ──── v1.0.1
Installed RecipesBase ─ v0.8.0
Updating `D:\OneDrive\Computer\Desktop\Tester\Project.toml`
[0c46a032] + DifferentialEquations v6.11.0
Updating `D:\OneDrive\Computer\Desktop\Tester\Manifest.toml`
[ec485272] + ArnoldiMethod v0.0.4
[4fba245c] + ArrayInterface v2.4.1
[4c555306] + ArrayLayouts v0.1.5
[aae01518] + BandedMatrices v0.14.3
[b99e7846] + BinaryProvider v0.5.8
[764a87c0] + BoundaryValueDiffEq v2.4.0
[d360d2e6] + ChainRulesCore v0.6.1
[bbf7d656] + CommonSubexpressions v0.2.0
[34da2185] + Compat v2.2.0
[864edb3b] + DataStructures v0.17.9
[bcd4f6db] + DelayDiffEq v5.21.0
[2b5f629d] + DiffEqBase v6.17.3
[459566f4] + DiffEqCallbacks v2.12.0
[5a0ffddc] + DiffEqFinancial v2.2.1
[c894b116] + DiffEqJump v6.5.0
[77a26b50] + DiffEqNoiseProcess v3.9.0
[055956cb] + DiffEqPhysics v3.5.0
[163ba53b] + DiffResults v1.0.2
[b552c78f] + DiffRules v1.0.1
[0c46a032] + DifferentialEquations v6.11.0
[c619ae07] + DimensionalPlotRecipes v1.1.0
[b4f34e82] + Distances v0.8.2
[ffbed154] + DocStringExtensions v0.8.1
[d4d017d3] + ExponentialUtilities v1.6.0
[1a297f60] + FillArrays v0.8.5
[6a86dc24] + FiniteDiff v2.2.1
[f6369f11] + ForwardDiff v0.10.9
[069b7b12] + FunctionWrappers v1.0.0
[01680d73] + GenericSVD v0.2.2
[d25df0c9] + Inflate v0.1.1
[42fd0dbc] + IterativeSolvers v0.8.1
[82899510] + IteratorInterfaceExtensions v1.0.0
[093fc24a] + LightGraphs v1.3.1
[d3d80556] + LineSearches v7.0.1
[1914dd2f] + MacroTools v0.5.4
[f9640e96] + MultiScaleArrays v1.6.0
[d41bc354] + NLSolversBase v7.6.1
[2774e3e8] + NLsolve v4.3.0
[77ba4419] + NaNMath v0.3.3
[efe28fd5] + OpenSpecFun_jll v0.5.3+1
[bac558e1] + OrderedCollections v1.1.0
[1dea7af3] + OrdinaryDiffEq v5.29.0
[d96e819e] + Parameters v0.12.0
[e409e4f3] + PoissonRandom v0.4.0
[e6cf234a] + RandomNumbers v1.4.0
[3cdcf5f2] + RecipesBase v0.8.0
[731186ca] + RecursiveArrayTools v2.1.0
[f2c3362d] + RecursiveFactorization v0.1.0
[189a3867] + Reexport v0.2.0
[ae029012] + Requires v1.0.1
[ae5879a3] + ResettableStacks v1.0.0
[f2b01f46] + Roots v0.8.4
[699a6c99] + SimpleTraits v0.9.1
[47a9eef4] + SparseDiffTools v1.3.3
[276daf66] + SpecialFunctions v0.10.0
[90137ffa] + StaticArrays v0.12.1
[789caeaf] + StochasticDiffEq v6.19.1
[3783bdb8] + TableTraits v1.0.0
[a2a6695c] + TreeViews v0.3.0
[19fa3120] + VertexSafeGraphs v0.1.1
[700de1a5] + ZygoteRules v0.2.0
[2a0f44e3] + Base64
[8bb1440f] + DelimitedFiles
[8ba89e20] + Distributed
[b77e0a4c] + InteractiveUtils
[76f85450] + LibGit2
[8f399da3] + Libdl
[37e2e46d] + LinearAlgebra
[56ddb016] + Logging
[d6f4376e] + Markdown
[44cfe95a] + Pkg
[de0858da] + Printf
[3fa0cd96] + REPL
[9a3f8284] + Random
[ea8e919c] + SHA
[9e88b42a] + Serialization
[1a1011a3] + SharedArrays
[6462fe0b] + Sockets
[2f01184e] + SparseArrays
[10745b16] + Statistics
[4607b0f0] + SuiteSparse
[8dfed614] + Test
[cf7118a7] + UUIDs
[4ec0a83e] + Unicode

Resolving package versions...
Updating `D:\OneDrive\Computer\Desktop\Tester\Project.toml`
[587475ba] + Flux v0.10.1
Updating `D:\OneDrive\Computer\Desktop\Tester\Manifest.toml`
[621f4979] + AbstractFFTs v0.5.0
[1520ce14] + AbstractTrees v0.3.2
[fa961155] + CEnum v0.2.0
[3895d2a7] + CUDAapi v3.1.0
[be33ccc6] + CUDAnative v2.10.2
[944b1d66] + CodecZlib v0.6.0
[3da002f7] + ColorTypes v0.8.1
[5ae59095] + Colors v0.9.6
[3a865a2d] + CuArrays v1.7.2
[9a962f9c] + DataAPI v1.1.0
[7a1cc6ca] + FFTW v1.2.0
[f5851436] + FFTW_jll v3.3.9+4
[53c48c17] + FixedPointNumbers v0.6.1
[587475ba] + Flux v0.10.1
[0c68f7d7] + GPUArrays v2.0.1
[7869d1d1] + IRTools v0.3.1
[1d5cc7b8] + IntelOpenMP_jll v2018.0.3+0
[e5e0dc1b] + Juno v0.7.2
[929cbde3] + LLVM v1.3.3
[856f044c] + MKL_jll v2019.0.117+2
[e89f7d12] + Media v0.5.0
[e1d29d7a] + Missings v0.4.3
[872c559c] + NNlib v0.6.4
[a2af1166] + SortingAlgorithms v0.3.1
[2913bbd2] + StatsBase v0.32.1
[a759f4b9] + TimerOutputs v0.5.3
[3bb67fe8] + TranscodingStreams v0.9.5
[a5390f91] + ZipFile v0.9.1
[83775a58] + Zlib_jll v1.2.11+8
[e88e6eb3] + Zygote v0.4.7
[9abbd945] + Profile
``````

It worked under Julia 1.3!!! I saw the learning process happen in real time. Very nice. Now I need to be able to derive the equations myself.

I had run ]up before you suggested it. Probably this contributed to my success.

I typed in the tutorial in a Julia window in Juno and copy-pasted to the REPL. Somehow, I do not think this is the preferred approach. What is the preferred approach?

This video shows my package development workflow, but also just how I use Juno in general for projects. You see in there that I make heavy use of things like `Ctrl + Enter` to run a command in place, or `Shift + Enter` to run a command and then move to the next line. These Julia-specific commands are all mentioned in the Juno documentation: http://docs.junolab.org/latest/man/basic_usage/