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

Online Help

All Products    Maple    MapleSim


Units Support in the Optimization Package

 

Description

Examples

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

withOptimization:

Minimizex4000Unityd2,x=10Unitft..2Unitmi

2.073600×106ft2,x=10560.ft

(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.

Units:-UseSystemFPS

Minimizex4000Unityd2,x=10Unitft..2Unitmi

2.073600×106ft2,x=10560.ft

(2)

Units:-UseSystemSI

Minimize1,z=π,x30Unitkm2=0,initialpoint=x=10Unitm,z=10

1.,x=29999.9999185253m,z=3.14159265358979

(3)

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

Minimizex4000Unityd2,x=10Unitft..2Unitmi,useunits=x::Unitm

230400.0000000yd2,x=3218.68800000000m

(4)

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

LSSolvex2Unitm,x0.1Unitmin,x900Unitms

Error, (in Units:-Tools:-OptimizeExpression) units problem, incompatible dimensions in {abs(x-2*Units:-Unit(m))+abs(x-.1*Units:-Unit(min))+abs(x-900*Units:-Unit(ms))}

LSSolvex2Units,x0.1Unitmin,x900Unitms

7.20333333333333137s2,x=2.96666666666667s

(5)

Minimized,ssd,d,sd4Unityd2Unitcm2,d,ssexp1,initialpoint=2Unitmi,1

0.00616102262626188561mi,0.00226651356079383mi,2.71828182845905

(6)

See Also

Optimization

Units

Units/System