ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
model46.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
7 #include <admodel.h>
8 
15  const double_index_type& initial_value)
16 {
17  it = new double_index_type(initial_value);
18 }
21  v(NULL),
22  index_min(0),
23  index_max(-1),
24  it(NULL)
25 {
26 }
27 
29  int min1,
30  int max1,
31  const index_type& min,
32  const index_type& max,
33  const index_type& min2,
34  const index_type& max2,
35  const double_index_type& dmin,
36  const double_index_type& dmax,
37  const char* s)
38 {
39  allocate(min1,max1,min,max,min2,max2,dmin,dmax,1,s);
40 }
41 
43  int min,
44  int max,
45  const index_type& nrl,
46  const index_type& nrh,
47  const index_type& ncl,
48  const index_type& nch,
49  const double_index_type& bounds_minimum,
50  const double_index_type& bounds_maximum,
51  const index_type& phase_start,
52  const char* s)
53 {
54  if (max >= min)
55  {
56  unsigned int size = static_cast<unsigned int>(max - min + 1);
57  v = new param_init_bounded_matrix[size];
58  if (!v)
59  {
60  cerr << "Error trying to allocate memory in"
61  << " param_init_bounded_matrix_vector::allocate.\n";
62  ad_exit(1);
63  }
64  index_min = min;
65  index_max = max;
66  v -= indexmin();
67  for (int i = indexmin(); i <= indexmax(); ++i)
68  {
69  if (it) v[i].set_initial_value(ad_double((*it)[i]));
70  adstring id = s + adstring("[") + str(i) + adstring("]");
71  v[i].allocate(
72  nrl[i], nrh[i],
73  ncl[i], nch[i],
74  bounds_minimum[i], bounds_maximum[i],
75  phase_start[i],
76  (char*)id);
77  }
78  }
79 }
85  const ad_integer& imin, const ad_integer& imax,
86  const ad_integer& imin2, const ad_integer& imax2,
87  const ad_double& _bmin, const ad_double& _bmax,
88  const ad_integer& _phase_start, const char* s)
89 {
90  minb = _bmin;
91  maxb = _bmax;
92  named_dvar_matrix::allocate(imin,imax,imin2,imax2,s);
93  if (!(!(*this)))
94  {
95  initial_params::allocate(_phase_start);
97  {
99  }
100  else if (ad_comm::global_parfile)
101  {
103  }
104  else
105  {
106  if ((!initial_value_flag)
107  || initial_value <=minb || initial_value >= maxb)
108  {
109  //cerr << "Initial value out of bounds -- using halfway value" << endl;
110  initial_value=(minb+maxb)/2.;
111  }
113  }
114  }
115  else
116  {
118  }
119 }
122 {
123  deallocate();
124 }
127 {
128  if (it)
129  {
130  delete it;
131  it = NULL;
132  }
133  if (v)
134  {
135  v += indexmin();
136  delete [] v;
137  v = NULL;
138  }
139 }
param_init_bounded_matrix_vector()
Default constructor.
Definition: model46.cpp:20
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
void deallocate()
Frees member allocated memory.
Definition: model46.cpp:126
int imax2(int a, double v)
Definition: dtweedie.cpp:5
param_init_bounded_matrix * v
Definition: admodel.h:2815
static uistream * global_bparfile
Definition: fvar.hpp:8859
Stores double value.
Definition: fvar.hpp:8499
Description not yet available.
Definition: admodel.h:1409
exitptr ad_exit
Definition: gradstrc.cpp:53
void set_initial_value(double x)
Definition: model.cpp:90
#define dmin(a, b)
Definition: cbivnorm.cpp:190
#define dmax(a, b)
Definition: cbivnorm.cpp:191
void allocate(int min1, int max1, const index_type &min, const index_type &max, const index_type &min2, const index_type &max2, const double_index_type &dmin2, const double_index_type &dmax2, const index_type &phase_start, const char *s)
Definition: model46.cpp:42
#define min(a, b)
Definition: cbivnorm.cpp:188
void allocate(void)
Does not allocate, but initializes members.
Definition: fvar_mat.cpp:479
Description not yet available.
adstring str(double x, int minwidth=17, int decplaces=-1)
Convert x to adstring with minimum width and total number of decimal places.
Definition: str.cpp:25
void allocate(int _phase_start)
Definition: model.cpp:117
dvar_matrix()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_mat.cpp:15
double_index_type * it
Definition: admodel.h:2818
dvar_matrix & operator=(const dvar_matrix &)
Assigns other values to dvar_matrix.
Definition: fvar_mat.cpp:515
double initial_value
Definition: admodel.h:823
void allocate(const ad_integer &imin, const ad_integer &imax, const ad_integer &imin2, const ad_integer &imax2, const ad_double &_bmin, const ad_double &_bmax, const ad_integer &phase_start, const char *s)
Allocates matrix with row dimensions imin to imax, column dimensions imin2 to imax2 and bounded by bm...
Definition: model46.cpp:84
~param_init_bounded_matrix_vector()
Destructor.
Definition: model46.cpp:121
int initial_value_flag
Definition: admodel.h:822
void set_initial_value(const double_index_type &initial_value)
Sets initial value of param_init_bounded_matrix_vector.
Definition: model46.cpp:14
Stores integer.
Definition: fvar.hpp:7654
static cifstream * global_parfile
Definition: fvar.hpp:8857
#define max(a, b)
Definition: cbivnorm.cpp:189
int imin2(int a, int b)
Definition: dtweedie.cpp:10
Description not yet available.
Definition: fvar.hpp:8564