# Optimization Toolbox

## Solve linear, quadratic, conic, integer, and nonlinear optimization problems

Optimization Toolbox™ provides functions for finding parameters that minimize or maximize objectives while satisfying constraints. The toolbox includes solvers for linear programming (LP), mixed-integer linear programming (MILP), quadratic programming (QP), second-order cone programming (SOCP), nonlinear programming (NLP), constrained linear least squares, nonlinear least squares, and nonlinear equations.

You can define your optimization problem with functions and matrices or by specifying variable expressions that reflect the underlying mathematics. You can use automatic differentiation of objective and constraint functions for faster and more accurate solutions.

You can use the toolbox solvers to find optimal solutions to continuous and discrete problems, perform tradeoff analyses, and incorporate optimization methods into algorithms and applications. The toolbox lets you perform design optimization tasks, including parameter estimation, component selection, and parameter tuning. It enables you to find optimal solutions in applications such as portfolio optimization, energy management and trading, and production planning.

### Get Started:

FREE CHEAT SHEETS

### 9 MATLAB Cheat Sheets for Data Science and Machine Learning

Find just the right command for the most common tasks in your workflow.

Get cheat sheets### Modeling

Transform a problem description into a mathematical form by defining variables, objectives, and constraints, so that it can be solved with optimization techniques.

### Problem-Based Optimization

Write objectives and constraints with expressions of optimization variables. Solve faster and more robustly with automatic differentiation on the nonlinear expressions. Apply an automatically selected solver.

### Solver-Based Optimization

Write nonlinear objectives and constraints using functions; write linear objectives and constraints using coefficient matrices. Interactively create and solve the problem with the Optimize Live Editor task and then generate code for sharing or use in your application.

### Choosing a Solver

Use the Optimize Live Editor task to help choose a solver suitable for the type of problem when using the solver-based approach. The solver is automatically selected in the problem-based approach.

### Setting Options

Set optimization options to tune the optimization process, for example, to choose the optimization algorithm used by the solver, or to set termination conditions. Set options to monitor and plot optimization solver progress.

### Reviewing and Improving Results

Review the exit messages, optimality measures, and the iterative display to assess the solution. Improve performance on nonlinear problems by using automatic differentiation, supplying gradients, or using parallel computing to estimate gradients.

### Solvers

Apply quasi-Newton, trust-region, or Nelder-Mead simplex algorithms to solve unconstrained problems. Apply interior-point, sequential-quadratic-programming (SQP), or trust-region-reflective algorithms to solve constrained problems.

### Applications

Use nonlinear optimization for estimating and tuning parameters, finding optimal designs, computing optimal trajectories, constructing robust portfolios, and other applications where there is a nonlinear relationship between variables.

### Linear Programming Solvers

Apply dual-simplex or interior-point algorithms to solve linear programs.

### Quadratic and Second-Order Cone Programming Solvers

Apply interior-point, active-set, or trust-region-reflective algorithms to solve quadratic programs. Apply interior-point methods to solve second-order cone programs.

### Applications

Use linear programming on problems such as resource allocation, production planning, blending, and investment planning. Use quadratic and second-order cone programming on problems such as design optimization, portfolio optimization, and control of hydroelectric dams.

### Solvers

Solve mixed-integer linear programming problems using the branch and bound algorithm, which includes preprocessing, heuristics for generating feasible points, and cutting planes.

### Mixed-Integer Linear Programming-Based Algorithms

Use the mixed-integer linear programming solver to build special-purpose algorithms.

### Applications

Model with integer variables when there are on/off decisions or logical constraints as well as when variable values must be integral. Routing, scheduling, planning, assignment, and capital budgeting problems are typical applications.

### Solvers

Formulate problems as either goal-attainment or minimax. Use goal-attainment when there are optionally weighted goal values for each of the objectives. Use minimax to minimize the worst-case value of a set of objective functions.

### Applications

Use multiobjective optimization when tradeoffs are required for conflicting objectives. Examples are weight and strength in structural design and risk and return in portfolio optimization.

### Solvers

Apply Levenberg-Marquardt, trust-region, active-set, or interior-point algorithms.

### Linear Least-Squares Applications

Use linear least-squares solvers to fit a linear model to acquired data or to solve a system of linear equations, including when the parameters are subject to bound and linear constraints.

### Nonlinear Least-Squares Applications

Use nonlinear least-squares solvers to fit a nonlinear model to acquired data or to solve a system of nonlinear equations, including when the parameters are subject to bound constraints.

### MATLAB Compiler Support

Use MATLAB Compiler™ and MATLAB Compiler SDK™ to deploy MATLAB^{®} optimization models as standalone executables, web apps, C/C++ shared libraries, Microsoft^{®} .NET assemblies, Java^{®} classes, and Python^{®} packages.

### Code Generation

Generate portable and readable C or C++ code to solve optimization problems using MATLAB Coder™. Compile the generated code for any hardware, including embedded systems.

`Optimize`

Live Editor Task

Interactively create and solve optimization problems

### Automatic Differentiation

Solve problems faster and more accurately using automatically computed gradients of objective and constraint functions

### Second-Order Cone Programming

Solve convex optimization problems with second-order cone constraints, linear constraints, and a linear objective

### Code Generation

Generate C/C++ code to solve systems of nonlinear equations with `fsolve`

(requires MATLAB Coder)

### Code Generation

Generate C/C++ code to solve nonlinear least-squares problems with `lsqcurvefit`

or `lsqnonlin`

(requires MATLAB Coder)

See release notes for details on any of these features and corresponding functions.