Close
Close window
Matrix Form of Commands - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

The Optimization Package Matrix Form

This worksheet introduces the matrix form of the optimization commands. For an introduction to the algebraic form and more explanation about each example, refer to the Optimization example worksheet .

In this worksheet, we will be minimizing a function (referred to as the objective function) subject to a number of constraints. Certain maximize examples are included as well. In any of the examples, the maximize option can be added to the command to find the maximum instead of the minimum.

Introduction to the Optimization Package form

>

restart

The following command allows you to use the short form of the command names in the Optimization package.

>

withOptimization

ImportMPS,Interactive,LPSolve,LSSolve,Maximize,Minimize,NLPSolve,QPSolve

(1.1)

The commands in the Optimization package allow you to specify the objective function and the constraints in several different ways. This worksheet deals with the matrix form of the objective function and constraints. The other forms are algebraic form and operator form.

Linear Programming Example 1

A linear program can be stated in the form:

minTransposec x

subject to Axb

where c is in Rn, A is in Rmxn, and b is in Rm

For a first example we have a simplex two dimensional linear programming problem of the form described above with:

>

c:=2,1;A4|1,5|1,1|0,0|1;b:=12,2,0,0

The LPSolve command returns the optimal function values, as well as the point at which the optimal value occurs.

>

LPSolvec,A,b

Alternatively, we could use the first two constraints and the nonnegative option.

>

LPSolvec,A1..2,1..2,b1..2,assume=nonnegative

The first element of the solution is the minimum value that the objective function obtains while satisfying the constraints. The second element indicates a point where the minimum is reached. This point is not necessarily unique.

Linear Programming Example 2

We can also include equality constraint as the next example shows,
so our problem becomes:

minTransposec x

subject to Axb

Ex=f

where c is in Rn, A is in Rmxn, and b is in Rm, E is in Rmxn, and f is in Rm

>

c:=2,1,1;A:=4|1|0,5|1|0;b12,2;E:=23|23|1;f203

This example demonstrates the maximize option.

>

LPSolvec,A,b,E,f,assume=nonnegative,maximize

Quadratic Programming Example

A quadratic program can be written in the form:

min 1/2*Transpose(x).H.x+Transpose(x).c

subject to Axb

Ex=f

where
H in is Rnxn, c is in Rn, A is in Rmxn, and b is in Rm, E is in Rmxn, and f is in Rm

>

c:=1|1;H8|0,0|0;A6|1,112|1,1|0;b11,0,4

The QPSolve command returns the optimal function values, as well as the point at which the optimal value occurs.

>

QPSolvec,H,A,b

Nonlinear Programming

We can also use NLPSolve in matrix form where the gradient should be provided.

>

p:=x→100x2x122+1x12;grad:=procx,yy[1]:=−400*x[2]x[1]^2*x[1]2+2*x[1];y[2]:=200*x[2]200*x[1]^2end proc

p:=x→100x2x122+1x12

grad:=procx,yy[1]:=−400*x[2]400*x[1]^2*x[1]2+2*x[1];y[2]:=200*x[2]200*x[1]^2end proc

(5.1)


We can now use the matrix form of NLPSolve

>

NLPSolve2,p,,10,10,10,10,objectivegradient=grad

>

Return to Index for Example Worksheets


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /