This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Problem-Based Optimization Setup

Formulate optimization problems using variables and expressions, solve in serial or parallel.

In problem-based optimization you create optimization variables, expressions in these variables that represent the objective and constraints, and solve the problem using solve. For the problem-based steps to take, see Problem-Based Workflow.

See First Choose Problem-Based or Solver-Based Approach for choosing between problem-based optimization and solver-based optimization.

Note: If you have a nonlinear function that is not a polynomial or rational expression, convert it to an optimization expression by using fcn2optimexpr. See Convert Nonlinear Function to Optimization Expression.

For a basic nonlinear optimization example, see Solve a Constrained Nonlinear Problem, Problem-Based. For a basic mixed-integer linear programming example, see Mixed-Integer Linear Programming Basics: Problem-Based.


expand all

optimproblemCreate optimization problem
optimvarCreate optimization variables
showboundsDisplay variable bounds
showproblemDisplay optimization problem
showvarDisplay optimization variable
writeboundsSave description of variable bounds
writeproblemSave optimization problem description
writevarSave optimization variable description
fcn2optimexprConvert function to optimization expression
optimconstrCreate empty optimization constraint array
optimexprCreate empty optimization expression array
showconstrDisplay optimization constraint
showexprDisplay optimization expression
writeconstrSave optimization constraint description
writeexprSave optimization expression description
evaluateEvaluate optimization expression
findindexFind numeric index equivalents of named index variables
infeasibilityConstraint violation at a point
prob2structConvert optimization problem to solver form
solveSolve optimization problem
varindexMap problem variables to solver-based variable index


OptimizationConstraintOptimization constraints
OptimizationExpressionObjective function or constraints
OptimizationProblemOptimization problem
OptimizationVariableVariable for optimization


Problem-Based Steps

Problem-Based Workflow

Problem-based steps for solving optimization problems.

Optimization Expressions

Expressions define both objective and constraints.

Pass Extra Parameters in Problem-Based Approach

Pass extra parameters, data, or fixed variables in the problem-based approach.

Named Index for Optimization Variables

How to create and work with named indices for variables.

Review or Modify Optimization Problems

Shows how to review or modify problem elements such as variables and constraints.

Examine Optimization Solution

How to evaluate the solution and its quality.

Set Options

Set Options

Set optimization options

Output Function for Problem-Based Optimization

Shows how to use an output function in the problem-based approach to record iteration history and to make a custom plot.

Tips for Problem-Based Optimization

Create Efficient Optimization Problems

Tips for obtaining a faster or more accurate solution when there are integer constraints, and for avoiding loops in problem creation.

Separate Optimization Model from Data

To create reusable, scalable problems, separate the model from the data.

Variables with Duplicate Names Disallowed

Solution to the problem of two optimization variables with the same name.

Create Initial Point for Optimization with Named Index Variables

This example shows how to create initial points for solve when you have named index variables by using the findindex function.

Expression Contains Inf or NaN

Optimization expressions containing Inf or NaN cannot be displayed, and can cause unexpected results.

Objective and Constraints Having a Common Function in Serial or Parallel, Problem-Based

Save time when your objective and nonlinear constraint functions share common computations in the problem-based approach.

Parallel Computing

What Is Parallel Computing in Optimization Toolbox?

Using multiple processors for optimization.

Using Parallel Computing in Optimization Toolbox

Automatic gradient estimation in parallel.

Minimizing an Expensive Optimization Problem Using Parallel Computing Toolbox™

Example showing the effectiveness of parallel computing in two solvers: fmincon and ga.

Improving Performance with Parallel Computing

Considerations for speeding optimizations.

Problem-Based Algorithms

Problem-Based Optimization Algorithms

How the optimization functions and objects solve optimization problems.

Supported Operations on Optimization Variables and Expressions

Lists all available mathematical and indexing operations on optimization variables and expressions.