sdo.optimize

Solve design optimization problem

Description

Solve an optimization problem to find the values of design variables that satisfy the design requirements.

Use sdo.optimize to solve a design optimization problem of the following form:

Here:

• F is the cost (objective).

• p is a scalar or vector of design variables.

• Cleq and Ceq are the nonlinear inequality and equality constraints, respectively.

• A and B are the linear inequality constraints.

• Aeq and Beq are the linear equality constraints.

• lb and ub are the lower and upper bounds on p, respectively.

[optimParam,optimInfo] = sdo.optimize(optimFcn,param) uses fmincon, the default optimization method, to find the parameter values optimParam that satisfy the requirements specified in optimFcn.

example

[optimParam,optimInfo] = sdo.optimize(optimFcn,param,options) solves the optimization problem with the optimization options specified in options. Use sdo.OptimizeOptions to set these options.

[optimParam,optimInfo] = sdo.optimize(prob) solves the optimization problem specified in a structure prob that contains the function to be minimized, design variables, and optimization options.

Examples

collapse all

Solve an optimization problem specified in sdoExampleCostFunction. The example cost function is included with the Simulink® Design Optimization™ software.

This example function computes the following cost:

$\mathit{f}\left(\mathit{x}\right)={\mathit{x}}^{2}$

The function also includes the following nonlinear and linear inequality constraints, respectively:

${\mathit{x}}^{2}-4\mathit{x}+1\le 0$

$\frac{2\mathit{x}}{3}-3\le 0$

For optimization, $\mathit{f}\left(\mathit{x}\right)$ is minimized, subject to satisfying the constraints. The example function also computes cost and constraint gradients.

Create a design variable, using an initial value of 1.

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

Specify default optimization options to use fmincon solver. For this example, to include cost and constraint gradient evaluation from sdoExampleCostFunction, set the GradFcn option to 'on'.

opts = sdo.OptimizeOptions;

Optimize the parameter.

[pOptim,optim_info] = sdo.optimize(@(p) sdoExampleCostFunction(p),p,opts);
Optimization started 01-Sep-2021 16:57:56

max                     First-order
Iter F-count        f(x)   constraint    Step-size    optimality
0      3            1            0
1      5         0.09            0          0.7         0.59
2      6    0.0716349     0.001047       0.0324       0.0129
3      7    0.0717968    9.127e-08     0.000302     2.37e-06
Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.

The optimized parameter value is stored in the Value property of the returned param.Continuous object pOptim.

pOptim.Value
ans = 0.2679

Input Arguments

collapse all

Cost function to minimize, specified as a function handle. 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:

FieldValue
F

Cost (objective) evaluated at p. The solver minimizes F.

F is a scalar double.

Cleq

Nonlinear inequality constraint violations evaluated at p. The solver satisfies Cleq(p) ≤ 0.

Cleq is a double m-by-1 vector, where m is the number of nonlinear inequality constraints.

Ceq

Nonlinear equality constraint violations evaluated at p. The solver satisfies Ceq(p) = 0.

Ceq is a double r-by-1 vector, where r is the number of nonlinear equality constraints.

leq

Linear inequality constraint violations evaluated at p. The solver satisfies leq(p) ≤ 0.

leq is a double n-by-1 vector, where n is the number of linear inequality constraints.

eq

Linear equality constraint violations evaluated at p. The solver satisfies eq(p) = 0.

eq is a double s-by-1 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:

FieldValue
FDouble n-by-1 vector that contains dF(p)/dp, where n is the number of scalar parameters
CleqDouble n-by-m matrix that contains dCleq(p)/dp, where m is the number of nonlinear inequality constraints
CeqDouble n-by-r matrix that contains dCeq(p)/dp, where r is the number of nonlinear equality constraints

You must return the derivatives of all applicable objective and constraint violations.

Example: For an example of a cost function that you can optimize using Simulink® Design Optimization™ software, enter edit sdoExampleCostFunction in the MATLAB® command window.

Data Types: function_handle

Model parameters to optimize, specified as a param.Continuous object or vector of param.Continuous objects.

• To specify a single parameter for optimization, use a param.Continuous object.

• To specify multiple parameters for optimization, use a vector of param.Continuous objects.

Optimization options, specified as an object created using sdo.OptimizeOptions. Use this option set to specify:

• Optimization method

• Maximum number of iterations

• Tolerances

Optimization problem structure, specified as a structure with the following fields:

Field NameValue
OptFcnCost function to minimize. See optimFcn for the input and output argument requirements of this function.
ParametersModel parameters to optimize, specified as param.Continuous objects.
OptionsOptimization options, created with sdo.OptimizeOptions.

Data Types: struct

Output Arguments

collapse all

Optimized parameter values, returned as a param.Continuous object or vector of param.Continuous objects. The size of optimParam is the same as the size of param. The optimized parameter values are stored in the Value property of the returned param.Continuous object.

Optimization information, returned as a structure with one or more of the following fields:

FieldValue
FOptimized cost (objective) value.
Cleq

Optimized nonlinear inequality constraint violations.

The field appears if you specify a nonlinear inequality constraint in optimFcn.

The value is a m-by-1 vector, where the order of the elements corresponds to the order specified in optimFcn. Positive values indicate that the constraint is not satisfied. Check the exitflag field to confirm that the optimization succeeded.

Ceq

Optimized nonlinear equality constraint violations.

The field appears if you specify a nonlinear equality constraint in optimFcn.

The value is a double r-by-1 vector, where the order of the elements corresponds to the order specified in optimFcn. Any nonzero values indicate that the constraint is not satisfied. Check the exitflag field to confirm that the optimization succeeded.

leq

Optimized linear inequality constraint violations.

The field appears if you specify a linear inequality constraint in optimFcn.

The value is a double n-by-1 vector, where the order of the elements corresponds to the order specified in optimFcn. Nonzero values indicate that the constraint is not satisfied. Check the exitflag field to confirm that the optimization succeeded.

eq

Optimized linear equality constraint violations.

The field appears if you specify linear equality constraints in optimFcn.

The value is a double s-by-1 vector, where the order of the elements corresponds to the order specified in optimFcn. Nonzero values indicate that the constraint is not satisfied. Check the exitflag field to confirm that the optimization succeeded.

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 optimFcn.

Jacobian

Jacobian information at the optimized parameter values.

The field appears if the solver specified in the Method property of sdo.OptimizeOptions computes Jacobians.

The value is a structure whose fields are dependent on optimFcn.

exitflag

Integer identifying the reason the algorithm terminated. See fmincon, patternsearch (Global Optimization Toolbox), fminsearch, and lsqnonlin for a list of the values and the corresponding termination reasons.

iterationsNumber of optimization iterations.
SolverOutput

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 (Global Optimization Toolbox), fminsearch, and lsqnonlin for a list of solver outputs and their description.

Stats

Structure that contains statistics collected during optimization, such as start and end times, number of function evaluations, and restarts.

Data Types: struct

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.

Alternative Functionality

Apps

The Response Optimizer app provides a graphical interface to specify design requirements and optimize model parameters. For more information, see Design Optimization to Meet a Custom Objective (GUI) and Design Optimization to Track Reference Signal (GUI).

The Parameter Estimator app provides a graphical interface to specify experiments and tune model parameters so that the model output matches the experiment data. For more information, see Estimate Model Parameter Values (GUI).

Extended Capabilities

Introduced in R2011a 