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{Unit}\left(\mathrm{yd}\right)\right)}^{2},x=10\mathrm{Unit}\left(\mathrm{ft}\right)..2\mathrm{Unit}\left(\mathrm{mi}\right)\right)$
 $\left[{2.073600}{}{{10}}^{{6}}{}⟦{{\mathrm{ft}}}^{{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{Unit}\left(\mathrm{yd}\right)\right)}^{2},x=10\mathrm{Unit}\left(\mathrm{ft}\right)..2\mathrm{Unit}\left(\mathrm{mi}\right)\right)$
 $\left[{2.073600}{}{{10}}^{{6}}{}⟦{{\mathrm{ft}}}^{{2}}⟧{,}\left[{x}{=}{10560.}{}⟦{\mathrm{ft}}⟧\right]\right]$ (2)
 > $\mathrm{Units}:-\mathrm{UseSystem}\left('\mathrm{SI}'\right)$
 > $\mathrm{Minimize}\left(1,\left\{z=\mathrm{\pi },{\left(x-30\mathrm{Unit}\left(\mathrm{km}\right)\right)}^{2}=0\right\},\mathrm{initialpoint}=\left\{x=10\mathrm{Unit}\left(m\right),z=10\right\}\right)$
 $\left[{1.}{,}\left[{x}{=}{29999.9999185253}{}⟦{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{Unit}\left(\mathrm{yd}\right)\right)}^{2},x=10\mathrm{Unit}\left(\mathrm{ft}\right)..2\mathrm{Unit}\left(\mathrm{mi}\right),\mathrm{useunits}=\left[x::\mathrm{Unit}\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\mathrm{Unit}\left(m\right),x-0.1\mathrm{Unit}\left(\mathrm{min}\right),x-900\mathrm{Unit}\left(\mathrm{ms}\right)\right]\right)$
 > $\mathrm{LSSolve}\left(\left[x-2\mathrm{Unit}\left(s\right),x-0.1\mathrm{Unit}\left(\mathrm{min}\right),x-900\mathrm{Unit}\left(\mathrm{ms}\right)\right]\right)$
 $\left[{7.20333333333333137}{}⟦{{s}}^{{2}}⟧{,}\left[{x}{=}{2.96666666666667}{}⟦{s}⟧\right]\right]$ (5)
 > $\mathrm{Minimize}\left(\left(d,s\right)↦s\cdot d,\left[\left(d,s\right)↦{\left(d-4\cdot \mathrm{Unit}\left(\mathrm{yd}\right)\right)}^{2}-\mathrm{Unit}\left({\mathrm{cm}}^{2}\right)\right],\left[\left(d,s\right)↦s-\mathrm{exp}\left(1\right)\right],\mathrm{initialpoint}=\left[2\mathrm{Unit}\left(\mathrm{mi}\right),1\right]\right)$
 $\left[{0.00616102262626188561}{}⟦{\mathrm{mi}}⟧{,}\left[{0.00226651356079383}{}⟦{\mathrm{mi}}⟧{,}{2.71828182845905}\right]\right]$ (6)