Hi, new to Julia here,
I’m trying to optimize the parameters of an ode system, while keeping some parameter constant.
Using the lotka-volterra as an example,
function f(du,u,p,t)
du[1] = dx = p[1]*u[1] - u[1]*u[2]
du[2] = dy = -a*u[2] + u[1]*u[2]
end
u0 = [1.0;1.0]
tspan = (0.0,10.0)
p = [1.5]
prob = ODEProblem(f,u0,tspan,p)
cost_function = build_loss_objective(prob,Tsit5(),L2Loss(t,data),
maxiters=10000,verbose=false)
using Optim
result = optimize(cost_function, 0.0, 10.0)
say I wanted to programmatically pass a constant ‘a’ and then optimize p, then pass a different constant ‘a’ and optimize p again, and so forth for many values of a. I am confused on the syntax for doing this. I was thinking having a function g(a) that includes all the code above and returns the optimized p, but it doesn’t seem to be the best way to do this, especially if I want to try different odes.
Thanks