I have this very simple ODE-contrained optimization problem:$h(x,x',p,t) = x'-A(p)x-b(p) = 0$, the constraint$g(x(0)) = x_0$, the initial condition with no parameters involved$F = \int (X-X_{obs})^2 dt$, the objective equation According to adjoint method, I need to Integrate constraint equation: $$x'=A(p)x+b(p)$$Integrate adjoint equation and reverse $\lambda$ in $t$: $$\lambda'= A(p)^T \lambda-(X-X_{obs})$$Calculate $\frac{dF}{dp}$: $$\frac{dF}{dp} = \int \lambda^T \frac{\partial h}{\partial p} dt,$$since $$\frac{\partial f}{\partial p} = \frac{\partial g}{\partial p}=0$$But for parameters only show up in $\mathbf{b(p)}$ term, derivatives from adjoint method is inconsistent with derivatives estimated using $\frac{\partial F}{\partial p}$ directly while derivatives for other parameters seem OK.Im thinking that this inconsistency maybe due to the fact that parameters in $b(p)$ doesnt affect the calculation of $\lambda$ directly, namely it doesnt show up in the adjoint equation? But there is also the possibility that I did something wrong in coding.Any body have any similar experience? Thanks!
Inaccurate Derivatives from Adjoint method for ODE-constrained problem
ode;constrained optimization