end
Because the objective function in this example is piecewise differentiable, the value of G
depends on the value of the pressure in Tank3.
Add the updated custom functions to the operating point specification.
opspec.CustomConstrFcn = @myConstraintsGrad;
opspec.CustomObjFcn = @myObjectiveGrad;
To enable gradients in the optimization algorithm, enable the Jacobian optimization
option.
opt.OptimizationOptions.Jacobian = 'on';
To use analytic Jacobians when trimming models using Steady State Solver or the
Linear Analysis Tool, select the Enable analytic Jacobian trimming option.
Trim the model using the custom functions with gradients, and view the trimmed states.
1 Steady-State Operating Points