It looks like adjoint sensitivity analysis is not available from the Simulator class. Is the following code an efficient way to get the adjoint sensitivity of a state at multiple time points? More specifically, can some of the operations be pulled out of the loop, i.e. performed only once?

The example is an ODE with 2 states and 2 parameters. In this case I just want the sensitivity of the first state wrt all of the parameters.

integrator = casadi.CVodesIntegrator( ... time = numpy.arange(10, dtype=numpy.float) y0 = [1.0, 2.0] param = [3.0, 4.0] adjoint_sensitivities = [] seed = [1, 0] index = 0 for tf in time[1:]: integrator.setOption('t0', 0.0) integrator.setOption('tf', tf) integrator.init() integrator.input(casadi.INTEGRATOR_X0).set(y0) integrator.input(casadi.INTEGRATOR_P).set(param) integrator.setAdjSeed(seed, casadi.INTEGRATOR_XF) integrator.evaluate(0, 1) adjsens = integrator.adjSens(casadi.INTEGRATOR_P).toArray() adjoint_sensitivities.append(adjsens[index])

Thanks!