Overview - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


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

Operator Form

Matrix Form

Examples

Algebraic Form

• 

Algebraic form is the most commonly used form for specifying optimization problems.  The objective function and constraints are given as algebraic expressions, such as sinx+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.

Operator Form

• 

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

• 

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.

Examples

withOptimization:

Solve a linear programming problem specified using algebraic form. The objective function and the constraints are expressions in x and y.

LPSolve4x5y,0x,0y,x+2y6,5x+4y20

−19.,x=2.66666666666667,y=1.66666666666667

(1)

Solve a linear programming problem specified using Matrix form.

LPSolve4,5,3|1,5|1,12,2,0,,maximize

6.06250000000000,0.1875000000000001.06250000000000

(2)

Quadratic programming problems can be specified in algebraic form or in Matrix form.

QPSolve2x+5y+3x2+3xy+2y2,2xy

−3.53333333333333,x=0.466666666666667,y=−1.60000000000000

(3)

QPSolve2,5,6|3,3|4,1|1,2,assume=nonnegative

16.,2.0.

(4)

Nonlinear programs can be specified in algebraic form or in Matrix form.

NLPSolvesinx311+x4,initialpoint=x=2

−0.0107674612530566632,x=3.07244485023085

(5)

You should provide the gradient of the objective function if you want to use NLPSolve in Matrix form.

obj := proc(v)
         10*v[1]^2 - 2*v[1]*v[2]^2 + v[2]^4 + 1 - 2*v[2] + v[2]^2
       end proc:

objgrad := proc(v, w)
        w[1] := 20*v[1] - 2*v[2]^2:
        w[2] := -4*v[1]*v[2] + 4*v[2]^3 - 2 + 2*v[2]
end proc:

NLPSolve2,obj,objectivegradient=objgrad

0.276597509679878506,0.03645601208177330.603788442821000

(6)

See Also

Optimization

Optimization/AlgebraicForm

Optimization/MatrixForm

Optimization/OperatorForm

Optimization[Interactive]

Optimization[LPSolve]

Optimization[LSSolve]

Optimization[Maximize]

Optimization[Minimize]

Optimization[NLPSolve]

Optimization[QPSolve]