Forms of Input for Optimization Package Commands
This help page gives a brief overview of the ways in which optimization problems can be specified in the Optimization package. More information about each form can be found in the Optimization/AlgebraicForm, Optimization/OperatorForm, and Optimization/MatrixForm help pages.
Algebraic form is the most commonly used form for specifying optimization problems. The objective function and constraints are given as algebraic expressions, such as sin⁡x+y or v2+ⅇv.
Algebraic form is accepted by all the Optimization package exports. It is the only form accepted by the Optimization[Interactive] Maplet application.
All computations performed by solvers in the Optimization package use floating-point Vectors and Matrices. Problems specified in algebraic form are converted to Matrix form by the solvers. The computation performed is numeric and floating-point results are returned, even if symbols or exact data are provided.
For a detailed description of algebraic form, see the Optimization/AlgebraicForm help page.
Using operator form, the objective function and the constraints are provided as procedures taking one or more parameters and returning a scalar.
The operator form of input is accepted by the following commands: Optimization[Minimize], Optimization[Maximize], Optimization[NLPSolve], and Optimization[LSSolve]. When this form is used, the Minimize and Maximize commands automatically assume the input is nonlinear and calls the nonlinear programming solvers, even if the input represents linear functions.
Input in operator form is converted to Matrix form by the solver. Specifically, procedures are converted to take Vector parameters.
For a detailed description of operator form, see the Optimization/OperatorForm help page.
Matrix form provides the greatest flexibility in specifying the problem and results in the most efficient performance by the solvers. However, it is also the most complex. Using Matrix form, the objective function and the constraints are specified as Vectors, Matrices, and procedures accepting and returning Vectors.
Matrix form is not supported by the Optimization[Minimize] and Optimization[Maximize] commands or by the Optimization[Interactive] Maplet. It is accepted by the Optimization[LPSolve], Optimization[QPSolve], Optimization[NLPSolve] and Optimization[LSSolve] commands.
Matrix form input is converted to floating-point data if it is not of floating-point type. The Optimization solvers attempt to use hardware floating-point computation when possible and appropriate. To avoid unnecessary copying of Matrices and Vectors, create these objects with the datatype and storage recommended in the help pages of the specific Optimization commands.
For a detailed description of Matrix form, see the Optimization/MatrixForm help page.
Solve a linear programming problem specified using algebraic form. The objective function and the constraints are expressions in x and y.
Solve a linear programming problem specified using Matrix form.
Quadratic programming problems can be specified in algebraic form or in Matrix form.
Nonlinear programs can be specified in algebraic form or in Matrix form.
You should provide the gradient of the objective function if you want to use NLPSolve in Matrix form.
obj := proc(v)
10*v^2 - 2*v*v^2 + v^4 + 1 - 2*v + v^2
objgrad := proc(v, w)
w := 20*v - 2*v^2:
w := -4*v*v + 4*v^3 - 2 + 2*v
Download Help Document