PREVContentsINDEX

Section 22 The TOP_OF_MAIN section

The TOP_OF_MAIN section is intended to allow the programmer to insert any desired C++ code at the top of the main() function in the program. The code is copied literally from the template to the program. This section can be used to set the AUTODIF global variables (see the AUTODIF manual chapter on AUTODIF global variables.) The following code fragment will set these variables.

TOP_OF_MAIN_SECTION
  arrmblsize = 200000; // use instead of 
                   // gradient_structure::set_ARRAY_MEMBLOCK_SIZE
  gradient_structure::set_GRADSTACK_BUFFER_SIZE(100000); // this may be incorrect in 
                                       // the AUTODIF manual.
  gradient_structure::set_CMPDIF_BUFFER_SIZE(50000); 
  gradient_structure::set_MAX_NVAR_OFFSET(500); // can have up to 500 
                                             // independent variables
  gradient_structure::set_MAX_NUM_DEPENDENT_VARIABLES(500); // can have up to 
                                          // 500 dependent variables

Note that within AD Model Builder one doesn't use the function gradient_structure::set_ARRAY_MEMBLOCK_SIZE to set the amount of memory available for variable arrays. Instead use the line of code arrmblsize = nnn; where nnn is the amount of memory desired.

Section 23 The GLOBALS_SECTION

The GLOBALS_SECTION is intended to allow the programmer to insert any desired C++ code before the main() function in the program. The code is copied literally from the template to the program. This enables the programmer to define global objects and to include include header files and user-defined functions into the generated C++ code.

Section 24 the BETWEEN_PHASES_SECTION

Code in the between phases section is executed before each phase of the minimization. It is possible to carry out different actions which depend on which phase of the minimization is to begin by using a swtich statement (you can read about this in a book on C or C++) together with the current_phase() function.

switch (current_phase()
{
case 1:
  // some action
  cout << "Before phase 1 minimization " << endl;
  break;
case 2: i
  // some action
  cout << "Before phase 2 minimization " << endl;
  break;
// ....
}

NEXT