Accelerating the pace of engineering and science

# Documentation Center

• Trial Software
• Product Updates

# sdo.optimize

Package: sdo

Design optimization problem solution

## Syntax

[param_opt,opt_info] = sdo.optimize(opt_fcn,param)
[param_opt,opt_info] = sdo.optimize(opt_fcn,param,options)
[param_opt,opt_info] = sdo.optimize(prob)

## Description

[param_opt,opt_info] = sdo.optimize(opt_fcn,param) uses fmincon (the default optimization method) to solve a design optimization problem of the form:

where

• p — Design variable

• Cleq, Ceq — Nonlinear inequality and equality constraints

• A, B — Linear inequality constraints

• Aeq, Beq — Linear equality constraints

• lb, ub — Upper and lower bounds on p

[param_opt,opt_info] = sdo.optimize(opt_fcn,param,options) specifies the optimization options. For parameter estimation, you typically use the Nonlinear Least Squares method:

`opts = sdo.OptimizeOptions('Method','lsqnonlin');`

[param_opt,opt_info] = sdo.optimize(prob) uses a structure that contains the function to be minimized, design variables and optimization options.

## Input Arguments

 opt_fcn Function to be minimized. The optimization solver calls this function during optimization. The function requires: One input argument, which is a vector of param.Continuous objects to be tuned.To pass additional input arguments, use an anonymous function. For example, new_fcn = @(p) fcn(p,arg1,arg2, ...).One output argument, which is a structure with one or more of the following fields:F — Value of the cost function evaluated at p. The solver minimizes F.F is a 1x1 double. Cleq — Value of the nonlinear inequality constraint violations evaluated at p. The solver satisfies Cleq(p) <= 0.Cleq is a double mx1 vector, where m is the number of nonlinear inequality constraints.Ceq — Value of the nonlinear equality constraint violations evaluated at p. The solver satisfies Ceq(p) == 0.The value is a double rx1 vector, where r is the number of nonlinear equality constraints.leq — Value of the linear inequality constraint violations evaluated at p. The solver satisfies leq(p) <= 0.leq is a double nx1 vector, where n is the number of linear inequality constraints.eq — Value of the linear equality constraint violations evaluated at p. The solver satisfies eq(p) == 0.eq is a double sx1 vector or [], where s is the number of linear equality constraints.To specify a pure feasibility problem, omit F or set F = []. To specify a minimization problem, omit Cleq, Ceq, leq and eq or set their values to [].The software computes gradients of the cost and constraint violations using numeric perturbation. If you want to specify how the gradients are computed, include a second output argument and set the GradFcn property of sdo.OptimizeOptions to 'on'. This argument must be a structure with one or more of the following fields:F — Double nx1 vector that contains dF(p)/dp, where n is the number of scalar parameters.Cleq — Double nxm matrix that contains dCleq(p)/dp, where m is the number of nonlinear inequality constraints.Ceq — Double nxr matrix that contains dCeq(p)/dp, where r is the number of nonlinear equality constraints. For an example, type edit sdoExampleCostFunction. param A param.Continuous object or a vector of objects. options Optimization options. options is an options set, created using sdo.OptimizeOptions. Use this options set to specify: Optimization methodMaximum number of iterationsTolerances prob Structure with the following fields: OptFcn — Name of the function to be minimized. See opt_fcn for the input and output argument requirements of this function.Parameters — A param.Continuous object or a vector of objectsOptions — Optimization options, specified using sdo.OptimizeOptions

## Output Arguments

 param_opt A param.Continuous object or vector of objects, containing the optimized parameter values in the Value property. opt_info Optimization information. Structure with one or more of the following fields:F — Optimized cost (objective) value.Cleq — Optimized nonlinear inequality constraint violations. The field appears if you specify a nonlinear inequality constraint in opt_fcn. The value is a mx1 vector, where the order of the elements correspond to the order specified in opt_fcn. Positive values indicate that the constraint has not been satisfied. Check exitflag to confirm that the optimization succeeded.Ceq — Optimized nonlinear equality constraint violations. The field appears if you specify a nonlinear equality constraint in opt_fcn.The value is a double rx1 vector, where the order of the elements correspond to the order specified in opt_fcn. Any nonzero values indicate that the constraint has not been satisfied. Check exitflag to confirm that the optimization succeeded.leq — Optimized linear equality constraint violations.The field appears if you specify a linear equality constraint in opt_fcn.The value is a double nx1 vector, where the order of the elements correspond to the order specified in opt_fcn. Nonzero values indicate that the constraint has not been satisfied. Check exitflag to confirm that the optimization succeeded.eq — Optimized linear equality constraint violations.The field appears if you specify linear equality constraints in opt_fcn.The value is a double sx1 vector, where the order of the elements correspond to the order specified in opt_fcn. Nonzero values indicate that the constraint has not been satisfied. Check exitflag to confirm that the optimization succeeded.Gradients — Cost and constraint gradients at the optimized parameter values. See How the Optimization Algorithm Formulates Minimization Problems on how the solver computes gradients.This field appears if the solver specified in the Method property of sdo.OptimizeOptions computes gradients.The value is a structure whose fields are dependent on opt_fcn.exitflag — Integer identifying the reason the algorithm terminated. See fmincon, patternsearch and fminsearch for a list of the values and the corresponding termination reasons.iterations — Number of optimization iterationsSolverOutput — A structure with solver-specific output information. The fields of this structure depends on the optimization solver specified in the Method property of sdo.OptimizeOptions. See fmincon, patternsearch and fminsearch for a list of solver outputs and their description.Stats — A structure that contains statistics collected during optimization, such as start and end times, number of function evaluations and restarts.

## Examples

expand all

### Optimize Model Response

Create design variables.

```p = param.Continuous('x',1);
```

Specify optimization options.

```opts = sdo.OptimizeOptions;
opts.GradFcn = 'on';
```

Optimize the parameter.

```[pOpt,opt_info] = sdo.optimize(@(p) sdoExampleCostFunction(p),p,opts);
```

## More About

expand all

### Tips

• By default, the software displays the optimization information for each iteration in the MATLAB® command window. To learn more about the information displayed, see:

You can configure the level of this display using the MethodOptions.Display property of an optimization option set.

## See Also

Was this topic helpful?