Get Started with Problem-Based Optimization and Equations
To solve a problem using the problem-based approach, perform these steps.
Create an optimization problem using
optimproblem
or an equation-solving problem usingeqnproblem
.Create optimization variables using
optimvar
.Create expressions using the optimization variables representing the objective, constraints, or equations. Place the expressions into the problem using dot notation, such as
prob.Objective = expression1; probl.Constraints.ineq = ineq1;
For nonlinear problems, create an initial point
x0
as a structure, with the names of the optimization variables as the fields.Solve the problem by calling
solve
.
To improve your setup, increase performance, or learn details about problem-based setup, see Improve Problem-Based Organization and Performance.
For parallel computing in Optimization Toolbox™, see the last section; for parallel computing in Global Optimization Toolbox, see How to Use Parallel Processing in Global Optimization Toolbox (Global Optimization Toolbox).
Functions
Objects
EquationProblem | System of nonlinear equations |
OptimizationConstraint | Optimization constraints |
OptimizationEquality | Equalities and equality constraints |
OptimizationExpression | Arithmetic or functional expression in terms of optimization variables |
OptimizationInequality | Inequality constraints |
OptimizationProblem | Optimization problem |
OptimizationValues | Values for optimization problems (Since R2022a) |
OptimizationVariable | Variable for optimization |
Live Editor Tasks
Optimize | Optimize or solve equations in the Live Editor (Since R2020b) |
Topics
Problem-Based Procedures
- 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 forsolve
to useconeprog
for problem solution. - Review or Modify Optimization Problems
Review or modify problem elements such as variables and constraints. - Examine Optimization Solution
Evaluate the solution and its quality.
Limitations
- Variables with Duplicate Names Disallowed
Learn how to solve a problem that has two optimization variables with the same name. - Expression Contains Inf or NaN
Optimization expressions containingInf
orNaN
cannot be displayed, and can cause unexpected results.
Tune and Monitor Solution Process
- Set Optimization Options, Problem-Based
How to set and change optimization options in the problem-based approach. - 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.
Algorithms
- Problem-Based Optimization Algorithms
Learn how the optimization functions and objects solve optimization problems. - fcn2optimexpr Algorithm Description
Howfcn2optimexpr
works. - 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.
Parallel Computing in Optimization Toolbox
- 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
andga
. - Improving Performance with Parallel Computing
Investigate factors for speeding optimizations.