Main Content

Get Started with Problem-Based Optimization and Equations

Get started with problem-based setup

To solve a problem using the problem-based approach, perform these steps.

  • Create an optimization problem using optimproblem or an equation-solving problem using eqnproblem.

  • 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).


expand all

eqnproblemCreate equation problem (Since R2019b)
optimproblemCreate optimization problem
optimvaluesCreate values for optimization problem (Since R2022a)
optimvarCreate optimization variables
showDisplay information about optimization object (Since R2019b)
showboundsDisplay variable bounds
writeSave optimization object description (Since R2019b)
writeboundsSave description of variable bounds
fcn2optimexprConvert function to optimization expression
optimconstrCreate empty optimization constraint array
optimeqCreate empty optimization equality array (Since R2019b)
optimineqCreate empty optimization inequality array (Since R2019b)
optimexprCreate empty optimization expression array
showDisplay information about optimization object (Since R2019b)
writeSave optimization object description (Since R2019b)
evaluateEvaluate optimization expression or objectives and constraints in problem
findindexFind numeric index equivalents of named index variables
infeasibilityConstraint violation at a point
issatisfiedConstraint satisfaction of an optimization problem at a set of points (Since R2024a)
paretoplotPareto plot of multiobjective values (Since R2022a)
prob2structConvert optimization problem or equation problem to solver form
showDisplay information about optimization object (Since R2019b)
solveSolve optimization problem or equation problem
solversDetermine default and valid solvers for optimization problem or equation problem (Since R2022b)
varindexMap problem variables to solver-based variable index
writeSave optimization object description (Since R2019b)


EquationProblemSystem of nonlinear equations (Since R2019b)
OptimizationConstraintOptimization constraints
OptimizationEqualityEqualities and equality constraints (Since R2019b)
OptimizationExpressionArithmetic or functional expression in terms of optimization variables
OptimizationInequalityInequality constraints (Since R2019b)
OptimizationProblemOptimization problem
OptimizationValuesValues for optimization problems (Since R2022a)
OptimizationVariableVariable for optimization

Live Editor Tasks

OptimizeOptimize or solve equations in the Live Editor (Since R2020b)


Problem-Based Procedures


Tune and Monitor Solution Process


Parallel Computing in Optimization Toolbox