ADMB Documentation  11.1.1920
 All Classes Files Functions Variables Typedefs Friends Defines
df1b2fnl.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: df1b2fnl.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <df1b2fnl.h>
00012 
00013 #define USE_BARD_PEN
00014 class newadkludge;
00015 newadkludge * newadkl=0;
00016 
00017 
00018 typedef funnel_init_var  * PFUNNEL_INIT_VAR;
00019 
00020 class laplace_approximation_calculator;
00021 laplace_approximation_calculator * funnel_init_var::lapprox=0;
00022 df1b2variable * funnel_init_var::funnel_constraints_penalty=0;
00023 int funnel_init_var::num_vars=0;
00024 //int funnel_init_var::num_all_vars=0;
00025 int funnel_init_var::num_inactive_vars=0;
00026 int funnel_init_var::num_active_parameters=0;
00027 //funnel_init_var ** funnel_init_var::all_list=new PFUNNEL_INIT_VAR[2000];
00028 funnel_init_var ** funnel_init_var::list=new PFUNNEL_INIT_VAR[2000];
00029 funnel_init_var ** funnel_init_var::inactive_list=new PFUNNEL_INIT_VAR[2000];
00030 init_df1b2vector * funnel_init_var::py=0;
00031 imatrix * funnel_init_var::plist=0;
00032 
00033   int funnel_check_flag=0;
00034 
00035 void  xxx(init_df1b2vector & tmp,int x){;}
00036 
00041 void funnel_init_var::add_to_list(void)
00042 {
00043   index=num_vars;
00044   list[num_vars++]=this;
00045   //all_list[num_all_vars++]=this;
00046 }
00047 
00052 void funnel_init_var::delete_from_list(void)
00053 {
00054   if (index!=num_vars-1)
00055   {
00056     cerr << "can only delete last member" << endl;
00057     ad_exit(1);
00058   }
00059   num_vars--;
00060   index=-1;
00061 }
00062 
00067 void funnel_init_var::add_to_inactive_list(void)
00068 {
00069   index=-1;
00070   inactive_list[num_inactive_vars++]=this;
00071 }
00072 
00077 void funnel_init_var::allocate(void)
00078 {
00079   //cout << "In allocate" << endl;
00080 }
00081 
00086 void check_pool_depths(void)
00087 {
00088   for (int i=0;i<df1b2variable::adpool_counter;i++)
00089   {
00090     cout << " Pool depth " << i << "  "
00091          << df1b2variable::adpool_vector[i]->depth_check()
00092          << "  " << df1b2variable::adpool_vector[i]  << endl;
00093   }
00094 }
00095 
00100 void funnel_init_var::allocate_all(void)
00101 {
00102   re_objective_function_value::pobjfun->deallocate();
00103   if (lapprox)
00104   {
00105     if (lapprox->calling_set)
00106     {
00107       (*lapprox->calling_set)(0,0)++;
00108     }
00109   }
00110   num_active_parameters=funnel_init_var::nvarcalc_all();
00111   if (py)
00112   {
00113     if (py->indexmax() != num_active_parameters)
00114     {
00115       delete py;
00116       py=0;
00117     }
00118   }
00119   f1b2gradlist->reset();
00120 
00121   adpool * tmppool=df1b2variable::pool;
00122   if (tmppool)
00123   {
00124     //cout << tmppool << endl;
00125     // check if current pool is the right size
00126     if (tmppool->nvar != num_active_parameters)
00127     {
00128       // check sizes of other pools
00129       int found_pool_flag=0;
00130       for (int i=0;i<df1b2variable::adpool_counter;i++)
00131       {
00132         if (df1b2variable::adpool_vector[i]->nvar == num_active_parameters)
00133         {
00134           df1b2variable::pool=df1b2variable::adpool_vector[i];
00135           found_pool_flag=1;
00136           break;
00137         }
00138       }
00139       if (!found_pool_flag)
00140       {
00141         df1b2variable::pool=new adpool();
00142         if (!df1b2variable::pool)
00143         {
00144           cerr << "Memory allocation error" << endl;
00145           ad_exit(1);
00146         }
00147         if (df1b2variable::adpool_counter>df1b2variable::adpool_vectorsize)
00148         {
00149           //cerr << "Need to increase adpool_vectorsize" << endl;
00150           //ad_exit(1);
00151           //int offset=get_unused_pool_index();
00152           int offset=1;
00153           adpool * tmp= df1b2variable::adpool_vector[offset];
00154           delete tmp;
00155           df1b2variable::adpool_vector[offset]=df1b2variable::pool;
00156           df1b2variable::nvar_vector[offset]=num_active_parameters;
00157           df1b2variable::adpool_use_index[offset]=
00158             df1b2variable::current_allocation_index;
00159         }
00160         else
00161         {
00162           df1b2variable::adpool_vector[df1b2variable::adpool_counter]=
00163             df1b2variable::pool;
00164           df1b2variable::nvar_vector[df1b2variable::adpool_counter]=
00165             num_active_parameters;
00166           //df1b2variable::adpool_counter++;
00167           df1b2variable::increment_adpool_counter();
00168         }
00169       }
00170     }
00171   }
00172   else
00173   {
00174     df1b2variable::pool=new adpool();
00175     if (!df1b2variable::pool)
00176     {
00177       cerr << "Memory allocation error" << endl;
00178       ad_exit(1);
00179     }
00180     if (df1b2variable::adpool_counter>df1b2variable::adpool_vectorsize)
00181     {
00182       int offset=1;
00183       adpool * tmp= df1b2variable::adpool_vector[offset];
00184       delete tmp;
00185       df1b2variable::adpool_vector[offset]=df1b2variable::pool;
00186       df1b2variable::nvar_vector[offset]=num_active_parameters;
00187       df1b2variable::adpool_use_index[offset]=
00188         df1b2variable::current_allocation_index;
00189     }
00190     else
00191     {
00192       df1b2variable::adpool_use_index[df1b2variable::adpool_counter]=
00193         df1b2variable::current_allocation_index;
00194       df1b2variable::adpool_vector[df1b2variable::adpool_counter]=
00195         df1b2variable::pool;
00196       df1b2variable::nvar_vector[df1b2variable::adpool_counter]=
00197         num_active_parameters;
00198       //df1b2variable::adpool_counter++;
00199       df1b2variable::increment_adpool_counter();
00200     }
00201   }
00202   df1b2variable::current_allocation_index++;
00203   df1b2variable::nvar=num_active_parameters;
00204   df1b2variable::set_blocksize();
00205 
00206   re_objective_function_value::pobjfun->allocate();
00207   //if (funnel_check_flag)
00208    // check_pool_depths();
00209   df1b2variable::minder=1;
00210   int maxdersave=df1b2variable::maxder;
00211   df1b2variable::maxder=num_active_parameters;
00212   if (!py)
00213   {
00214     py = new init_df1b2vector(1,num_active_parameters);
00215   }
00216   //if (funnel_check_flag)
00217   //  check_pool_depths();
00218   if (!py)
00219   {
00220     cerr << "memory allocation error" << endl;
00221     ad_exit(1);
00222   }
00223   //init_df1b2vector& tmp = *py;
00224 
00225 
00226   if (plist)
00227   {
00228     if (plist->indexmax() != num_active_parameters)
00229     {
00230       delete plist;
00231       plist=0;
00232     }
00233   }
00234   if (!plist)
00235   {
00236     plist = new imatrix(1,num_active_parameters,1,2);
00237   }
00238   if (!plist)
00239   {
00240     cerr << "memory allocation error" << endl;
00241     ad_exit(1);
00242   }
00243 
00244   int ii=1;
00245   int i;
00246   for(i=0;i<num_vars;i++)
00247   {
00248     list[i]->xinit(*py,ii);
00249   }
00250 
00251   ii=1;
00252   for(i=0;i<num_vars;i++)
00253   {
00254     list[i]->set_index(*plist,ii);
00255   }
00256 
00257   for(i=0;i<num_inactive_vars;i++)
00258   {
00259     inactive_list[i]->allocate();
00260   }
00261 
00262   funnel_init_var::reset(*py);
00263   //if (funnel_check_flag)
00264   //  check_pool_depths();
00265   df1b2variable::maxder=maxdersave;
00266 }
00267 
00272 funnel_init_df1b2variable::funnel_init_df1b2variable
00273   (const df1b2_init_number & _x) : df1b2variable(newadkl)
00274   //(df1b2_init_number & x) : df1b2variable()
00275 {
00276   ADUNCONST(df1b2_init_number,x)
00277   type=0;
00278   pointer=0;
00279   ind_index=x.get_ind_index();
00280   if (ind_index<0)
00281   {
00282     add_to_inactive_list();
00283   }
00284   else
00285   {
00286     add_to_list();
00287     if (lapprox==0)
00288     {
00289       cout << "This can't happen" << endl;
00290       ad_exit(1);
00291     }
00292     lapprox->used_flags(ind_index)+=1;
00293   }
00294   //cout << "ind_index = " << ind_index << endl;
00295   xu=*(x.get_u());
00296 }
00297 
00302 funnel_init_df1b2variable::funnel_init_df1b2variable
00303   (const random_effects_bounded_vector_info & _u)
00304   : df1b2variable(newadkl)
00305 {
00306   ADUNCONST(random_effects_bounded_vector_info,u)
00307   df1b2variable& x = (*(u.pv)).df1b2vector::operator () (u.i);
00308 
00309   type=1;
00310   pointer=u.pv;
00311   ind_index = x.get_ind_index();
00312   if (ind_index<0)
00313   {
00314     add_to_inactive_list();
00315   }
00316   else
00317   {
00318     add_to_list();
00319     lapprox->used_flags(ind_index)+=1;
00320   }
00321   xu=*(x.get_u());
00322 }
00323 
00328 void funnel_init_df1b2variable::allocate(const df1b2variable& x)
00329 {
00330   cerr << "Haven't defined htis yet" << endl;
00331   ad_exit(1);
00332 }
00333 
00338 funnel_init_df1b2variable::funnel_init_df1b2variable
00339   (void) : df1b2variable(newadkl)
00340 {
00341   type=0;
00342   pointer=0;
00343   ind_index = -1;
00344   if (ind_index<0)
00345   {
00346     add_to_inactive_list();
00347   }
00348   else
00349   {
00350     add_to_list();
00351   }
00352 }
00353 
00358 void funnel_init_df1b2variable::
00359   preallocate(const df1b2variable & _x)
00360 {
00361   ADUNCONST(df1b2variable,x)
00362   type=0;
00363   pointer=0;
00364   ind_index = x.get_ind_index();
00365   if (ind_index<0)
00366   {
00367     add_to_inactive_list();
00368   }
00369   else
00370   {
00371     add_to_list();
00372     lapprox->used_flags(ind_index)+=1;
00373   }
00374   xu=*(x.get_u());
00375 }
00376 
00381 funnel_init_df1b2variable::funnel_init_df1b2variable
00382   (const funnel_init_df1b2variable& x):
00383   funnel_init_var(),
00384   df1b2variable(x)
00385 {}
00386 
00391 funnel_init_df1b2variable::funnel_init_df1b2variable
00392   (const df1b2variable & _x) : df1b2variable(newadkl)
00393 {
00394   ADUNCONST(df1b2variable,x)
00395   type=0;
00396   pointer=0;
00397   ind_index = x.get_ind_index();
00398   get_ind_index() = x.get_ind_index();
00399   if (ind_index<0)
00400   {
00401     add_to_inactive_list();
00402   }
00403   else
00404   {
00405     add_to_list();
00406     lapprox->used_flags(ind_index)+=1;
00407     if (lapprox->calling_set)
00408     {
00409       int j=++(*lapprox->calling_set)(ind_index,0);
00410       int k=lapprox->used_flags(ind_index);
00411       if (j != k)
00412       {
00413         cerr << "This can't happen" << endl;
00414         ad_exit(1);
00415       }
00416       (*lapprox->calling_set)(ind_index,j)=(*lapprox->calling_set)(0,0);
00417     }
00418   }
00419   xu=*(x.get_u());
00420 }
00421 
00426 void funnel_init_df1b2variable::allocate(void)
00427 {
00428   df1b2variable::allocate();
00429   *(get_u())=xu;
00430   if (index>=0)
00431     get_u_dot()[index]=1.0;
00432 }
00433 
00438 funnel_dependent_df1b2variable::funnel_dependent_df1b2variable
00439   (const df1b2variable& x)
00440 {
00441   df1b2variable::operator = (x);
00442   if (!df1b2_gradlist::no_derivatives)
00443   {
00444     //df1b2variable * tmp = (df1b2variable *) (this);
00445     //set_dependent_variable(*tmp);
00446   }
00447   df1b2_gradlist::set_no_derivatives();
00448 }
00449 
00454 void funnel_init_df1b2variable::set_value(const init_df1b2vector& _x,
00455   const int& _ii)
00456 {
00457   df1b2variable pen=0.0;
00458   ADUNCONST(init_df1b2vector,x)
00459   ADUNCONST(int,ii)
00460   if (!pointer)
00461   {
00462     df1b2variable::operator = (x(ii++));
00463   }
00464   else
00465   {
00466     switch (type)
00467     {
00468       case 1:   // vector
00469       {
00470         df1b2_init_bounded_vector & b = *(df1b2_init_bounded_vector*)pointer;
00471         if (!initial_params::straight_through_flag)
00472         {
00473           // df1b2variable& tmp = boundp(x(ii++),b.getminb(),b.getmaxb(),pen);
00474           // df1b2variable::operator = (tmp);
00475           df1b2variable::operator =
00476             (boundp(x(ii++),b.getminb(),b.getmaxb()));
00477         }
00478         else
00479         {
00480           df1b2variable::operator = (x(ii));
00481           *get_u()=boundp(*(x(ii++).get_u()),b.getminb(),b.getmaxb());
00482         }
00483         break;
00484       }
00485       case 2:  // matrix
00486       default:
00487       {
00488         cerr << "the bounded matrix case in "
00489           " void funnel_init_df1b2variable::xinit  has not bee implemented"
00490           << endl;
00491           ad_exit(1);
00492       }
00493     }
00494   }
00495 }
00496 
00501 void funnel_init_df1b2variable::set_value(const init_df1b2vector& _x,
00502   const int& _ii,const df1b2variable& _pen)
00503 {
00504   ADUNCONST(init_df1b2vector,x)
00505   ADUNCONST(int,ii)
00506   ADUNCONST(df1b2variable,pen)
00507   if (!pointer)
00508   {
00509     df1b2variable::operator = (x(ii++));
00510   }
00511   else
00512   {
00513     switch (type)
00514     {
00515       case 1:   // vector
00516       {
00517         df1b2_init_bounded_vector & b = *(df1b2_init_bounded_vector*)pointer;
00518         laplace_approximation_calculator * l =lapprox;
00519         int uf=-1;
00520         if (ind_index>0)
00521         {
00522           uf=l->used_flags(ind_index);
00523         }
00524         if (uf > 1 && (l->hesstype ==2))
00525         {
00526           if (ind_index <=lapprox->xsize )
00527           {
00528             cout << " fixed effect used " << uf << " times" << endl;
00529             df1b2variable::operator = (boundp(x(ii++),b.getminb(),
00530               b.getmaxb()));
00531           }
00532           else
00533           {
00534              cout << lapprox->hesstype << endl;
00535              cout << " Error random effect used " << uf << " times" << endl;
00536              ad_exit(1);
00537           }
00538         }
00539         else
00540         {
00541           if (!initial_params::straight_through_flag)
00542           {
00543             df1b2variable::operator = (boundp(x(ii++),b.getminb(),b.getmaxb(),
00544               pen));
00545           }
00546           else
00547           {
00548             df1b2variable::operator = (x(ii++));
00549             *get_u()=boundp(*get_u(),b.getminb(),b.getmaxb());
00550             double diff=b.getmaxb()-b.getminb();
00551             df1b2variable ss=((*this)-b.getminb())/diff;
00552 #           ifdef USE_BARD_PEN
00553               const double l4=log(4.0);
00554               double wght=.000001/diff;
00555               pen-=wght*(log(ss+double(1.e-40))+log((double(1.0)-ss)
00556                 +double(1.e-40))+l4);
00557 #           else
00558              XXXX
00559 #           endif
00560           }
00561         }
00562         break;
00563       }
00564       case 2:  // matrix
00565       default:
00566       {
00567         cerr << "the bounded matrix case in "
00568           " void funnel_init_df1b2variable::xinit  has not bee implemented"
00569           << endl;
00570           ad_exit(1);
00571       }
00572     }
00573   }
00574 }
00575 
00580 int funnel_init_var::nvarcalc_all(void)
00581 {
00582   int n=0;
00583   for (int i=0;i<num_vars;i++)
00584   {
00585     n+=list[i]->nvar_calc();
00586   }
00587   return n;
00588 }
00589 
00594 void funnel_init_df1b2variable::xinit(init_df1b2vector& y,int& ii)
00595 {
00596   if (!pointer)
00597   {
00598     y(ii)= xu;
00599   }
00600   else
00601   {
00602     switch (type)
00603     {
00604       case 1:   // vector
00605       {
00606         df1b2_init_bounded_vector & b = *(df1b2_init_bounded_vector*)pointer;
00607         y(ii)=boundpin(xu,b.getminb(),b.getmaxb());
00608         //cout << setprecision(15) <<  << b.getminb() << " "
00609          // << b.getmaxb() << " " << y(ii) << " " << xu << endl;
00610         break;
00611       }
00612       case 2:  // matrix
00613       default:
00614       {
00615         cerr << "the bounded matrix case in "
00616           " void funnel_init_df1b2variable::xinit  has not bee implemented"
00617           << endl;
00618           ad_exit(1);
00619       }
00620     }
00621   }
00622   ii++;
00623 }
00624 
00629 void funnel_init_df1b2variable::xinit(dvector& y,int& ii)
00630 {
00631   if (!pointer)
00632   {
00633     y(ii)= xu;
00634   }
00635   else
00636   {
00637     switch (type)
00638     {
00639       case 1:   // vector
00640       {
00641         df1b2_init_bounded_vector & b = *(df1b2_init_bounded_vector*)pointer;
00642         y(ii)=boundpin(xu,b.getminb(),b.getmaxb());
00643         break;
00644       }
00645       case 2:  // matrix
00646       default:
00647       {
00648         cerr << "the bounded matrix case in "
00649           " void funnel_init_df1b2variable::xinit  has not bee implemented"
00650           << endl;
00651           ad_exit(1);
00652       }
00653     }
00654   }
00655   ii++;
00656 }
00657 
00658 /*
00659 void funnel_init_df1b2variable::xinit(dvector& y,int& ii)
00660 {
00661   y(ii)= xu;
00662   ii++;
00663 }
00664 */
00665 
00670 void funnel_init_df1b2variable::set_index(imatrix& y,int& ii)
00671 {
00672   //cout << ind_index << " " << ii << endl;
00673   y(ii,1)= ind_index;
00674   y(ii,2)= ii;
00675   ii++;
00676 }
00677 
00682 void funnel_init_var::reset(init_df1b2vector& x)
00683 {
00684   int ii=1;
00685   df1b2variable pen=0.0;
00686   for (int i=0;i<num_vars;i++)
00687   {
00688     list[i]->set_value(x,ii,pen);
00689     //list[i]->set_value(x,ii);
00690   }
00691   if (funnel_init_var::funnel_constraints_penalty)
00692   {
00693     delete funnel_init_var::funnel_constraints_penalty;
00694   }
00695   funnel_init_var::funnel_constraints_penalty=new df1b2variable(pen);
00696 }
00697 
00698 
00699 /*
00700 funnel_init_df1b2vector::funnel_init_df1b2vector(const df1b2_init_vector & _x)
00701 {
00702   ADUNCONST(df1b2_init_vector,x)
00703   //type=0;
00704   //pointer=0;
00705   p=&_x;
00706   int mmin=p->indexmin();
00707   int mmax=p->indexmax();
00708   int ind_index = (*p)(mmin).get_ind_index();
00709   if (ind_index<0)
00710   {
00711     add_to_inactive_list();
00712   }
00713   else
00714   {
00715     add_to_list();
00716   }
00717   df1b2variable::noallocate=1;
00718   df1b2vector::allocate(mmin,mmax);
00719   df1b2variable::noallocate=0;
00720 }
00721 */
00722 
00727 funnel_init_df1b2vector::funnel_init_df1b2vector(const df1b2vector & _x)
00728 {
00729   //ADUNCONST(df1b2_init_vector,x)
00730   // this seems to be right and not the above although it seemed to work
00731   ADUNCONST(df1b2_init_vector,x)
00732   p=&_x;
00733   int mmin=p->indexmin();
00734   int mmax=p->indexmax();
00735   int ind_index = x(mmin).get_ind_index();
00736   if (ind_index<0)
00737   {
00738     add_to_inactive_list();
00739   }
00740   else
00741   {
00742     add_to_list();
00743     for (int i=mmin;i<=mmax;i++)
00744     {
00745       ind_index = x(i).get_ind_index();
00746       lapprox->used_flags(ind_index)+=1;
00747     }
00748   }
00749   df1b2variable::noallocate=1;
00750   df1b2vector::allocate(mmin,mmax);
00751   df1b2variable::noallocate=0;
00752 }
00753 
00758 int funnel_init_df1b2vector::nvar_calc(void)
00759 {
00760   return p->indexmax()-p->indexmin()+1;
00761 }
00762 
00767 void funnel_init_df1b2vector::xinit(init_df1b2vector& y,int& ii)
00768 {
00769   //df1b2_init_vector * vp = (df1b2_init_vector *) p;
00770   //int mmin=vp->indexmin();
00771   //int mmax=vp->indexmax();
00772   int mmin=p->indexmin();
00773   int mmax=p->indexmax();
00774   int i;
00775   for (i=mmin;i<=mmax;i++)
00776   {
00777     //y(ii)= value((*vp)(i));
00778     y(ii)= value((*p)(i));
00779     ii++;
00780   }
00781 }
00782 
00787 void funnel_init_df1b2vector::set_index(imatrix& y,int& ii)
00788 {
00789   df1b2_init_vector * vp = (df1b2_init_vector *) p;
00790   int mmin=vp->indexmin();
00791   int mmax=vp->indexmax();
00792   int i;
00793   for (i=mmin;i<=mmax;i++)
00794   {
00795     y(ii,1)= ( *vp)(i).get_ind_index();
00796     y(ii,2)= ii;
00797     ii++;
00798   }
00799 }
00800 
00805 void funnel_init_df1b2vector::set_value(const init_df1b2vector& _x,
00806   const int& _ii,const df1b2variable& _pen)
00807 {
00808   ADUNCONST(int,ii)
00809   ADUNCONST(init_df1b2vector,x)
00810   int mmin=p->indexmin();
00811   int mmax=p->indexmax();
00812   int i;
00813   for (i=mmin;i<=mmax;i++)
00814   {
00815     (*this)(i) = (x(ii++));
00816   }
00817 }
00818 // *****************************************************************
00819 // *****************************************************************
00820 // *****************************************************************
00821 
00826 funnel_init_bounded_df1b2vector::funnel_init_bounded_df1b2vector(
00827   const df1b2_init_bounded_vector& _x)
00828 {
00829   ADUNCONST(df1b2_init_bounded_vector,x)
00830   //type=0;
00831   //pointer=0;
00832   p=&_x;
00833   int mmin=x.indexmin();
00834   int mmax=x.indexmax();
00835   int ind_index = x(mmin).get_ind_index();
00836   if (ind_index<0)
00837   {
00838     add_to_inactive_list();
00839   }
00840   else
00841   {
00842     add_to_list();
00843   }
00844   df1b2variable::noallocate=1;
00845   df1b2vector::allocate(mmin,mmax);
00846   df1b2variable::noallocate=0;
00847 }
00848 
00853 int funnel_init_bounded_df1b2vector::nvar_calc(void)
00854 {
00855   return p->indexmax()-p->indexmin()+1;
00856 }
00857 
00862 void funnel_init_bounded_df1b2vector::xinit(init_df1b2vector& y,int& ii)
00863 {
00864   df1b2_init_bounded_vector * vp = (df1b2_init_bounded_vector *) p;
00865   int mmin=p->indexmin();
00866   int mmax=p->indexmax();
00867   int i;
00868   for (i=mmin;i<=mmax;i++)
00869   {
00870     y(ii)= value((*vp)(i));
00871     ii++;
00872   }
00873 }
00874 
00879 void funnel_init_bounded_df1b2vector::set_index(imatrix& y,int& ii)
00880 {
00881   int mmin=p->indexmin();
00882   int mmax=p->indexmax();
00883   int i;
00884   for (i=mmin;i<=mmax;i++)
00885   {
00886     y(ii,1)= ( *(df1b2_init_bounded_vector *)(p) )(i).get_ind_index();
00887     y(ii,2)= ii;
00888     ii++;
00889   }
00890 }
00891 
00896 void funnel_init_bounded_df1b2vector::set_value(const init_df1b2vector& _x,
00897   const int& _ii,const df1b2variable& _pen)
00898 {
00899   ADUNCONST(int,ii)
00900   ADUNCONST(init_df1b2vector,x)
00901   df1b2_init_bounded_vector * vp = (df1b2_init_bounded_vector *) p;
00902   int mmin=p->indexmin();
00903   int mmax=p->indexmax();
00904   int i;
00905   for (i=mmin;i<=mmax;i++)
00906   {
00907     (*this)(i) = (x(ii++));
00908     if (!initial_params::straight_through_flag)
00909     {
00910       // df1b2variable& tmp = boundp(x(ii++),b.getminb(),b.getmaxb(),pen);
00911       // df1b2variable::operator = (tmp);
00912       (*this)(i) = (boundp(x(ii++),vp->getminb(),vp->getmaxb()));
00913     }
00914     else
00915     {
00916       (*this)(i) = (x(ii));
00917       *((*this)(i).get_u()) =
00918         boundp(*(x(ii++).get_u()),vp->getminb(),vp->getmaxb());
00919     }
00920   }
00921 }