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

Online Help

All Products    Maple    MapleSim


Operator Form of Input for Optimization Package Commands

  

This help page describes the operator form of input for commands in the Optimization package.  For general information on all the input forms accepted by the Optimization package commands, see the Optimization/InputForms help page.

  

The descriptions of the various components below assume that the optimization problem involves minimizing or maximizing a function of variables x1, x2, ..., xn.

 

Objective Function

Constraints

Bounds

Initial Values

Solution

Examples

Objective Function

• 

Specify the objective function as a procedure that accepts n floating-point parameters corresponding to the problem variables and returns a float.

• 

The Optimization[LSSolve] command accepts an objective function of the form  12f1x1,x2,...,xn2+f2x1,x2,...,xn2+...+fqx1,x2,...,xn2.  In this situation, the objective function is specified as a list of procedures, each taking n floating-point parameters representing the problem variables and returning a float.  These procedures compute the least-squares residuals f1, f2, ..., fq.

Constraints

• 

Specify the inequality constraints as a set or list of procedures.  A single constraint vx1,x2,...,xn0 is specified as a procedure v of the same form as the objective function previously described and returning the left-hand side value of the constraint.

• 

Specify the equality constraints also as a set or list of procedures.  Each constraint wx1,x2,...,xn=0 is specified as a procedure returning the left-hand side value of the constraint.

Bounds

• 

Specify bounds as a sequence of ranges.  For example, the sequence −1.0..2.5,0.5..3.2 indicates that the first problem variable is constrained to be between −1.0 and 2.5, and the second is constrained to be between 0.5 and 3.2.  If bounds are provided, the number of ranges must be equal to the number of problem variables.

• 

Bounds can be included with the general constraints. For example, adding the inequalities 1.5x and x3.2 to the constraint set is equivalent to specifying x=1.5..3.2. Bounds are not required to be specified separately, though this usually leads to more efficient computation.

• 

The problem variables are not assumed to be non-negative by default, but the assume=nonnegative option can be used to specify this. For more information, see the Optimization/Options help page.

Initial Values

• 

Specify the initial values using the option initialpoint=p, where p is a list of realcons.  The list must contain one value for each problem variable.  For more information on the initialpoint option, see the Optimization/Options help page.

Solution

• 

Maple returns the solution as a list containing the final minimum (or maximum) value and a point (the computed extremum).  The point is a Vector containing the values of the problem variables unless the problem involves units in which case the point will be a list (see Optimization/General/Units).

Examples

withOptimization

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

(1)

Use simple procedures as input to the NLPSolve command.

p := proc(x)
  if x <= 0 then
    x^2+1;
  else
    sin(x)/x;
  end if;
end proc;

pprocxifx<=0thenx&Hat;2&plus;1elsesinx&sol;xend ifend proc

(2)

NLPSolvep&comma;5..30

−0.0424796169776126&comma;23.5194525091898

(3)

Use operator form to solve a least-squares problem.

b1 := proc(x) x-1 end proc:

b2 := proc(x) x-7 end proc:

c1 := proc(x) -2*x-3 end proc:

c2 := proc(x) x-5 end proc:

LSSolveb1&comma;b2&comma;c1&comma;c2&comma;1..10

9.00000000000000178&comma;4.

(4)

Use operator form as input to the Maximize command.

Maximizex&comma;y3x2+y&comma;x&comma;yx2y2&comma;x&comma;yy2x3&comma;initialpoint=5&comma;5

241.024997396375710&comma;8.898979485566363.44948974278318

(5)

See Also

Optimization

Optimization/InputForms

Optimization/Options

Optimization[LSSolve]