Main Content

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 or that represent equations, and solve the problem using solve. For the problem-based steps to take for optimization problems, see Problem-Based Optimization Workflow. For equation-solving, see Problem-Based Workflow for Solving Equations.

Before you begin to solve an optimization problem, you must choose the appropriate approach: problem-based or solver-based. For details, see First Choose Problem-Based or Solver-Based Approach.

Note: If you have a nonlinear function that is not composed of polynomials, rational expressions, and elementary functions such as exp, then convert the function to an optimization expression by using fcn2optimexpr. See Convert Nonlinear Function to Optimization Expression and Supported Operations for Optimization Variables and Expressions.

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. For a basic equation-solving example, see Solve Nonlinear System of Equations, Problem-Based.


expand all

eqnproblemCreate equation problem
optimproblemCreate optimization problem
optimvarCreate optimization variables
showDisplay information about optimization object
showboundsDisplay variable bounds
writeSave optimization object description
writeboundsSave description of variable bounds
fcn2optimexprConvert function to optimization expression
optimconstrCreate empty optimization constraint array
optimeqCreate empty optimization equality array
optimineqCreate empty optimization inequality array
optimexprCreate empty optimization expression array
showDisplay information about optimization object
writeSave optimization object description
evaluateEvaluate optimization expression
findindexFind numeric index equivalents of named index variables
infeasibilityConstraint violation at a point
prob2structConvert optimization problem or equation problem to solver form
showDisplay information about optimization object
solveSolve optimization problem or equation problem
varindexMap problem variables to solver-based variable index
writeSave optimization object description


EquationProblemSystem of nonlinear equations
OptimizationConstraintOptimization constraints
OptimizationEqualityEqualities and equality constraints
OptimizationExpressionArithmetic or functional expression in terms of optimization variables
OptimizationInequalityInequality constraints
OptimizationProblemOptimization problem
OptimizationVariableVariable for optimization


Problem-Based Steps

Problem-Based Optimization Workflow

Learn the problem-based steps for solving optimization problems.

Problem-Based Workflow for Solving Equations

Learn the problem-based steps for solving equations.

Optimization Expressions

Define expressions for both the objective and constraints.

Pass Extra Parameters in Problem-Based Approach

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

Write Objective Function for Problem-Based Least Squares

Syntax rules for problem-based least squares.

Write Constraints for Problem-Based Cone Programming

Requirements for solve to use coneprog for problem solution.

Named Index for Optimization Variables

Create and work with named indices for variables.

Review or Modify Optimization Problems

Review or modify problem elements such as variables and constraints.

Examine Optimization Solution

Evaluate the solution and its quality.

Set Options

Set Options

Set optimization options

Output Function for Problem-Based Optimization

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

Obtain a faster or more accurate solution when the problem has integer constraints, and avoid loops when creating a problem.

Separate Optimization Model from Data

Create reusable, scalable problems by separating the model from the data.

Variables with Duplicate Names Disallowed

Learn how to solve a problem that has two optimization variables with the same name.

Create Initial Point for Optimization with Named Index Variables

Create initial points for solve when the problem has 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 the objective and nonlinear constraint functions share common computations in the problem-based approach.

Effect of Automatic Differentiation in Problem-Based Optimization

Automatic differentiation lowers the number of function evaluations for solving a problem.

Supply Derivatives in Problem-Based Workflow

How to include derivative information in problem-based optimization when automatic derivatives do not apply.

Obtain Generated Function Details

Find the values of extra parameters in nonlinear functions created by prob2struct.

Integer Constraints in Nonlinear Problem-Based Optimization

Learn how the problem-based optimization functions prob2struct and solve handle integer constraints.

Output Function for Problem-Based Optimization

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

Parallel Computing

What Is Parallel Computing in Optimization Toolbox?

Use multiple processors for optimization.

Using Parallel Computing in Optimization Toolbox

Perform 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

Investigate factors for speeding optimizations.

Problem-Based Algorithms

Problem-Based Optimization Algorithms

Learn how the optimization functions and objects solve optimization problems.

Automatic Differentiation Background

Learn how automatic differentiation works.

Supported Operations for Optimization Variables and Expressions

Explore the supported mathematical and indexing operations for optimization variables and expressions.