Internally, the `solve`

function
solves optimization problems by calling a solver:

`linprog`

for linear objective and linear constraints`intlinprog`

for linear objective and linear constraints and integer constraints`quadprog`

for quadratic objective and linear constraints`lsqlin`

or`lsqnonneg`

for linear least-squares with linear constraints`fminunc`

for problems without any constraints (not even variable bounds) and with a general nonlinear objective function`fmincon`

for problems with a nonlinear constraint, or with a general nonlinear objective and at least one constraint

Before `solve`

can call these
functions, the problems must be converted to solver form, either by `solve`

or some other associated functions or objects. This conversion entails, for example, linear
constraints having a matrix representation rather than an optimization variable
expression.

The first step in the algorithm occurs as you place
optimization expressions into the problem. An `OptimizationProblem`

object has an internal list of the variables used in its
expressions. Each variable has a linear index in the expression, and a size. Therefore, the
problem variables have an implied matrix form. The `prob2struct`

function performs the conversion from problem form to solver form. For an example, see Convert Problem to Structure.

For the default and allowed solvers that
`solve`

calls, depending on the problem objective and constraints, see
`'solver'`

. You
can override the default by using the `'solver'`

name-value pair argument when calling `solve`

.

For the algorithm that
`intlinprog`

uses to solve MILP problems, see intlinprog Algorithm. For
the algorithms that `linprog`

uses to solve linear programming problems,
see Linear Programming Algorithms.
For the algorithms that `quadprog`

uses to solve quadratic programming
problems, see Quadratic Programming Algorithms. For the algorithms that `lsqlin`

uses
to solve linear least-squares problems, see Least-Squares (Model Fitting) Algorithms. For
nonlinear solver algorithms, see Unconstrained Nonlinear Optimization Algorithms and Constrained Nonlinear Optimization Algorithms.

If your objective function is a sum of squares, and you want `solve`

to recognize it as such, write it as `sum(expr.^2)`

, and not as
`expr'*expr`

. The internal parser recognizes only explicit sums of
squares. For an example, see Nonnegative Least-Squares, Problem-Based.

`intlinprog`

| `linprog`

| `prob2struct`