Revision 1953

trunk/contrib/tpl2cpp_output/tpl2cpp_output.cpp (revision 1953)
1
// $Id$
2
/*
3
 *
4
 * Author: Hans J. Skaug
5
 * Copyright (c) 2009-2012 ADMB foundation
6
 */
7

  
8
/**
9
  \file tpl2cpp_output.cpp
10
  \ingroup prepros
11
  \brief Typical output from the preprosessor "tpl2cpp".
12
  This file is generated by the command
13

  
14
    tpl2cpp tpl2cpp_output
15

  
16
  in a case case there the model is contained in "tpl2cpp_output.tpl".
17
  Hence the contents of tpl2cpp_output.cpp is model specific,
18
  and only generic aspects are documented.
19
 */
20

  
21

  
22
/**
23
 * Allocates variables defined in the DATA_SECTION of the tpl-file.
24
 * \param argc number of command line arguments (in a standard C sense)
25
 * \param argv string of command line arguments (in a standard C sense)
26
 *
27
 * Called from the constructor of "model_parameters".
28
 */
29
model_data::model_data(int argc,char * argv[]) : ad_comm(argc,argv)
30
{
31
  n.allocate("n");
32
  Y.allocate(1,10,1,10,"Y");
33
  y2 = 10.0;
34
}
35

  
36
/**
37
Performes initilizations declared in the INITIALIZATION_SECTION of the tpl-file.
38
*/
39
void model_parameters::initializationfunction(void)
40
{
41
  gamma.set_initial_value(1.0);
42
}
43

  
44
/**
45
Allocate and initialize model parameters defined in the PARAMETER_SECTION of the
46
tpl-file.
47
\param argc number of command line arguments (in a standard C sense)
48
\param argv string of command line arguments (in a standard C sense)
49
*/
50
model_parameters::model_parameters(int sz,int argc,char * argv[]) :
51
 model_data(argc,argv) , function_minimizer(sz)
52
{
53
  initializationfunction();
54
  alpha.allocate(1,3,1,"alpha");
55
  beta.allocate(1,3,-10000.0,10000.0,2,"beta");
56
  gamma.allocate(-6.0,6.0,"gamma");
57
  x1.allocate("x1");
58
  #ifndef NO_AD_INITIALIZE
59
  x1.initialize();
60
  #endif
61
  x2.allocate("x2");
62
  x3.allocate(1,4,"x3");
63
  l.allocate("l");
64
  prior_function_value.allocate("prior_function_value");
65
  likelihood_function_value.allocate("likelihood_function_value");
66
}
67

  
68
/**
69
Performes calculations defined in the PRELIMINARY_CALCS_SECTION of the tpl-file.
70
*/
71
void model_parameters::preliminary_calculations(void)
72
{
73
  admaster_slave_variable_interface(*this);
74
  Y = 10.0;
75
  penalty = 1.0;
76
}
77

  
78
/**
79
Performes calculations defined in the BETWEEN_PHASES_SECTION of the tpl-file.
80
*/
81
void model_parameters::between_phases_calculations(void)
82
{
83
  switch (current_phase())
84
  {
85
    case 1:
86
      penalty = 0.001;
87
    break;
88
    case 2:
89
      penalty = 0.001;
90
    break;
91
  }
92
}
93

  
94
/**
95
Performes calculations defined in the PROCEDURE_SECTION of the tpl-file.
96
The initialization "l=0.0" of the objective function is autogenerated by
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff