Units Support in the Optimization Package - Maple Programming Help

Home : Support : Online Help : Mathematics : Optimization : Optimization Package : General information : Optimization/General/Units

Units Support in the Optimization Package

Description

 • The Optimization package supports Units in expressions, operators, boundaries, and initial points. It does not support units in Matrix inputs.
 • The following commands support units and accept the useunits option.
 – Minimize
 – Maximize
 – LPSolve
 – QPSolve
 – NLPSolve
 – LSSolve
 • In all cases, a dimensional analysis of the optimization problem is done and a unit-free version of the problem is created and passed back to the original Optimization command. Units are then added back to the output when it is returned to the user.
 • Output of these commands will be in the same form as calls made without units except for the Operator forms which will return the solution point as a list instead of a Vector.
 • The units in the solution point variables are determined by (in order of precedence) the units specified in the useunits option, the units in the initialpoint option, the units in boundary ranges, or the default from the current unit system for the dimension of the variable determined by Units:-TestDimension.
 • The unit used for the optimal value of the objective function will be the default for its dimension giving the current unit system.
 • The useunits option forces dimensional analysis of the input even if no units are detected. This can be helpful if the input is a procedure that returns units but the variables are dimensionless, or no initial points or boundary ranges are given in the input.
 • The useunits option can also be set to a list or set to indicate the units for each of the variables.  If the objective function is an operator, useunits may be a list of units.  If the objective function is an expression, useunits may be a list or set of :: values of the form variable::unit.
 • Units are not completely supported for the solutionmodule output form in Optimization. A module will be generated, but it will not have units in its outputs.  A warning will be issued in that case informing the user of what units are being used inside the module.
 • Details of the conversion to a unit-free problem can be seen by setting infolevel[HasUnits] to a value from 2 to 4.

Examples

 > $\mathrm{with}\left(\mathrm{Optimization}\right):$
 > $\mathrm{Minimize}\left({\left(x-4000⟦\mathrm{yd}⟧\right)}^{2},x=10⟦\mathrm{ft}⟧..2⟦\mathrm{mi}⟧\right)$
 $\left[{230399.9999999}{}⟦{{\mathrm{yd}}}^{{2}}⟧{,}\left[{x}{=}{10560.}{}⟦{\mathrm{ft}}⟧\right]\right]$ (1)

The units of the objective function are usually in the default unit for that dimension in the current Units system. To get feet instead of meters change the system. This will not effect the units of variables which are given explicitly.

 > $\mathrm{Units}:-\mathrm{UseSystem}\left('\mathrm{FPS}'\right)$
 > $\mathrm{Minimize}\left({\left(x-4000⟦\mathrm{yd}⟧\right)}^{2},x=10⟦\mathrm{ft}⟧..2⟦\mathrm{mi}⟧\right)$
 $\left[{230399.9999999}{}⟦{{\mathrm{yd}}}^{{2}}⟧{,}\left[{x}{=}{10560.}{}⟦{\mathrm{ft}}⟧\right]\right]$ (2)
 > $\mathrm{Units}:-\mathrm{UseSystem}\left('\mathrm{SI}'\right)$
 > $\mathrm{Minimize}\left(1,\left\{{\left(x-30⟦\mathrm{km}⟧\right)}^{2}=0,z=\mathrm{Pi}\right\},\mathrm{initialpoint}=\left\{x=10⟦m⟧,z=10\right\}\right)$
 $\left[{1.}{,}\left[{x}{=}{29999.9165699122}{}⟦{m}⟧{,}{z}{=}{3.14159265358979}\right]\right]$ (3)

The automatically detected units for the variables can be overridden by the useunits option.

 > $\mathrm{Minimize}\left({\left(x-4000⟦\mathrm{yd}⟧\right)}^{2},x=10⟦\mathrm{ft}⟧..2⟦\mathrm{mi}⟧,\mathrm{useunits}=\left[x::\left(⟦m⟧\right)\right]\right)$
 $\left[{230400.0000000}{}⟦{{\mathrm{yd}}}^{{2}}⟧{,}\left[{x}{=}{3218.68800000000}{}⟦{m}⟧\right]\right]$ (4)

The units handler will issue errors when incompatible dimensions are found.

 > $\mathrm{LSSolve}\left(\left[x-2⟦m⟧,x-0.1⟦\mathrm{min}⟧,x-900⟦\mathrm{ms}⟧\right]\right)$
 > $\mathrm{LSSolve}\left(\left[x-2⟦s⟧,x-0.1⟦\mathrm{min}⟧,x-900⟦\mathrm{ms}⟧\right]\right)$
 $\left[{7.20333333333333137}{}⟦{s}⟧{,}\left[{x}{=}{2.96666666666667}{}⟦{s}⟧\right]\right]$ (5)
 > $\mathrm{Minimize}\left(\left(d,s\right)→ds,\left[\left(d,s\right)→{\left(d-4⟦\mathrm{yd}⟧\right)}^{2}-⟦{\mathrm{cm}}^{2}⟧\right],\left[\left(d,s\right)→s-ⅇ\right],\mathrm{initialpoint}=\left[2⟦\mathrm{mi}⟧,1\right]\right)$
 $\left[{0.00616102262626188561}{}⟦{\mathrm{mi}}⟧{,}\left[{0.00226651356079383}{}⟦{\mathrm{mi}}⟧{,}{2.71828182845905}\right]\right]$ (6)