# Differential Equations and Parameter Estimation

**URL:** <https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246>\
**Category:** General Usage\
**Created:** [May 15, 2019, 4:52pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246 "2019-05-15T16:52:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [May 15, 2019, 4:52pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/1 "2019-05-15T16:52:09Z")

</div>

I’m about to attempt parameter estimation using DifferentialEquations, and have a couple of questions – I hope someone can share their experience. I’ve read the tutorial, and some previous discussion.

- My problem is a single PDE of how temperature in a tank varies with some boundary inputs (influent temperature, some heating power, some volumetric flow rates, some control inputs). I have discretized the PDE using the finite difference method.
- I have data consisting of 5 inputs (“manipulated variables”) and 2 temperatures outputs sampled every minute.
- One of the sampled output temperatures T\_\mathrm{s} is a combination of an influent temperature T\_\mathrm{i} and the (unknown) effluent temperature T\_\mathrm{e}; T\_\mathrm{s} = u\_\mathrm{v} T\_\mathrm{e} + (1-u\_\mathrm{v})T\_\mathrm{i} where u\_\mathrm{v} is a control input (a split range valve setting).
- Because of the form of measurement/data T\_\mathrm{s} is not a state, I assume that it is best to pose the model as a DAE so that I can have T\_\mathrm{s} as a solution – ODEs can only have states as a solution, I guess.
- I will probably use 2 hyper parameters in the model fitting: (i) the number n of compartments in the discretized model, and (ii) the weight \lambda of the regularization term.
- I noted Chris’ response to `alewolf` on how to choose which variables in the DAE solver are used in the loss function (`save_idxs` argument).

My **questions** are the following…

1. My input data are available at a discrete time interval (1 min). I can handle this in two ways:  
a. Set up a `for` loop, and solve the DAE over 1 minute with constant input, passing the final result as initial time to the next iteration in the for loop, and let the cost function be the sum of each sub sum, or  
b. Create an interpolation function for the input data so that the DAE solver knows the value at all times.  
Which is recommended, (a) or (b)?
2. In general, initial states will be unknown, and I assume that I should pose these as unknown parameters in the model fitting? (n compartments…)
3. The regularization term – it looks like the standard is to add the squared 2-norm of the parameter vector. If I have some idea of what the parameters should be… which is best?  
a. Add bounds for the parameters in the optimization problem, or  
b. Formulate the regularization term to be the norm of the deviation of the parameter from some initial guess?  
c. Combining the above, i.e., combine (a) and (b)?
4. If my _validation_ set is not immediately following in time my training set, the initial states of the validation set will be unknown. How to I handle this problem?

- Use state estimation for the validation problem?
- Use state estimation for both the validation problem and the training problem for assessing hyper parameters?

1. If I vary my two hyper parameters simultaneously (n and \lambda) and compare the RMSE of both the training set and the validation set to choose the hyper parameters, I get a 2D problem. Should I tackle one at a time?

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [May 15, 2019, 10:11pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/2 "2019-05-15T22:11:03Z")

</div>

the tank is agitated? you can have some boundaries using a CSTR and a PFR results as limits

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 16, 2019, 12:44am UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/3 "2019-05-16T00:44:29Z")

</div>

> [@BLI](#):
>
> Which is recommended, (a) or (b)?

Neither. Just solve one DAE with `saveat=1`, and then use the result array against all data points at once.

> [@BLI](#):
>
> In general, initial states will be unknown, and I assume that I should pose these as unknown parameters in the model fitting? (

Yes, just make them functions of parameters being fit

> [@BLI](#):
>
> - c. Combining the above, i.e., combine (a) and (b)?

(a) is what’s usually done, (b) is a little weird but is in some sense related to putting a Gaussian prior distribution and doing MAP.

> [@BLI](#):
>
> 1. If my _validation_ set is not immediately following in time my training set, the initial states of the validation set will be unknown. How to I handle this problem?

Your choice.

> [@BLI](#):
>
> If I vary my two hyper parameters simultaneously (nn and λ\lambda) and compare the RMSE of both the training set and the validation set to choose the hyper parameters, I get a 2D problem. Should I tackle one at a time?

Or use the gradient.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [May 16, 2019, 9:38am UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/4 "2019-05-16T09:38:53Z")

</div>

The tank model describes stratification in the temperature, so the temperature is distributed.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [May 16, 2019, 10:02am UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/5 "2019-05-16T10:02:21Z")

</div>

Thanks, Chris. My first question was perhaps not very clear. My model is typically:

- \frac{dx}{dt} = f(x,u;\theta), with sampled outputs from y=g(x,u;\theta).
- I have input-output pairs (u\_i,y\_i),\quad i\in \{1,\ldots,N\_d\}, thus N\_d data points sampled at 1 min interval.
- The model solution x(t) is influenced by the input u(t)\in \mathbb{R}^5, and so is the output y(t)\in \mathbb{R}^2.
- Because I don’t observe the states directly, but instead the mapped y variable, I think I need a DAE formulation instead of an ODE formulation.
- **Critical element of question** : Because u(t) influences the solution, I assume that I need to either…  
i. Make an interpolant for u\_i so that the DAE has u(t) available, or  
ii. Make a for loop for solving the model in the interval [t\_i,t\_{i+1}) with constant input u\_i, and then let the solution x(t\_{i+1}) become the initial value for the next value of i??

Hm… there is perhaps a third way that looks like what you suggest:

- Make the input an unknown parameter, use both u\_i and y\_i as data, and use parameter fitting to find the value of the unknown input.
- In this approach, it should be straightforward to find the unknown input parameter because it will be equal to the datapoints u\_i??
- I would still need to do some interpolation-like thing in the DAE model, to let the model know which of the input parameters to use.
- I have lots of data; N\_d is in the order of `1e4` – possibly sampled too often.

Anyway, is there an example around on model fitting with models influenced by inputs?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 18, 2019, 11:52am UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/6 "2019-05-18T11:52:41Z")

</div>

> [@BLI](#):
>
> Because I don’t observe the states directly, but instead the mapped yy variable, I think I need a DAE formulation instead of an ODE formulation.

Only if they are implicitly defined. Otherwise it’s still an ODE. I guess the API on the parameter estimation is the issue here. You can define your own cost function to that uses explicit definitions from the ODE.

> [@BLI](#):
>
> Make an interpolant for uiu\_i so that the DAE has u(t)u(t) available

This shows up enough that we made [GitHub - SciML/DataInterpolations.jl: A library of data interpolation and smoothing functions](https://github.com/UMCTM/DataInterpolations.jl) for this.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 12, 2019, 4:35pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/7 "2019-06-12T16:35:56Z")

</div>

I’ve fine-tuned my simulation code with experimental data, etc., and am ready to start parameter estimation…

Four questions:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/b/1b3691fa7e90d7d8b5235e33193bf919583c38c4.png)

1. `build_loss_objective` – does it compute a **single shooting** cost function? [If so, why not give it the more descriptive name `single_shooting_objective`, in line with `multiple_shooting_objective`?)
2. The `build_loss_objective` function — I _assume_ that it takes the entire parameter object `p` of the `DifferentialEquations` problem as input argument to the resulting cost function, and returns a scalar number measuring the model fit??
3. Is it required that the parameter object `p` of the `DifferentialEquations` object is a _vector_, or can it be any ordered collection such as a named tuple?
4. Is it possible to specify a _subset_ of parameter object `p` for the `DifferentialEquations` problem?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 12, 2019, 5:03pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/8 "2019-06-12T17:03:34Z")

</div>

> [@BLI](#):
>
> `build_loss_objective` – does it compute a **single shooting** cost function? [If so, why not give it the more descriptive name `single_shooting_objective` , in line with `multiple_shooting_objective` ?)

Legacy. This is a good breaking change to propose for DiffEq 7.0

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 12, 2019, 5:05pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/9 "2019-06-12T17:05:48Z")

</div>

> [@BLI](#):
>
> - The `build_loss_objective` function — I _assume_ that it takes the entire parameter object `p` of the `DifferentialEquations` problem as input argument to the resulting cost function, and returns a scalar number measuring the model fit??
> - Is it required that the parameter object `p` of the `DifferentialEquations` object is a _vector_ , or can it be any ordered collection such as a named tuple?
> - Is it possible to specify a _subset_ of parameter object `p` for the `DifferentialEquations` problem

It needs to be a vector and it needs to be the full vector. This is somewhat of an interface problem that we need to sort out with the optimization libraries. And yes the cost function reduces to a scalar.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 12, 2019, 5:45pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/10 "2019-06-12T17:45:31Z")

</div>

Ah…

```julia
julia> p=(a=1,b=2)
(a = 1, b = 2)

julia> keys(p)
(:a, :b)

julia> values(p)
(1, 2)

```

Is there a way to “merge” these two tuples (`keys(p)` and `values(p)`) back into `p`?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 12, 2019, 6:39pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/12 "2019-06-12T18:39:47Z")

</div>

OK… I figured it out:

```julia
julia> p
(a = 1, b = 2)

julia> k=keys(p)
(:a, :b)

julia> v=values(p)
(1, 2)

julia> NamedTuple{k}(p)
(a = 1, b = 2)

```

This should make it possible to use a named tuple `p` as argument to the `DifferentialEquations` model… something like:

```julia
julia> p = (a=1,b=2,c=3,d=4,e=5,f=6)
(a = 1, b = 2, c = 3, d = 4, e = 5, f = 6)

julia> k=keys(p)
(:a, :b, :c, :d, :e, :f)

julia> val=values(p)
(1, 2, 3, 4, 5, 6)

julia> vec=collect(val)
6-element Array{Int64,1}:
 1
 2
 3
 4
 5
 6

julia> idx = [1,3];

julia> vec[idx]
2-element Array{Int64,1}:
 1
 3

julia> vec[idx] = [3,1]
2-element Array{Int64,1}:
 3
 1

julia> vec
6-element Array{Int64,1}:
 3
 2
 1
 4
 5
 6

julia> NamedTuple{k}(Tuple(vec))
(a = 3, b = 2, c = 1, d = 4, e = 5, f = 6)

```

I don’t know how efficient this will be, but it will allow me to use named tuples as the parameter object in `DifferentialEquations`, specify the indices of the subset of the parameters that I want to change in the model, convert these to a vector, use this vector as input argument to the cost function for the optimization algorithm, read the improved parameter from the optimization code, convert these back to a named tuple for the `DifferentialEquations` model, etc., etc.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 15, 2019, 12:19pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/13 "2019-06-15T12:19:15Z")

</div>

OK – my parameter estimation works, but my `loss()` function causes lots of memory usage… I’m looking for tips to reduce the memory consumption/reduce garbage collection.

To recapture/expand:

1. My model of a stratified water tank is a PDE, which I have semi discretized into `nT` ODEs. I want to be able to play around with the size of `nT`, and I need to pose the initial values T\_i(0) as unknown parameters — hence changing `nt` causes a change in the size of the parameter vector.
2. I have two response observations: the temperature in the upper part of the tank (index i in T\_i varies with `nT`) + an observation outside of the tank where effluent water from the tank is mixed with influent water. This second observation is an algebraic mixture of an input variable and a state. I can handle this in two ways:  
a. Pose the system as a DAE, or  
b. Pose the system as an ODE and write my own loss function.  
I’ve done the latter (b).
3. Stupid or not, I have transferred physical parameters to the model in a NamedTuple named `p`. I want the set-up to be flexible. So I have set up the code so that I can choose an index vector `pidx` to specify which physical parameters in `p`that I want to adjust/“train”.

- This has some consequences: the parameters to tune need to be in a _vector_ of `Float64` numbers (at least in Optim). So there is some management to pick out values from the NamedTuple `p`, insert them in the parameter vector to tune `pvec`, etc.
- The code could have been simplified if I instead had used physical parameters in a vector directly (instead of a NamedTuple). But then I (i) would have lost the possibility to use the field name in my model code (e.g., I use `p.g` for gravity — instead of the more obscure `p[1]`), (ii) I would have to do error prone changes in the model code every time I change the parameter set that I want to estimate. This is very much a trial and error thing, so flexibility is important.

1. Experimental input data are transferred via a NamedTuple `f` of linear interpolation functions.

OK – here is my code — which is highly inefficient (I think…):

```julia
function cost(pvec,p,pidx,f,wt,T0,tspan,dt,ks1,data)
# pvec: the Float64 vector of unknown parameters
# p: the NamedTuple of physical parameters
# pidx: a vector of Int with indices of the parameters of p that I want to tune
# f: a NamedTuple of linear interpolation functions which specify time functions of experimental input data
# wt: the name of my water tank model; needed to create the simulation problem
# T0: initial guess of temperatures in model. These are inserted into `pvec` and are adjusted
# tspan: simulation time span -- needed to set up the simulation problem
# dt: sample time in the experimental data
# kS1: index of the computed $T_i$ where the sensor of the first observation is located
# data: matrix of data from observations -- 2 rows; one state (index kS1) and one algebraic output

    nT = length(T0) # Gives number of initial states that taken from `pvec` and used as initial values in the simulation problem. The other elements of `pvec` are inserted in the NamedTuple `p_k` --- the update of `p`. 
    p_key = keys(p)
    p_val = collect(values(p))
    p_val[pidx] .= pvec[nT+1:end]
    p_k = NamedTuple{p_key}(Tuple(p_val)) # I name the updated parameter NamedTuple by `p_k` to avoid overwriting the initial guess I have
    # 
    prob = ODEProblem(wt,pvec[1:nT],tspan,p_k) # Simulation/shooting problem, with updated initial states
    sol = solve(prob, saveat=dt)
    Sol = reduce(hcat,sol.u)
    Tm_i_L = f.T_i.(sol.t).*(1 .-f.u_v.(sol.t)) .+ Sol[end,:].*f.u_v.(sol.t) # Algebraic variable; mixture of input temperature, output temperature, weighted by some valve opening
    sim = [Sol[ks1,:]';Tm_i_L'] # picking out the simulation/shooting solutions that I want to compare with the experimental data
    N = length(sim)
    #
    return norm(sim-data,2)^2/N
    #
end

```

with `loss` function for the Optim code given as:

```julia
loss = (pvec) -> cost(pvec,p,pidx,f_r,wt_r,T0,tspan_o,dt_r,kS1o,data_r)

```

Optimization is done with:

```julia
@time res = optimize(loss,p_lo,p_hi,pvec,Fminbox())

```

…which takes 8 minutes on my desktop workstation with 32 GB RAM, and some estimated memory use of 74 GiB.

Anyway, any tips for improvements are appreciated! I know it is a pain to read the code of others, so please bear over with me…

There are loads of variables that are introduced every time the `cost` function is called, so I understand that the code is not good… I have thought of passing these as modifiable input arguments to the `cost` function, but…  
A. Are all variables _mutable_? E.g., `prob`, `sol`, etc?  
B. Is it possible to “update”, e.g., `prob` in an efficient way?  
C. Etc.

Any suggestions are appreciated. I _know_ that I can rewrite the problem into an DAE and use the standard set-up, but that will have a dramatic cost wrt. flexibility — I think.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 15, 2019, 3:54pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/14 "2019-06-15T15:54:02Z")

</div>

When you profile, are the array allocations a large chunk of the time? Finding out what to optimize is sometimes more important than finding out how to optimize. If a profile shows most of the time is spent in `solve`, then the efficiency of the rest of the cost function doesn’t matter.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 15, 2019, 4:25pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/15 "2019-06-15T16:25:28Z")

</div>

Thanks for tip. I’ve never done profiling before… should I use the `Profile` package? Is the `ProfileView` package useful, or is my problem too simple for that.

I used `Fminbox()` from the Optim package. I observed (see comments under the Optimization category) that `Fminbox()` seems to miss somewhat with the solution in the scalar case.

Do you recommend another solver?

- Another solver from Optim, or
- A specific solver from Jump?
- Or another solver?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 15, 2019, 4:34pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/16 "2019-06-15T16:34:01Z")

</div>

This describes how to profile with Juno: [macOS Python with numpy faster than Julia in training neural network - Stack Overflow](https://stackoverflow.com/questions/49719076/macos-python-with-numpy-faster-than-julia-in-training-neural-network/49724611#49724611) . And if you’re not using Juno, ProfileView.jl will give you a similar GUI.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 18, 2019, 7:02am UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/17 "2019-06-18T07:02:32Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/7/7/773bc649f6e7f722a00a976797a16ffa5a641d21.png)

Here is the result from ProfileView in IJulia. From the user description at ProfileView.jl, I thought that I could hover the mouse over the various areas and get some more insight, but hovering doesn’t help… (Btw: I needed to increase the resolution from the default 10^6…).

How can I use this profile view?

NOTE: when `using ProfileView`, I’m told that:

```julia
julia> using ProfileView
[Info: Precompiling Gtk [4c0ca9eb-093a-5379-98c5-f87ac0bbbf44]
ERROR: LoadError: Cairo not properly installed. Please run
Pkg.build("Cairo")

```

If I run `Pkg.build("Cairo")`, I get error messages:

```julia
julia> Pkg.build("Cairo")
  Building LibCURL ─→ `C:\Users\user_name\.julia\packages\LibCURL\teHPG\deps\build.log`
  Building WinRPM ──→ `C:\Users\user_name\.julia\packages\WinRPM\Y9QdZ\deps\build.log`
  Building Homebrew → `C:\Users\user_name\.julia\packages\Homebrew\s09IX\deps\build.log`
  Building Cairo ───→ `C:\Users\user_name\.julia\packages\Cairo\p68X8\deps\build.log`
┌ Error: Error building `Cairo`:
│ [ Info: Updating WinRPM package list
│ [ Info: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_42.2/repodata/repomd.xml
│ [ Info: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_Leap_42.2/repodata/repomd.xml
│ [ Info: Nothing to do
│ [ Info: Nothing to do
│ ERROR: LoadError: Provider WinRPM.RPM failed to satisfy dependency pango
│ Stacktrace:
│ [1] error(::String) at .\error.jl:33
│ [2] satisfy!(::BinDeps.LibraryDependency, ::Array{DataType,1}) at C:\Users\user_name\.julia\packages\BinDeps\ZEval\src\dependencies.jl:945
│ [3] satisfy!(::BinDeps.LibraryGroup, ::Array{DataType,1}) at C:\Users\user_name\.julia\packages\BinDeps\ZEval\src\dependencies.jl:910
│ [4] satisfy!(::BinDeps.LibraryGroup) at C:\Users\user_name\.julia\packages\BinDeps\ZEval\src\dependencies.jl:874
│ [5] top-level scope at C:\Users\user_name\.julia\packages\BinDeps\ZEval\src\dependencies.jl:977
│ [6] include at .\boot.jl:326 [inlined]
│ [7] include_relative(::Module, ::String) at .\loading.jl:1038
│ [8] include(::Module, ::String) at .\sysimg.jl:29
│ [9] include(::String) at .\client.jl:403
│ [10] top-level scope at none:0
│ in expression starting at C:\Users\user_name\.julia\packages\Cairo\p68X8\deps\build.jl:176
└ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Pkg\src\Operations.jl:1075

```

I don’t know if these error messages are related to those at [Problem with Cairo building - #10 by tobias.knopp](https://discourse.julialang.org/t/problem-with-cairo-building/23600/10) (which seems to be for a Linux installation). The ProfileView version is ` [c46f51b8] ProfileView v0.4.1`.

Anyway, I’ll transfer the commands from IJulia to Juno, and try without using ProfileView.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 18, 2019, 1:10pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/18 "2019-06-18T13:10:01Z")

</div>

The line numbers are really the thing to be seen. Is all time spent in the ODE solve?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 19, 2019, 6:38am UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/19 "2019-06-19T06:38:26Z")

</div>

I redid the simulations in Juno; Juno.profiler() worked without the Cairo problems of ProfileView:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/6/b6736225291a20d6177ac4f23c8dbc15a339cd01.png)

When I hover the mouse over the various areas in the profile plot, the areas encircled in blue appear to relate to Optim, while those encircled in red appear to be related to DifferentialEquations. More or less.

What do I learn from this?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 19, 2019, 9:52am UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/20 "2019-06-19T09:52:13Z")

</div>

Wow, that is a very deep stack. Did you do an analysis to check what lines/functions the time is generally spent it? This graphic omits all of the line information.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 19, 2019, 8:49pm UTC](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246/21 "2019-06-19T20:49:16Z")

</div>

I didn’t see how I could read the line number in Juno from the profile. I’ll check again after the weekend. I need to give priority to some application deadline + a midsummer hike in the mountains (in the rain).

[Next page](https://discourse.julialang.org/t/differential-equations-and-parameter-estimation/24246.md?page=2)
