ADMB Documentation  11.1.2528
 All Classes Files Functions Variables Typedefs Friends Defines
df1b2fnl.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: df1b2fnl.cpp 2506 2014-10-27 20:13:12Z 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 
00039 void funnel_init_var::add_to_list(void)
00040 {
00041   index=num_vars;
00042   list[num_vars++]=this;
00043   //all_list[num_all_vars++]=this;
00044 }
00045 
00050 void funnel_init_var::delete_from_list(void)
00051 {
00052   if (index!=num_vars-1)
00053   {
00054     cerr << "can only delete last member" << endl;
00055     ad_exit(1);
00056   }
00057   num_vars--;
00058   index=-1;
00059 }
00060 
00065 void funnel_init_var::add_to_inactive_list(void)
00066 {
00067   index=-1;
00068   inactive_list[num_inactive_vars++]=this;
00069 }
00070 
00075 void funnel_init_var::allocate(void)
00076 {
00077   //cout << "In allocate" << endl;
00078 }
00079 
00084 void check_pool_depths(void)
00085 {
00086   for (int i=0;i<df1b2variable::adpool_counter;i++)
00087   {
00088     cout << " Pool depth " << i << "  "
00089          << df1b2variable::adpool_vector[i]->depth_check()
00090          << "  " << df1b2variable::adpool_vector[i]  << endl;
00091   }
00092 }
00093 
00097 void funnel_init_var::deallocate_all(void)
00098 {
00099   if (plist)
00100   {
00101     if (plist->indexmax() != num_active_parameters)
00102     {
00103     delete plist;
00104     plist = 0;
00105     }
00106   }
00107   if (py)
00108   {
00109     delete py;
00110     py = 0;
00111   }
00112 }
00113 
00118 void funnel_init_var::allocate_all(void)
00119 {
00120   re_objective_function_value::pobjfun->deallocate();
00121   if (lapprox)
00122   {
00123     if (lapprox->calling_set)
00124     {
00125       (*lapprox->calling_set)(0,0)++;
00126     }
00127   }
00128   num_active_parameters=funnel_init_var::nvarcalc_all();
00129   if (py)
00130   {
00131     if (py->indexmax() != num_active_parameters)
00132     {
00133       delete py;
00134       py=0;
00135     }
00136   }
00137   f1b2gradlist->reset();
00138 
00139   adpool * tmppool=df1b2variable::pool;
00140   if (tmppool)
00141   {
00142     //cout << tmppool << endl;
00143     // check if current pool is the right size
00144     if (tmppool->nvar != num_active_parameters)
00145     {
00146       // check sizes of other pools
00147       int found_pool_flag=0;
00148       for (int i=0;i<df1b2variable::adpool_counter;i++)
00149       {
00150         if (df1b2variable::adpool_vector[i]->nvar == num_active_parameters)
00151         {
00152           df1b2variable::pool=df1b2variable::adpool_vector[i];
00153           found_pool_flag=1;
00154           break;
00155         }
00156       }
00157       if (!found_pool_flag)
00158       {
00159         df1b2variable::pool=new adpool();
00160         if (!df1b2variable::pool)
00161         {
00162           cerr << "Memory allocation error" << endl;
00163           ad_exit(1);
00164         }
00165         if (df1b2variable::adpool_counter>df1b2variable::adpool_vectorsize)
00166         {
00167           //cerr << "Need to increase adpool_vectorsize" << endl;
00168           //ad_exit(1);
00169           //int offset=get_unused_pool_index();
00170           int offset=1;
00171           adpool * tmp= df1b2variable::adpool_vector[offset];
00172           delete tmp;
00173           df1b2variable::adpool_vector[offset]=df1b2variable::pool;
00174           df1b2variable::nvar_vector[offset]=num_active_parameters;
00175           df1b2variable::adpool_use_index[offset]=
00176             df1b2variable::current_allocation_index;
00177         }
00178         else
00179         {
00180           df1b2variable::adpool_vector[df1b2variable::adpool_counter]=
00181             df1b2variable::pool;
00182           df1b2variable::nvar_vector[df1b2variable::adpool_counter]=
00183             num_active_parameters;
00184           //df1b2variable::adpool_counter++;
00185           df1b2variable::increment_adpool_counter();
00186         }
00187       }
00188     }
00189   }
00190   else
00191   {
00192     df1b2variable::pool=new adpool();
00193     if (!df1b2variable::pool)
00194     {
00195       cerr << "Memory allocation error" << endl;
00196       ad_exit(1);
00197     }
00198     if (df1b2variable::adpool_counter>df1b2variable::adpool_vectorsize)
00199     {
00200       int offset=1;
00201       adpool * tmp= df1b2variable::adpool_vector[offset];
00202       delete tmp;
00203       df1b2variable::adpool_vector[offset]=df1b2variable::pool;
00204       df1b2variable::nvar_vector[offset]=num_active_parameters;
00205       df1b2variable::adpool_use_index[offset]=
00206         df1b2variable::current_allocation_index;
00207     }
00208     else
00209     {
00210       df1b2variable::adpool_use_index[df1b2variable::adpool_counter]=
00211         df1b2variable::current_allocation_index;
00212       df1b2variable::adpool_vector[df1b2variable::adpool_counter]=
00213         df1b2variable::pool;
00214       df1b2variable::nvar_vector[df1b2variable::adpool_counter]=
00215         num_active_parameters;
00216       //df1b2variable::adpool_counter++;
00217       df1b2variable::increment_adpool_counter();
00218     }
00219   }
00220   df1b2variable::current_allocation_index++;
00221   df1b2variable::nvar=num_active_parameters;
00222   df1b2variable::set_blocksize();
00223 
00224   re_objective_function_value::pobjfun->allocate();
00225   //if (funnel_check_flag)
00226    // check_pool_depths();
00227   df1b2variable::minder=1;
00228   int maxdersave=df1b2variable::maxder;
00229   df1b2variable::maxder=num_active_parameters;
00230   if (!py)
00231   {
00232     py = new init_df1b2vector(1,num_active_parameters);
00233   }
00234   //if (funnel_check_flag)
00235   //  check_pool_depths();
00236   if (!py)
00237   {
00238     cerr << "memory allocation error" << endl;
00239     ad_exit(1);
00240   }
00241   //init_df1b2vector& tmp = *py;
00242 
00243 
00244   if (plist)
00245   {
00246     if (plist->indexmax() != num_active_parameters)
00247     {
00248       delete plist;
00249       plist=0;
00250     }
00251   }
00252   if (!plist)
00253   {
00254     plist = new imatrix(1,num_active_parameters,1,2);
00255   }
00256   if (!plist)
00257   {
00258     cerr << "memory allocation error" << endl;
00259     ad_exit(1);
00260   }
00261 
00262   int ii=1;
00263   int i;
00264   for(i=0;i<num_vars;i++)
00265   {
00266     list[i]->xinit(*py,ii);
00267   }
00268 
00269   ii=1;
00270   for(i=0;i<num_vars;i++)
00271   {
00272     list[i]->set_index(*plist,ii);
00273   }
00274 
00275   for(i=0;i<num_inactive_vars;i++)
00276   {
00277     inactive_list[i]->allocate();
00278   }
00279 
00280   funnel_init_var::reset(*py);
00281   //if (funnel_check_flag)
00282   //  check_pool_depths();
00283   df1b2variable::maxder=maxdersave;
00284 }
00285 
00290 funnel_init_df1b2variable::funnel_init_df1b2variable
00291   (const df1b2_init_number & _x) : df1b2variable(newadkl)
00292   //(df1b2_init_number & x) : df1b2variable()
00293 {
00294   ADUNCONST(df1b2_init_number,x)
00295   type=0;
00296   pointer=0;
00297   ind_index=x.get_ind_index();
00298   if (ind_index<0)
00299   {
00300     add_to_inactive_list();
00301   }
00302   else
00303   {
00304     add_to_list();
00305     if (lapprox==0)
00306     {
00307       cout << "This can't happen" << endl;
00308       ad_exit(1);
00309     }
00310     lapprox->used_flags(ind_index)+=1;
00311   }
00312   //cout << "ind_index = " << ind_index << endl;
00313   xu=*(x.get_u());
00314 }
00315 
00320 funnel_init_df1b2variable::funnel_init_df1b2variable
00321   (const random_effects_bounded_vector_info & _u)
00322   : df1b2variable(newadkl)
00323 {
00324   ADUNCONST(random_effects_bounded_vector_info,u)
00325   df1b2variable& x = (*(u.pv)).df1b2vector::operator () (u.i);
00326 
00327   type=1;
00328   pointer=u.pv;
00329   ind_index = x.get_ind_index();
00330   if (ind_index<0)
00331   {
00332     add_to_inactive_list();
00333   }
00334   else
00335   {
00336     add_to_list();
00337     lapprox->used_flags(ind_index)+=1;
00338   }
00339   xu=*(x.get_u());
00340 }
00341 
00346 void funnel_init_df1b2variable::allocate(const df1b2variable& x)
00347 {
00348   cerr << "Haven't defined htis yet" << endl;
00349   ad_exit(1);
00350 }
00351 
00356 funnel_init_df1b2variable::funnel_init_df1b2variable
00357   (void) : df1b2variable(newadkl)
00358 {
00359   type=0;
00360   pointer=0;
00361   ind_index = -1;
00362   if (ind_index<0)
00363   {
00364     add_to_inactive_list();
00365   }
00366   else
00367   {
00368     add_to_list();
00369   }
00370 }
00371 
00376 void funnel_init_df1b2variable::
00377   preallocate(const df1b2variable & _x)
00378 {
00379   ADUNCONST(df1b2variable,x)
00380   type=0;
00381   pointer=0;
00382   ind_index = x.get_ind_index();
00383   if (ind_index<0)
00384   {
00385     add_to_inactive_list();
00386   }
00387   else
00388   {
00389     add_to_list();
00390     lapprox->used_flags(ind_index)+=1;
00391   }
00392   xu=*(x.get_u());
00393 }
00394 
00399 funnel_init_df1b2variable::funnel_init_df1b2variable
00400   (const funnel_init_df1b2variable& x):
00401   funnel_init_var(),
00402   df1b2variable(x)
00403 {}
00404 
00409 funnel_init_df1b2variable::funnel_init_df1b2variable
00410   (const df1b2variable & _x) : df1b2variable(newadkl)
00411 {
00412   ADUNCONST(df1b2variable,x)
00413   type=0;
00414   pointer=0;
00415   ind_index = x.get_ind_index();
00416   get_ind_index() = x.get_ind_index();
00417   if (ind_index<0)
00418   {
00419     add_to_inactive_list();
00420   }
00421   else
00422   {
00423     add_to_list();
00424     lapprox->used_flags(ind_index)+=1;
00425     if (lapprox->calling_set)
00426     {
00427       int j=++(*lapprox->calling_set)(ind_index,0);
00428       int k=lapprox->used_flags(ind_index);
00429       if (j != k)
00430       {
00431         cerr << "This can't happen" << endl;
00432         ad_exit(1);
00433       }
00434       (*lapprox->calling_set)(ind_index,j)=(*lapprox->calling_set)(0,0);
00435     }
00436   }
00437   xu=*(x.get_u());
00438 }
00439 
00444 void funnel_init_df1b2variable::allocate(void)
00445 {
00446   df1b2variable::allocate();
00447   *(get_u())=xu;
00448   if (index>=0)
00449     get_u_dot()[index]=1.0;
00450 }
00451 
00456 funnel_dependent_df1b2variable::funnel_dependent_df1b2variable
00457   (const df1b2variable& x)
00458 {
00459   df1b2variable::operator = (x);
00460   if (!df1b2_gradlist::no_derivatives)
00461   {
00462     //df1b2variable * tmp = (df1b2variable *) (this);
00463     //set_dependent_variable(*tmp);
00464   }
00465   df1b2_gradlist::set_no_derivatives();
00466 }
00467 
00472 void funnel_init_df1b2variable::set_value(const init_df1b2vector& _x,
00473   const int& _ii)
00474 {
00475   df1b2variable pen=0.0;
00476   ADUNCONST(init_df1b2vector,x)
00477   ADUNCONST(int,ii)
00478   if (!pointer)
00479   {
00480     df1b2variable::operator = (x(ii++));
00481   }
00482   else
00483   {
00484     switch (type)
00485     {
00486       case 1:   // vector
00487       {
00488         df1b2_init_bounded_vector & b = *(df1b2_init_bounded_vector*)pointer;
00489         if (!initial_params::straight_through_flag)
00490         {
00491           // df1b2variable& tmp = boundp(x(ii++),b.getminb(),b.getmaxb(),pen);
00492           // df1b2variable::operator = (tmp);
00493           df1b2variable::operator =
00494             (boundp(x(ii++),b.getminb(),b.getmaxb()));
00495         }
00496         else
00497         {
00498           df1b2variable::operator = (x(ii));
00499           *get_u()=boundp(*(x(ii++).get_u()),b.getminb(),b.getmaxb());
00500         }
00501         break;
00502       }
00503       case 2:  // matrix
00504       default:
00505       {
00506         cerr << "the bounded matrix case in "
00507           " void funnel_init_df1b2variable::xinit  has not bee implemented"
00508           << endl;
00509           ad_exit(1);
00510       }
00511     }
00512   }
00513 }
00514 
00519 void funnel_init_df1b2variable::set_value(const init_df1b2vector& _x,
00520   const int& _ii,const df1b2variable& _pen)
00521 {
00522   ADUNCONST(init_df1b2vector,x)
00523   ADUNCONST(int,ii)
00524   ADUNCONST(df1b2variable,pen)
00525   if (!pointer)
00526   {
00527     df1b2variable::operator = (x(ii++));
00528   }
00529   else
00530   {
00531     switch (type)
00532     {
00533       case 1:   // vector
00534       {
00535         df1b2_init_bounded_vector & b = *(df1b2_init_bounded_vector*)pointer;
00536         laplace_approximation_calculator * l =lapprox;
00537         int uf=-1;
00538         if (ind_index>0)
00539         {
00540           uf=l->used_flags(ind_index);
00541         }
00542         if (uf > 1 && (l->hesstype ==2))
00543         {
00544           if (ind_index <=lapprox->xsize )
00545           {
00546             cout << " fixed effect used " << uf << " times" << endl;
00547             df1b2variable::operator = (boundp(x(ii++),b.getminb(),
00548               b.getmaxb()));
00549           }
00550           else
00551           {
00552              cout << lapprox->hesstype << endl;
00553              cout << " Error random effect used " << uf << " times" << endl;
00554              ad_exit(1);
00555           }
00556         }
00557         else
00558         {
00559           if (!initial_params::straight_through_flag)
00560           {
00561             df1b2variable::operator = (boundp(x(ii++),b.getminb(),b.getmaxb(),
00562               pen));
00563           }
00564           else
00565           {
00566             df1b2variable::operator = (x(ii++));
00567             *get_u()=boundp(*get_u(),b.getminb(),b.getmaxb());
00568             double diff=b.getmaxb()-b.getminb();
00569             df1b2variable ss=((*this)-b.getminb())/diff;
00570 #           ifdef USE_BARD_PEN
00571               const double l4=log(4.0);
00572               double wght=.000001/diff;
00573               pen-=wght*(log(ss+double(1.e-40))+log((double(1.0)-ss)
00574                 +double(1.e-40))+l4);
00575 #           else
00576              XXXX
00577 #           endif
00578           }
00579         }
00580         break;
00581       }
00582       case 2:  // matrix
00583       default:
00584       {
00585         cerr << "the bounded matrix case in "
00586           " void funnel_init_df1b2variable::xinit  has not bee implemented"
00587           << endl;
00588           ad_exit(1);
00589       }
00590     }
00591   }
00592 }
00593 
00598 int funnel_init_var::nvarcalc_all(void)
00599 {
00600   int n=0;
00601   for (int i=0;i<num_vars;i++)
00602   {
00603     n+=list[i]->nvar_calc();
00604   }
00605   return n;
00606 }
00607 
00612 void funnel_init_df1b2variable::xinit(init_df1b2vector& y,int& ii)
00613 {
00614   if (!pointer)
00615   {
00616     y(ii)= xu;
00617   }
00618   else
00619   {
00620     switch (type)
00621     {
00622       case 1:   // vector
00623       {
00624         df1b2_init_bounded_vector & b = *(df1b2_init_bounded_vector*)pointer;
00625         y(ii)=boundpin(xu,b.getminb(),b.getmaxb());
00626         //cout << setprecision(15) <<  << b.getminb() << " "
00627          // << b.getmaxb() << " " << y(ii) << " " << xu << endl;
00628         break;
00629       }
00630       case 2:  // matrix
00631       default:
00632       {
00633         cerr << "the bounded matrix case in "
00634           " void funnel_init_df1b2variable::xinit  has not bee implemented"
00635           << endl;
00636           ad_exit(1);
00637       }
00638     }
00639   }
00640   ii++;
00641 }
00642 
00647 void funnel_init_df1b2variable::xinit(dvector& y,int& ii)
00648 {
00649   if (!pointer)
00650   {
00651     y(ii)= xu;
00652   }
00653   else
00654   {
00655     switch (type)
00656     {
00657       case 1:   // vector
00658       {
00659         df1b2_init_bounded_vector & b = *(df1b2_init_bounded_vector*)pointer;
00660         y(ii)=boundpin(xu,b.getminb(),b.getmaxb());
00661         break;
00662       }
00663       case 2:  // matrix
00664       default:
00665       {
00666         cerr << "the bounded matrix case in "
00667           " void funnel_init_df1b2variable::xinit  has not bee implemented"
00668           << endl;
00669           ad_exit(1);
00670       }
00671     }
00672   }
00673   ii++;
00674 }
00675 
00676 /*
00677 void funnel_init_df1b2variable::xinit(dvector& y,int& ii)
00678 {
00679   y(ii)= xu;
00680   ii++;
00681 }
00682 */
00683 
00688 void funnel_init_df1b2variable::set_index(imatrix& y,int& ii)
00689 {
00690   //cout << ind_index << " " << ii << endl;
00691   y(ii,1)= ind_index;
00692   y(ii,2)= ii;
00693   ii++;
00694 }
00695 
00700 void funnel_init_var::reset(init_df1b2vector& x)
00701 {
00702   int ii=1;
00703   df1b2variable pen=0.0;
00704   for (int i=0;i<num_vars;i++)
00705   {
00706     list[i]->set_value(x,ii,pen);
00707     //list[i]->set_value(x,ii);
00708   }
00709   if (funnel_init_var::funnel_constraints_penalty)
00710   {
00711     delete funnel_init_var::funnel_constraints_penalty;
00712   }
00713   funnel_init_var::funnel_constraints_penalty=new df1b2variable(pen);
00714 }
00715 
00716 
00717 /*
00718 funnel_init_df1b2vector::funnel_init_df1b2vector(const df1b2_init_vector & _x)
00719 {
00720   ADUNCONST(df1b2_init_vector,x)
00721   //type=0;
00722   //pointer=0;
00723   p=&_x;
00724   int mmin=p->indexmin();
00725   int mmax=p->indexmax();
00726   int ind_index = (*p)(mmin).get_ind_index();
00727   if (ind_index<0)
00728   {
00729     add_to_inactive_list();
00730   }
00731   else
00732   {
00733     add_to_list();
00734   }
00735   df1b2variable::noallocate=1;
00736   df1b2vector::allocate(mmin,mmax);
00737   df1b2variable::noallocate=0;
00738 }
00739 */
00740 
00745 funnel_init_df1b2vector::funnel_init_df1b2vector(const df1b2vector & _x)
00746 {
00747   //ADUNCONST(df1b2_init_vector,x)
00748   // this seems to be right and not the above although it seemed to work
00749   ADUNCONST(df1b2_init_vector,x)
00750   p=&_x;
00751   int mmin=p->indexmin();
00752   int mmax=p->indexmax();
00753   int ind_index = x(mmin).get_ind_index();
00754   if (ind_index<0)
00755   {
00756     add_to_inactive_list();
00757   }
00758   else
00759   {
00760     add_to_list();
00761     for (int i=mmin;i<=mmax;i++)
00762     {
00763       ind_index = x(i).get_ind_index();
00764       lapprox->used_flags(ind_index)+=1;
00765     }
00766   }
00767   df1b2variable::noallocate=1;
00768   df1b2vector::allocate(mmin,mmax);
00769   df1b2variable::noallocate=0;
00770 }
00771 
00775 funnel_init_df1b2vector::~funnel_init_df1b2vector()
00776 {
00777   //df1b2vector::deallocate();
00778 }
00779 
00784 int funnel_init_df1b2vector::nvar_calc(void)
00785 {
00786   return p->indexmax()-p->indexmin()+1;
00787 }
00788 
00793 void funnel_init_df1b2vector::xinit(init_df1b2vector& y,int& ii)
00794 {
00795   //df1b2_init_vector * vp = (df1b2_init_vector *) p;
00796   //int mmin=vp->indexmin();
00797   //int mmax=vp->indexmax();
00798   int mmin=p->indexmin();
00799   int mmax=p->indexmax();
00800   int i;
00801   for (i=mmin;i<=mmax;i++)
00802   {
00803     //y(ii)= value((*vp)(i));
00804     y(ii)= value((*p)(i));
00805     ii++;
00806   }
00807 }
00808 
00813 void funnel_init_df1b2vector::set_index(imatrix& y,int& ii)
00814 {
00815   df1b2_init_vector * vp = (df1b2_init_vector *) p;
00816   int mmin=vp->indexmin();
00817   int mmax=vp->indexmax();
00818   int i;
00819   for (i=mmin;i<=mmax;i++)
00820   {
00821     y(ii,1)= ( *vp)(i).get_ind_index();
00822     y(ii,2)= ii;
00823     ii++;
00824   }
00825 }
00826 
00831 void funnel_init_df1b2vector::set_value(const init_df1b2vector& _x,
00832   const int& _ii,const df1b2variable& _pen)
00833 {
00834   ADUNCONST(int,ii)
00835   ADUNCONST(init_df1b2vector,x)
00836   int mmin=p->indexmin();
00837   int mmax=p->indexmax();
00838   int i;
00839   for (i=mmin;i<=mmax;i++)
00840   {
00841     (*this)(i) = (x(ii++));
00842   }
00843 }
00844 // *****************************************************************
00845 // *****************************************************************
00846 // *****************************************************************
00847 
00852 funnel_init_bounded_df1b2vector::funnel_init_bounded_df1b2vector(
00853   const df1b2_init_bounded_vector& _x)
00854 {
00855   ADUNCONST(df1b2_init_bounded_vector,x)
00856   //type=0;
00857   //pointer=0;
00858   p=&_x;
00859   int mmin=x.indexmin();
00860   int mmax=x.indexmax();
00861   int ind_index = x(mmin).get_ind_index();
00862   if (ind_index<0)
00863   {
00864     add_to_inactive_list();
00865   }
00866   else
00867   {
00868     add_to_list();
00869   }
00870   df1b2variable::noallocate=1;
00871   df1b2vector::allocate(mmin,mmax);
00872   df1b2variable::noallocate=0;
00873 }
00874 
00879 int funnel_init_bounded_df1b2vector::nvar_calc(void)
00880 {
00881   return p->indexmax()-p->indexmin()+1;
00882 }
00883 
00888 void funnel_init_bounded_df1b2vector::xinit(init_df1b2vector& y,int& ii)
00889 {
00890   df1b2_init_bounded_vector * vp = (df1b2_init_bounded_vector *) p;
00891   int mmin=p->indexmin();
00892   int mmax=p->indexmax();
00893   int i;
00894   for (i=mmin;i<=mmax;i++)
00895   {
00896     y(ii)= value((*vp)(i));
00897     ii++;
00898   }
00899 }
00900 
00905 void funnel_init_bounded_df1b2vector::set_index(imatrix& y,int& ii)
00906 {
00907   int mmin=p->indexmin();
00908   int mmax=p->indexmax();
00909   int i;
00910   for (i=mmin;i<=mmax;i++)
00911   {
00912     y(ii,1)= ( *(df1b2_init_bounded_vector *)(p) )(i).get_ind_index();
00913     y(ii,2)= ii;
00914     ii++;
00915   }
00916 }
00917 
00922 void funnel_init_bounded_df1b2vector::set_value(const init_df1b2vector& _x,
00923   const int& _ii,const df1b2variable& _pen)
00924 {
00925   ADUNCONST(int,ii)
00926   ADUNCONST(init_df1b2vector,x)
00927   df1b2_init_bounded_vector * vp = (df1b2_init_bounded_vector *) p;
00928   int mmin=p->indexmin();
00929   int mmax=p->indexmax();
00930   int i;
00931   for (i=mmin;i<=mmax;i++)
00932   {
00933     (*this)(i) = (x(ii++));
00934     if (!initial_params::straight_through_flag)
00935     {
00936       // df1b2variable& tmp = boundp(x(ii++),b.getminb(),b.getmaxb(),pen);
00937       // df1b2variable::operator = (tmp);
00938       (*this)(i) = (boundp(x(ii++),vp->getminb(),vp->getmaxb()));
00939     }
00940     else
00941     {
00942       (*this)(i) = (x(ii));
00943       *((*this)(i).get_u()) =
00944         boundp(*(x(ii++).get_u()),vp->getminb(),vp->getmaxb());
00945     }
00946   }
00947 }