Efficient Computation in the Optimization Package
This help page provides computation details for the solvers used in the Optimization package. It includes suggestions to help you achieve the most efficient performance.
Specifying the Optimization Problem
The Floating-Point Environment
Working with the evalhf Command
The Optimization package commands recognize optimization problems specified in three forms: algebraic form, operator form, and Matrix form. The Optimization/InputForms help page provides a summary of all three forms and links to more information.
While the algebraic and operator forms are easier to use, the Matrix form is most similar to the internal representation used by the solvers. Problems entered in algebraic and operator form are automatically converted to Vectors and Matrices. When Matrix form is used, Vectors and Matrices that do not have appropriate datatype and storage formats are converted to formats with the required properties. To avoid unnecessary conversions, it is recommended that all Vectors and Matrices be constructed with datatype=float. Some commands impose additional requirements on the input data and these requirements are described on the associated help pages.
The Optimization package solvers rely on a built-in library of optimization routines provided by the Numerical Algorithms Group (NAG). This library performs its computation in floating-point.
The solvers used by the Optimization package will choose either the hardware floating-point environment or the arbitrary-precision software floating-point environment to perform the computations. To maximize efficiency, the solvers attempt to use hardware floats whenever possible. Software floats are used only when the environment variable UseHardwareFloats is set to 'false', or when UseHardwareFloats is 'deduced' and Digits is greater than the value of evalhf⁡Digits.
Nonlinear objective functions and constraints require additional care to ensure that the hardware floating-point environment can be used. (See the previous section, The Floating-Point Environment.) These functions are stored internally as procedures in a format similar to that described in the Optimization/MatrixForm help page. The procedures accept Vector parameters as input and return computed results using Vector or Matrix output parameters. When nonlinear objective functions and constraints are provided in algebraic or operator form, they are converted to the internal form.
By default, Maple evaluates the procedure calls using the evalhf command. Procedures that contain any Maple constructs not supported by evalhf are evaluated using the slower evalf command. For more information on evalhf construct support, see the evalhf and evalhf/procedure help pages. To see messages indicating whether evalhf or evalf is being used, set infolevel[Optimization] to 2 or higher.
Operator form procedures are not evaluated by evalhf. It is recommended that you do not use operator form input unless ease-of-use is more important than efficiency.
Most of the internal solvers for nonlinear problems work more efficiently when derivatives of the objective function and the constraints are available. In some cases, a lack of derivative information can cause the solver to not find a solution. See Optimization/Methods for more information about the methods used by the solvers and the derivative information that is required.
When the problem is provided in algebraic or operator form, the solvers attempt to automatically compute gradients and Jacobian matrices, using diff for problems in algebraic form or codegen[GRADIENT] and codegen[JACOBIAN] for problems in operator form.
When the problem is provided in Matrix form, it is not possible for Maple to automatically determine derivative information. It is highly recommended that users provide this information using the available options. (For more information on options, see the Optimization/Options help page.) Using algebraic form with automatically computed derivatives often achieves better performance than Matrix form without derivative information. However, Matrix form input with derivative information is always the most efficient approach.
Download Help Document