 Operator Form of Input for Optimization Package Commands - Maple Programming Help

Home : Support : Online Help : Mathematics : Optimization : Optimization Package : General information : Input forms : Optimization/General/OperatorForm

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 $\mathrm{x1}$, $\mathrm{x2}$, ..., $\mathrm{xn}$.

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  $\left(\frac{1}{2}\right)\left({\mathrm{f1}\left(\mathrm{x1},\mathrm{x2},\mathrm{...},\mathrm{xn}\right)}^{2}+{\mathrm{f2}\left(\mathrm{x1},\mathrm{x2},\mathrm{...},\mathrm{xn}\right)}^{2}+\mathrm{...}+{\mathrm{fq}\left(\mathrm{x1},\mathrm{x2},\mathrm{...},\mathrm{xn}\right)}^{2}\right)$.  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 $\mathrm{f1}$, $\mathrm{f2}$, ..., $\mathrm{fq}$.

Constraints

 • Specify the inequality constraints as a set or list of procedures.  A single constraint $v\left(\mathrm{x1},\mathrm{x2},\mathrm{...},\mathrm{xn}\right)\le 0$ 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 $w\left(\mathrm{x1},\mathrm{x2},\mathrm{...},\mathrm{xn}\right)=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.5\le x$ and $x\le 3.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 $\mathrm{assume}=\mathrm{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

 > $\mathrm{with}\left(\mathrm{Optimization}\right)$
 $\left[{\mathrm{ImportMPS}}{,}{\mathrm{Interactive}}{,}{\mathrm{LPSolve}}{,}{\mathrm{LSSolve}}{,}{\mathrm{Maximize}}{,}{\mathrm{Minimize}}{,}{\mathrm{NLPSolve}}{,}{\mathrm{QPSolve}}\right]$ (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;
 ${p}{:=}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{<=}{0}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{^}{2}{+}{1}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{else}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{sin}}{}\left({x}\right){/}{x}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2)
 > $\mathrm{NLPSolve}\left(p,-5..30\right)$
 $\left[{-0.0424796169776126}{,}\left[\begin{array}{c}{23.5194525091898}\end{array}\right]\right]$ (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:
 > $\mathrm{LSSolve}\left(\left[\mathrm{b1},\mathrm{b2}\right],\left\{\mathrm{c1},\mathrm{c2}\right\},1..10\right)$
 $\left[{9.00000000000000178}{,}\left[\begin{array}{c}{4.}\end{array}\right]\right]$ (4)

Use operator form as input to the Maximize command.

 > $\mathrm{Maximize}\left(\left(x,y\right)↦3\cdot {x}^{2}+y,\left\{\left(x,y\right)↦x-2\cdot y-2,\left(x,y\right)↦{y}^{2}-x-3\right\},\mathrm{initialpoint}=\left[5,5\right]\right)$
 $\left[{241.024997396375710}{,}\left[\begin{array}{c}{8.89897948556636}\\ {3.44948974278318}\end{array}\right]\right]$ (5)