ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f1b2fnl6.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  */
11 #include <df1b2fnl.h>
12 
18 {
19  //ADUNCONST(df1b2_init_matrix,x)
21  p=&_x;
22  int mmin=p->indexmin();
23  int mmax=p->indexmax();
24 
25  int jmin=(*p)(mmin).indexmin();
26  int ind_index = x(mmin,jmin).get_ind_index();
27  if (ind_index<0)
28  {
30  }
31  else
32  {
33  add_to_list();
34  }
35  //int i,j;
36  int i;
37  ivector lb(mmin,mmax);
38  ivector ub(mmin,mmax);
39  lb(mmin)=(*p)(mmin).indexmin();
40  ub(mmin)=(*p)(mmin).indexmax();
41  int lf=0;
42  int uf=0;
43  for (i=mmin+1;i<=mmax;i++)
44  {
45  lb(i)=(*p)(i).indexmin();
46  ub(i)=(*p)(i).indexmax();
47  if (lb(i) !=lb(i-1))
48  lf=1;
49  if (ub(i) !=ub(i-1))
50  uf=1;
51  }
52  // do we want this DF 01Nov05
53  //df1b2variable::noallocate=1;
54  if (lf ==1)
55  {
56  if (uf==1)
57  {
58  df1b2matrix::allocate(mmin,mmax,lb,ub);
59  }
60  else
61  {
62  df1b2matrix::allocate(mmin,mmax,lb,ub(mmin));
63  }
64  }
65  else
66  {
67  if (uf==1)
68  {
69  df1b2matrix::allocate(mmin,mmax,lb(mmin),ub);
70  }
71  else
72  {
73  df1b2matrix::allocate(mmin,mmax,lb(mmin),ub(mmin));
74  }
75  }
77 }
78 
84 {
85  int mmin=p->indexmin();
86  int mmax=p->indexmax();
87  int n=0;
88  for (int i=mmin;i<=mmax;i++)
89  {
90  n+=(*p)(i).indexmax()-(*p)(i).indexmin()+1;
91  }
92  return n;
93 }
94 
100 {
102  int mmin=vp->indexmin();
103  int mmax=vp->indexmax();
104  int i,j;
105  for (i=mmin;i<=mmax;i++)
106  {
107  int jmin=(*vp)(i).indexmin();
108  int jmax=(*vp)(i).indexmax();
109  for (j=jmin;j<=jmax;j++)
110  {
111  y(ii)= value((*vp)(i,j));
112  ii++;
113  }
114  }
115 }
116 
122 {
124  int mmin=vp->indexmin();
125  int mmax=vp->indexmax();
126  int i,j;
127  for (i=mmin;i<=mmax;i++)
128  {
129  int jmin=(*vp)(i).indexmin();
130  int jmax=(*vp)(i).indexmax();
131  for (j=jmin;j<=jmax;j++)
132  {
133  y(ii,1)= ( *vp)(i,j).get_ind_index();
134  y(ii,2)= ii;
135  ii++;
136  }
137  }
138 }
139 
145  const int& _ii,const df1b2variable& _pen)
146 {
147  ADUNCONST(int,ii)
149  int mmin=p->indexmin();
150  int mmax=p->indexmax();
151  int i,j;
152  for (i=mmin;i<=mmax;i++)
153  {
154  int jmin=(*p)(i).indexmin();
155  int jmax=(*p)(i).indexmax();
156  for (j=jmin;j<=jmax;j++)
157  {
158  (*this)(i,j) = (x(ii++));
159  }
160  }
161 }
162 // *****************************************************************
163 // *****************************************************************
164 // *****************************************************************
165 /*
166 funnel_init_bounded_df1b2vector::funnel_init_bounded_df1b2vector(const df1b2_init_bounded_vector & _x)
167 {
168  ADUNCONST(df1b2_init_bounded_vector,x)
169  //type=0;
170  //pointer=0;
171  p=&_x;
172  int mmin=x.indexmin();
173  int mmax=x.indexmax();
174  int ind_index = x(mmin).get_ind_index();
175  if (ind_index<0)
176  {
177  add_to_inactive_list();
178  }
179  else
180  {
181  add_to_list();
182  }
183  df1b2variable::noallocate=1;
184  df1b2vector::allocate(mmin,mmax);
185  df1b2variable::noallocate=0;
186 }
187 
188 
189 int funnel_init_bounded_df1b2vector::nvar_calc(void)
190 {
191  return p->indexmax()-p->indexmin()+1;
192 }
193 
194 void funnel_init_bounded_df1b2vector::xinit(init_df1b2vector& y,int& ii)
195 {
196  df1b2_init_bounded_vector * vp = (df1b2_init_bounded_vector *) p;
197  int mmin=p->indexmin();
198  int mmax=p->indexmax();
199  int i;
200  for (i=mmin;i<=mmax;i++)
201  {
202  y(ii)= value((*vp)(i));
203  ii++;
204  }
205 }
206 
207 void funnel_init_bounded_df1b2vector::set_index(imatrix& y,int& ii)
208 {
209  int mmin=p->indexmin();
210  int mmax=p->indexmax();
211  int i;
212  for (i=mmin;i<=mmax;i++)
213  {
214  y(ii,1)= ( *(df1b2_init_bounded_vector *)(p) )(i).get_ind_index();
215  y(ii,2)= ii;
216  ii++;
217  }
218 }
219 
220 void funnel_init_bounded_df1b2vector::set_value(const init_df1b2vector& _x,
221  const int& _ii,const df1b2variable& _pen)
222 {
223  ADUNCONST(int,ii)
224  ADUNCONST(init_df1b2vector,x)
225  df1b2_init_bounded_vector * vp = (df1b2_init_bounded_vector *) p;
226  int mmin=p->indexmin();
227  int mmax=p->indexmax();
228  int i;
229  for (i=mmin;i<=mmax;i++)
230  {
231  (*this)(i) = (x(ii++));
232  if (!initial_params::straight_through_flag)
233  {
234  // df1b2variable& tmp = boundp(x(ii++),b.getminb(),b.getmaxb(),pen);
235  // df1b2variable::operator = (tmp);
236  (*this)(i) = (boundp(x(ii++),vp->getminb(),vp->getmaxb()));
237  }
238  else
239  {
240  (*this)(i) = (x(ii));
241  *((*this)(i).get_u()) =
242  boundp(*(x(ii++).get_u()),vp->getminb(),vp->getmaxb());
243  }
244  }
245 }
246 */
virtual void set_value(const init_df1b2vector &, const int &ii, const df1b2variable &)
Description not yet available.
Definition: f1b2fnl6.cpp:144
Description not yet available.
Definition: imatrix.h:69
virtual void xinit(init_df1b2vector &, int &ii)
Description not yet available.
Definition: f1b2fnl6.cpp:99
#define x
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
int indexmin(void) const
Definition: df1b2fun.h:1054
Description not yet available.
Definition: df1b2fun.h:1420
static int noallocate
Definition: df1b2fun.h:294
int nvar_calc(void)
Description not yet available.
Definition: f1b2fnl6.cpp:83
Description not yet available.
Definition: df1b2fun.h:266
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
Description not yet available.
funnel_init_df1b2matrix(const df1b2matrix &x)
Description not yet available.
Definition: f1b2fnl6.cpp:17
void add_to_list(void)
Description not yet available.
Definition: df1b2fnl.cpp:42
const df1b2matrix * p
Definition: df1b2fnl.h:190
virtual void set_index(imatrix &, int &ii)
Description not yet available.
Definition: f1b2fnl6.cpp:121
Description not yet available.
Definition: df1b2fun.h:373
Description not yet available.
Definition: df1b2fun.h:1042
int indexmax(void) const
Definition: df1b2fun.h:1055
void add_to_inactive_list(void)
Description not yet available.
Definition: df1b2fnl.cpp:74
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
void allocate(void)
Description not yet available.
Definition: f1b2vc5.cpp:781