Next: Improving the efficiency of Up: Equations, Gradient and Hessian Previous: Equations, Gradient and Hessian   Contents

## MakeF, MakeJ, MakeH

This set of procedures enable one to generate automatically C++ code for later use with the ALIAS-C++ library:

• MakeF: generates the procedure for evaluating a set of equations. These equations may be composed of most classical mathematical functions (see section 3.1.1 for a list of allowed operators) but may also include unexpanded determinants (see section 2.1.3).
• MakeJ: generates the procedure for evaluating the gradient of a set of equations
• MakeH: generates the procedure for evaluating the Hessian of a set of equations
The syntax for these procedures is:
```Make[FJH]("[C++ file name]","[procedure name]",[list of equations],[list of unknowns]);
```
Thus:
```with(ALIAS):
expr := [x^2+y^2-1,x+y]:
MakeF("Test.C","Test",expr,[x,y]);
```
enable to create the following C++ program Test.C
```/* Code automatically written by Maple */
INTERVAL_VECTOR Test(int l1, int l2, INTERVAL_VECTOR & v_IS) {
INTERVAL_VECTOR V(2);
if (l1<=1 && 1<=l2)
V(1)=Sqr(v_IS(1))+Sqr(v_IS(2))-1;
if (l1<=2 && 2<=l2)
V(2)=v_IS(1)+v_IS(2);
return V;
}
```

Note that the program generated by MakeF has a specific form that allows to interval evaluate all expressions or a specific set of expressions: such format will be called the MakeF format. There are also a MakeJ and MakeH format. The procedures Make[FJH] makes an extensive use of the procedure MinimalCout that try to find the optimal formulation of an expression with respect to interval arithmetic. Indeed not all mathematically equivalent formulation of an expression are interval equivalent (i.e. they produce the same interval evaluation). For example and are equivalent but the second formulation always produces the optimal interval evaluation as there is only one occurrence of . For further detail on MinimalCout see section 9.7. Note that the variable `ALIAS/mincout` plays an important role in the calculation time of these procedures.

Note that not all expression can be interval evaluated (e.g. 1/x cannot be evaluated if the interval for x includes 0). ALIAS provide an automatic way to avoid evaluation problems (see section 2.1.5). If you use your own procedure and are aware of evaluation problems and modify the returned values it will be a good policy to set C++ flags ALIAS_ChangeF, ALIAS_ChangeJ to 1 (default value 0) if a change occurs: this will allow the ALIAS C++ library to avoid using improperly the returned value (e.g in the interval Newton scheme).

There are two "optimized" versions of MakeF and MakeJ called MakeFO and MakeJO that may produce a better code from the view point of interval evaluation but with a larger computation time. Note that the Code procedure may be used to produce simple C++ equivalent of a formula. Note also that inequalities are also recognized by these procedures.

In most of the ALIAS-Maple procedures it may be possible for the user to provide its own procedure for the evaluation of the expressions and of their derivatives. This is obtained by setting the flag `ALIAS/user_func` to a string that is the name of the C++ file that defines a procedure which will be used for evaluating the expressions (the name of the procedure must be F. Similarly the flag `ALIAS/user_derivative` may be used for the derivative of the expressions in which the procedure name must be J.

For the MakeF the end-user may also indicate that he has already written the expressions in a form that is optimal and that MakeF should only translate as it the expression in C++ without any modification by setting the flag `ALIAS/as_itF` to 1.

For the MakeJ procedure the end-user may also indicate that he has already computed the derivatives by setting the flag `ALIAS/as_itJ` to 1 and by defining the variable `ALIAS/as_itJ_array` as an array that contains the derivatives of all the expressions (the i-th row of this array contains the derivatives of the i-th expression with respect to the variables). If you have determinant in the expression you have to set the flag `ALIAS/as_itJ_mat` to 1 to avoid MakeJ trying to find a better evaluation function.

Instead of generating C++ code these procedures may produce a C++ code that will use a parser. A motivation of using the parser is that the compilation time of the program necessary to interval evaluate a complex expression may be very large (note that the procedure Auto_Diff, section 2.3.2, may allow to reduce this compilation time).

Each expression to evaluate will be written in a file and the interval evaluation will be done at run-time by parsing the file. This allow to deal with large expressions at a small cost. This is obtained by setting the variable `ALIAS/use_parser` along the following rules:

• 5: only the Hessian will be calculated using the parser
• 6: only the Jacobian and Hessian will be calculated using the parser
• 7: the expressions, their Jacobian and Hessian will be calculated using the parser
• 10: the expressions, their Jacobian and Hessian will be calculated using the parser
To determine if a procedure offers this possibility check the on-line help and look if the variable `ALIAS/use_parser` is in the list of the global variables for the procedure.

Next: Improving the efficiency of Up: Equations, Gradient and Hessian Previous: Equations, Gradient and Hessian   Contents
Jean-Pierre Merlet 2012-12-20