ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
model6.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 
9 #ifdef ISZERO
10  #undef ISZERO
11 #endif
12 #define ISZERO(d) ((d)==0.0)
13 
18  param_init_matrix(), minb(0), maxb(0)
19 {
20 }
21 
23  const int& ii, const dvariable& pen)
24  {
25  if (allocated(*this))
26  {
27  if (ISZERO(scalefactor))
28  ::set_value(*this,x,ii,minb,maxb,pen);
29  else
30  ::set_value(*this,x,ii,minb,maxb,pen,scalefactor);
31  }
32  }
33 
34 
36  {
37  if (allocated(*this))
38  {
39  if (ISZERO(scalefactor))
40  ::set_value_inv(*this,x,ii,minb,maxb);
41  else
43  }
44  }
45 
46  void param_init_bounded_matrix::allocate(int rmin,int rmax,
47  int cmin,int cmax,
48  double _minb,double _maxb,int _phase_start,const char * s)
49  {
50  minb=_minb;
51  maxb=_maxb;
52  dvar_matrix::allocate(rmin,rmax,cmin,cmax);
54  if (allocated(*this))
55  {
56  initial_params::allocate(_phase_start);
57  for (int i=indexmin();i<=indexmax();i++)
58  {
59  if (allocated((*this)(i)))
60  {
62  {
63  *(ad_comm::global_bparfile) >> (*this)(i);
64  }
65  else if (ad_comm::global_parfile)
66  {
67  *(ad_comm::global_parfile) >> (*this)(i);
68  }
69  else
70  {
72  || initial_value >= maxb)
73  {
74  //cerr << "Initial value out of bounds -- using halfway value\n.";
75  initial_value=(minb+maxb)/2.;
76  }
77  (*this)(i)=(initial_value);
78  }
79  }
80  }
81  }
82  else
83  {
85  }
86  }
87 
88  void param_init_bounded_matrix::allocate(int rmin,int rmax,
89  int cmin,int cmax,double _minb,double _maxb,const char * s)
90  {
91  minb=_minb;
92  maxb=_maxb;
93  dvar_matrix::allocate(rmin,rmax,cmin,cmax);
95  if (allocated(*this))
96  {
98  for (int i=indexmin();i<=indexmax();i++)
99  {
100  if (allocated((*this)(i)))
101  {
103  {
104  *(ad_comm::global_bparfile) >> (*this)(i);
105  }
106  else if (ad_comm::global_parfile)
107  {
108  *(ad_comm::global_parfile) >> (*this)(i);
109  }
110  else
111  {
113  || initial_value >= maxb)
114  {
115  //cerr << "Initial value out of bounds -- using halfway value\n.";
116  initial_value=(minb+maxb)/2.;
117  }
118  (*this)(i)=(initial_value);
119  }
120  }
121  }
122  }
123  else
124  {
126  }
127  }
128 
130  const ad_integer& rmax, const index_type& cmin,
131  const index_type& cmax, double _minb,double _maxb,
132  int _phase_start,const char * s)
133  {
134  minb=_minb;
135  maxb=_maxb;
136  dvar_matrix::allocate(rmin,rmax,cmin,cmax);
138  if (allocated(*this))
139  {
140  initial_params::allocate(_phase_start);
141  for (int i=indexmin();i<=indexmax();i++)
142  {
143  if (allocated((*this)(i)))
144  {
146  {
147  *(ad_comm::global_bparfile) >> (*this)(i);
148  }
149  else if (ad_comm::global_parfile)
150  {
151  *(ad_comm::global_parfile) >> (*this)(i);
152  }
153  else
154  {
156  || initial_value >= maxb)
157  {
158  //cerr << "Initial value out of bounds -- using halfway value\n.";
159  initial_value=(minb+maxb)/2.;
160  }
161  (*this)(i)=(initial_value);
162  }
163  }
164  }
165  }
166  else
167  {
169  }
170  }
171 
172 
174  const ad_integer& rmax, const index_type& cmin,
175  const index_type& cmax, double _minb, double _maxb,
176  const char* s)
177  {
178  minb=_minb;
179  maxb=_maxb;
180  dvar_matrix::allocate(rmin,rmax,cmin,cmax);
182  if (allocated(*this))
183  {
185  for (int i=indexmin();i<=indexmax();i++)
186  {
187  if (allocated((*this)(i)))
188  {
190  {
191  *(ad_comm::global_bparfile) >> (*this)(i);
192  }
193  else if (ad_comm::global_parfile)
194  {
195  *(ad_comm::global_parfile) >> (*this)(i);
196  }
197  else
198  {
200  || initial_value >= maxb)
201  {
202  //cerr << "Initial value out of bounds -- using halfway value\n.";
203  initial_value=(minb+maxb)/2.;
204  }
205  (*this)(i)=(initial_value);
206  }
207  }
208  }
209  }
210  else
211  {
213  }
214  }
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
#define x
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_a59.cpp:13
Vector of double precision numbers.
Definition: dvector.h:50
#define ISZERO(d)
Definition: model6.cpp:12
static uistream * global_bparfile
Definition: fvar.hpp:8859
double scalefactor
Definition: admodel.h:824
ADMB variable vector.
Definition: fvar.hpp:2172
void allocate(const char *s)
Definition: model.cpp:112
virtual void set_value(const dvar_vector &x, const int &ii, const dvariable &pen)
Definition: model6.cpp:22
void allocate(void)
Does not allocate, but initializes members.
Definition: fvar_mat.cpp:479
Description not yet available.
void set_value(const dvar_matrix &x, const dvar_vector &v, const int &_ii, double s)
Description not yet available.
Definition: set.cpp:235
Description not yet available.
Definition: admodel.h:1316
void set_value_inv(const dvar_matrix &x, const dvector &v, const int &ii, double s)
Description not yet available.
Definition: setin.cpp:412
void allocate(int _phase_start)
Definition: model.cpp:117
int indexmax(void) const
Definition: fvar.hpp:2572
double initial_value
Definition: admodel.h:823
int initial_value_flag
Definition: admodel.h:822
Stores integer.
Definition: fvar.hpp:7654
param_init_bounded_matrix(void)
Default constructor.
Definition: model6.cpp:17
static cifstream * global_parfile
Definition: fvar.hpp:8857
virtual void set_value_inv(const dvector &x, const int &ii)
Definition: model6.cpp:35
int indexmin(void) const
Definition: fvar.hpp:2568
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518