Ask Your Question
1

What is the solution for the "Undefined Variable Error: InterpolatingAdjoint" error when utilizing "Differentialequations.jl" in Julia?

asked 2023-07-12 07:38:28 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-07-12 07:43:01 +0000

lalupa gravatar image

The "Undefined Variable Error: InterpolatingAdjoint" error occurs when the InterpolatingAdjoint method is not properly imported in the Julia code. To resolve this error, one should ensure that the InterpolatingAdjoint method is explicitly imported in the code, like so:

using DifferentialEquations
using DiffEqSensitivity

function my_ode!(du,u,p,t)
    du[1] = -u[1] + p[1]*u[2]
    du[2] = u[1] - p[2]*u[2]
end

function my_ode_jac!(J,du,u,p,t)
    J[1,1] = -1;     J[1,2] = p[1]
    J[2,1] =  1;     J[2,2] = -p[2]
end

p = [1.5,1.0]
u0 = [1.0,0.0]
tspan = (0.0,2.5)
prob = ODEProblem(my_ode!,u0,tspan,p,jac=my_ode_jac!)
sol = solve(prob,Vern9(),adjoint=true)

sensitivity_interpolant = InterpolatingAdjoint(sol)

Here, the DiffEqSensitivity package is imported in addition to the DifferentialEquations package, and the Sensitivity package's InterpolatingAdjoint method is used to create a sensitivity interpolant.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-12 07:38:28 +0000

Seen: 10 times

Last updated: Jul 12 '23