Skip to Main Content Skip to Search
Product Documentation

Choosing a Solver

Optimization Decision Table

The following table is designed to help you choose a solver. It does not address multiobjective optimization or equation solving. There are more details on all the solvers in Problems Handled by Optimization Toolbox Functions.

Use the table as follows:

  1. Identify your objective function as one of five types:

    • Linear

    • Quadratic

    • Sum-of-squares (Least squares)

    • Smooth nonlinear

    • Nonsmooth

  2. Identify your constraints as one of five types:

    • None (unconstrained)

    • Bound

    • Linear (including bound)

    • General smooth

    • Discrete (integer)

  3. Use the table to identify a relevant solver.

In this table:

Solvers by Objective and Constraint

Constraint Type Objective Type
LinearQuadraticLeast SquaresSmooth nonlinearNonsmooth
Nonen/a (f = const, or min = )quadprog, Theory, Examples\, lsqcurvefit, lsqnonlin, Theory, Examplesfminsearch, fminunc, Theory, Examplesfminsearch, *
Boundlinprog, Theory, Examplesquadprog, Theory, Exampleslsqcurvefit, lsqlin, lsqnonlin, lsqnonneg, Theory, Examplesfminbnd, fmincon, fseminf, Theory, Examplesfminbnd, *
Linearlinprog, Theory, Examplesquadprog, Theory, Exampleslsqlin, Theory, Examplesfmincon, fseminf, Theory, Examples*
General smoothfmincon, Theory, Examplesfmincon, Theory, Examplesfmincon, Theory, Examplesfmincon, fseminf, Theory, Examples*
Discretebintprog, *, Theory, Example****

Choosing the Algorithm

fmincon Algorithms

fmincon has four algorithm options:

Use optimset to set the Algorithm option at the command line.

Recommendations
  • Use the 'interior-point' algorithm first.

    For help if the minimization fails, see When the Solver Fails or When the Solver Might Have Succeeded.

  • To run an optimization again to obtain more speed on small- to medium-sized problems, try 'sqp' next, and 'active-set' last.

  • Use 'trust-region-reflective' when applicable. Your problem must have: objective function includes gradient, only bounds, or only linear equality constraints (but not both).

Reasoning Behind the Recommendations.  

fsolve Algorithms

fsolve has three algorithms:

Use optimset to set the Algorithm option at the command line.

Recommendations

Reasoning Behind the Recommendations.  

fminunc Algorithms

fminunc has two algorithms:

Choose between them at the command line by using optimset to set the LargeScale option to:

Recommendations
  • If your objective function includes a gradient, use 'LargeScale' = 'on'.

  • Otherwise, use 'LargeScale' = 'off'.

For help if the minimization fails, see When the Solver Fails or When the Solver Might Have Succeeded.

Least Squares Algorithms

lsqlin.  lsqlin has two algorithms:

Choose between them at the command line by using optimset to set the LargeScale option to:

Recommendations
  • If you have no constraints or only bound constraints, use 'LargeScale' = 'on'.

  • If you have linear constraints, use 'LargeScale' = 'off'.

For help if the minimization fails, see When the Solver Fails or When the Solver Might Have Succeeded.

lsqcurvefit and lsqnonlin.  lsqcurvefit and lsqnonlin have two algorithms:

Use optimset to set the Algorithm option at the command line.

Recommendations
  • If you have no constraints or only bound constraints, use 'trust-region-reflective'.

  • If your problem is underdetermined (fewer equations than dimensions), use 'levenberg-marquardt'.

For help if the minimization fails, see When the Solver Fails or When the Solver Might Have Succeeded.

Linear Programming Algorithms

linprog has three algorithms:

Choose between them at the command line by using optimset to set the LargeScale option to:

Recommendations

Use 'LargeScale' = 'on'

For help if the minimization fails, see When the Solver Fails or When the Solver Might Have Succeeded.

Quadratic Programming Algorithms

quadprog has three algorithms:

Use optimset to set the Algorithm option at the command line.

Recommendations
  • If you have a convex problem, or if you don't know whether your problem is convex, use interior-point-convex.

  • If you have only bounds, or only linear equalities, use trust-region-reflective.

  • If you have a nonconvex problem that does not satisfy the restrictions of trust-region-reflective, use active-set.

For help if the minimization fails, see When the Solver Fails or When the Solver Might Have Succeeded.

Problems Handled by Optimization Toolbox Functions

The following tables show the functions available for minimization, equation solving, multiobjective optimization, and solving least-squares or data-fitting problems.

Minimization Problems

TypeFormulationSolver

Scalar minimization

such that l < x < u (x is scalar)

fminbnd

Unconstrained minimization

fminunc,
fminsearch

Linear programming

such that A·x ≤ b, Aeq·x = beq, l ≤ x ≤ u

linprog

Quadratic programming

such that A·x ≤ b, Aeq·x = beq, l ≤ x ≤ u

quadprog

Constrained minimization

such that c(x) ≤ 0, ceq(x) = 0, A·x ≤ b, Aeq·x = beq, l ≤ x ≤ u

fmincon

Semi-infinite minimization

such that K(x,w) ≤ 0 for all w, c(x) ≤ 0, ceq(x) = 0, A·x ≤ b, Aeq·x = beq, l ≤ x ≤ u

fseminf

Binary integer programming

such that A·x ≤ b, Aeq·x = beq, x binary

bintprog

Multiobjective Problems

TypeFormulationSolver

Goal attainment

such that F(x) – w·γ ≤ goal, c(x) ≤ 0, ceq(x) = 0, A·x ≤ b, Aeq·x = beq, l ≤ x ≤ u

fgoalattain

Minimax

such that c(x) ≤ 0, ceq(x) = 0, A·x ≤ b, Aeq·x = beq, l ≤ x ≤ u

fminimax

Equation Solving Problems

TypeFormulationSolver

Linear equations

C·x = d, n equations, n variables

\ (matrix left division)

Nonlinear equation of one variable

f(x) = 0

fzero

Nonlinear equations

F(x) = 0, n equations, n variables

fsolve

Least-Squares (Model-Fitting) Problems

TypeFormulationSolver

Linear least-squares

m equations, n variables

\ (matrix left division)

Nonnegative linear-least-squares

such that x ≥ 0

lsqnonneg

Constrained linear-least-squares

such that A·x ≤ b, Aeq·x = beq, lb ≤ x ≤ ub

lsqlin

Nonlinear least-squares

such that lb ≤ x ≤ ub

lsqnonlin

Nonlinear curve fitting

such that lb ≤ x ≤ ub


lsqcurvefit

  


Free Optimization Interactive Kit

Learn how to use optimization to solve systems of equations, fit models to data, or optimize system performance.

Get free kit

Trials Available

Try the latest version of optimization products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS