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