# solve(ODEAdjointProblem(...)) with timespan different from the input solution

**URL:** <https://discourse.julialang.org/t/solve-odeadjointproblem-with-timespan-different-from-the-input-solution/47120>\
**Category:** General Usage\
**Tags:** question, package, diffeq\
**Created:** [September 23, 2020, 8:23am UTC](https://discourse.julialang.org/t/solve-odeadjointproblem-with-timespan-different-from-the-input-solution/47120 "2020-09-23T08:23:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samuel\_Ainsworth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel_ainsworth/32/15644_2.png) [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Post date:** [September 23, 2020, 8:23am UTC](https://discourse.julialang.org/t/solve-odeadjointproblem-with-timespan-different-from-the-input-solution/47120/1 "2020-09-23T08:23:28Z")

</div>

I’m currently doing all my ODE adjoint solves with something like

```julia
fwd_sol = solve(ODEProblem(f, (0.0, 1.0)))
solve(ODEAdjointProblem(fwd_sol, InterpolatingAdjoint(), (out, x, p, t, i) -> (out[:] = g), [1.0]))

```

which is great, but what if I’m interested in actually just doing the adjoint solve between t = 1.0 → t = 0.5, for example? Is there any way to do so?

I haven’t been able to find such an option and my attempts at altering `fwd_sol.tspan` haven’t worked out either.

---

<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 23, 2020, 8:43am UTC](https://discourse.julialang.org/t/solve-odeadjointproblem-with-timespan-different-from-the-input-solution/47120/2 "2020-09-23T08:43:57Z")

</div>

I don’t think there’s a way to do that right now, but it could be exposed. What’s the use case?

---

<div class="post-metadata">

**Author:** ![Samuel\_Ainsworth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel_ainsworth/32/15644_2.png) [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Post date:** [September 23, 2020, 9:27pm UTC](https://discourse.julialang.org/t/solve-odeadjointproblem-with-timespan-different-from-the-input-solution/47120/3 "2020-09-23T21:27:17Z")

</div>

The use-case is as a workaround/fix for [https://github.com/SciML/DifferentialEquations.jl/issues/674](https://github.com/SciML/DifferentialEquations.jl/issues/674). I have some events in my forward simulation, and I know how to differentiate “around” them. So all I need now is a way to do the adjoint solve right up to `event_time + epsilon`, do my own little tricks to change the adjoint for the event, and then continue with another adjoint solve starting at `event_time - epsilon`.
