S = odeSensitivity()
S = odeSensitivity(name, value)
odeSensitivity stores sensitivity settings for the ode object workflow. Nelson solves direct forward sensitivities for explicit and fully implicit problems with a numeric parameter vector.
| Object | Purpose | Used by |
|---|---|---|
| odeSensitivity | Stores a reusable definition for the ode object workflow. | The matching ode property and solve. |
| Validation | Checks supported names and shapes at construction time. | Tests and errors stay explicit before integration. |
When the optional SUNDIALS backend is available, cvodesnonstiff, cvodesstiff, and idas use native direct forward sensitivity support for problems without event callbacks. cvodesnonstiff, cvodesstiff, and idas also support adjoint gradients for scalar final objectives and optional scalar integral objectives.
The direct Sensitivity result is an array with dimensions state-by-parameter-by-time. Event locations without callbacks also populate EventSensitivity. The adjoint result is AdjointGradient, a row vector ordered like ParameterIndices. Output functions receive the physical state only. Mass matrices, nonnegative state constraints, and delayed equations are supported for explicit direct sensitivities. Event callbacks, separated complex parts, delayed output functions, and delayed adjoints are not supported yet.
Method defaults to direct. The value forward is accepted as an alias for direct. With Method set to adjoint, provide ObjectiveFcn, QuadratureFcn, or both. These functions are called as f(t,y,p) and must return a real scalar. ObjectiveTime is reserved for final-time objectives and must match the solve final time when provided. AdjointRelativeTolerance and AdjointAbsoluteTolerance override the backward problem tolerances.
F = ode('ODEFcn', @(t,y,p) p(1) * y, ...
'InitialValue', 1, ...
'Parameters', 2, ...
'Sensitivity', odeSensitivity('ParameterIndices', 1));
R = solve(F, 0, 0.2);
Sfinal = R.Sensitivity(1, 1, length(R.Time))
F = ode('ODEFcn', @(t,y,p) p(1), ...
'InitialValue', 0, ...
'Parameters', 2, ...
'Sensitivity', odeSensitivity(), ...
'EventDefinition', odeEvent('EventFcn', @(t,y) y - 0.5, 'Response', 'stop'));
R = solve(F, 0, 1);
R.EventSensitivity(1, 1, 1)
F = ode('EquationType', 'fullyimplicit', ...
'ODEFcn', @(t,y,yp,p) yp + p(1) * y, ...
'InitialValue', 1, ...
'InitialSlope', -2, ...
'Parameters', 2, ...
'Sensitivity', odeSensitivity());
R = solve(F, 0, 0.2);
Sfinal = R.Sensitivity(1, 1, length(R.Time))
F = ode('ODEFcn', @(t,y,p) p(1) * y, ...
'InitialValue', 1, ...
'Parameters', 2, ...
'Sensitivity', odeSensitivity('Method', 'adjoint', ...
'ObjectiveFcn', @(t,y,p) y(1)), ...
'Solver', 'cvodesnonstiff');
R = solve(F, 0, 0.5);
R.AdjointGradient
| Version | Description |
|---|---|
| 2.0.0 | initial version |