Solve optimization problem
sol = solve(prob)
sol = solve(prob,solver)
sol = solve(___,options)
[sol,fval] = solve(___)
[sol,fval,exitflag,output,lambda] = solve(___)
Internally, the solve
function
solves optimization problems by calling linprog
or intlinprog
. Before solve
can
call these functions, either it or some other associated functions or objects must convert
the problems to solver form. 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 internally 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 matrix form. For an example, see Convert Problem to Structure.
If the problem has any integer variables, then by
default solve
calls intlinprog
. Otherwise, by default
solve
calls linprog
. You can override this default
choice by using the solver
input
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.