# How to choose which parameters to estimate in parameter estimation when using diffeqflux.sciml\_train and BBO?

**URL:** <https://discourse.julialang.org/t/how-to-choose-which-parameters-to-estimate-in-parameter-estimation-when-using-diffeqflux-sciml-train-and-bbo/68280>\
**Category:** Modelling & Simulations\
**Created:** [September 16, 2021, 6:09pm UTC](https://discourse.julialang.org/t/how-to-choose-which-parameters-to-estimate-in-parameter-estimation-when-using-diffeqflux-sciml-train-and-bbo/68280 "2021-09-16T18:09:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shwetank\_verma](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@shwetank\_verma](https://discourse.julialang.org/u/shwetank_verma)\
**Post date:** [September 16, 2021, 6:09pm UTC](https://discourse.julialang.org/t/how-to-choose-which-parameters-to-estimate-in-parameter-estimation-when-using-diffeqflux-sciml-train-and-bbo/68280/1 "2021-09-16T18:09:59Z")

</div>

Hey everyone, I am trying to do parameter estimation for a set of differential equations using diffeqflux\_sciml\_train and BBO. However, I would like to choose which parameters I want to estimate and which ones I don’t want to. I will illustrate this here:

```julia
function rober(du,u,p,t)
    y₁,y₂,y₃ = u
    k₁,k₂,k₃ = p
    du[1] = -k₁*y₁+k₃*y₂*y₃
    du[2] = k₁*y₁-k₂*y₂^2-k₃*y₂*y₃
    du[3] = k₂*y₂^2
    nothing
end

p = [0.04,3e7,1e4]
u0 = [1.0,0.0,0.0]
prob = ODEProblem(rober,u0,(0.0,1e5),p)
sol = solve(prob,Rosenbrock23())
ts = sol.t
Js = map(u->I + 0.1*ForwardDiff.jacobian(UJacobianWrapper(rober, 0.0, p), u), sol.u)

function loss_adjoint(p)
  "Insert loss function"
end

initp = ones(3)
res = DiffEqFlux.sciml_train(loss_adjoint, initp, BBO(),....)

```

So let’s say that I only want to estimate k2 and k3 while changing the k1 with a discrete callback based on some time stops. k1 will keep changing every second.  
How can something like this be achieved?

My actual problem is related to finding parameters of the battery physics model and I would like to have a dynamic current. I have tried training with constant current and it doesn’t work very well. So now I want to do global optimisation with the dynamic current to get a better fit.

---

<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:** [September 16, 2021, 7:52pm UTC](https://discourse.julialang.org/t/how-to-choose-which-parameters-to-estimate-in-parameter-estimation-when-using-diffeqflux-sciml-train-and-bbo/68280/2 "2021-09-16T19:52:26Z")

</div>

Just make your cost function only be a function of the two parameters and pass in the other as a constant.
