PETSc version 3.16.5
Fix/Edit manual page

# TSSetCostGradients

Sets the initial value of the gradients of the cost function w.r.t. initial values and w.r.t. the problem parameters for use by the TSAdjoint routines.

### Synopsis

    #include "petscts.h"
    PetscErrorCode TSSetCostGradients(TS ts,PetscInt numcost,Vec *lambda,Vec *mu)

Logically Collective on TS

### Input Parameters

| ts | - the TS context obtained from TSCreate()
| numcost | - number of gradients to be computed, this is the number of cost functions
| lambda | - gradients with respect to the initial condition variables, the dimension and parallel layout of these vectors is the same as the ODE solution vector
| mu | - gradients with respect to the parameters, the number of entries in these vectors is the same as the number of parameters

### Notes

the entries in these vectors must be correctly initialized with the values lamda_i = df/dy|finaltime mu_i = df/dp|finaltime

After TSAdjointSolve() is called the lamba and the mu contain the computed sensitivities

### See Also

TSGetCostGradients()

### Level

beginner

### Location

src/ts/interface/sensitivity/tssen.c

### Examples

src/ts/tutorials/ex23fwdadj.c.html
src/ts/tutorials/extchem.c.html
src/ts/tutorials/extchemfield.c.html
src/ts/tutorials/ex20adj.c.html
src/ts/tutorials/ex20opt_p.c.html
src/ts/tutorials/ex20opt_ic.c.html
src/ts/tutorials/ex20td.c.html
src/tao/unconstrained/tutorials/spectraladjointassimilation.c.html
Index of all Sensitivity routines
Table of Contents for all manual pages
Index of all manual pages