ADMB Documentation  11.1.1015
 All Classes Files Functions Variables Typedefs Friends Defines
df1b2fnl.h
Go to the documentation of this file.
00001 /*
00002  * $Id: df1b2fnl.h 542 2012-07-10 21:04:06Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  * 
00007  * ADModelbuilder and associated libraries and documentations are
00008  * provided under the general terms of the "BSD" license.
00009  *
00010  * License:
00011  * 
00012  * Redistribution and use in source and binary forms, with or without
00013  * modification, are permitted provided that the following conditions are
00014  * met:
00015  * 
00016  * 1. Redistributions of source code must retain the above copyright
00017  * notice, this list of conditions and the following disclaimer.
00018  * 
00019  * 2.  Redistributions in binary form must reproduce the above copyright
00020  * notice, this list of conditions and the following disclaimer in the
00021  * documentation and/or other materials provided with the distribution.
00022  * 
00023  * 3.  Neither the name of the  University of California, Otter Research,
00024  * nor the ADMB Foundation nor the names of its contributors may be used
00025  * to endorse or promote products derived from this software without
00026  * specific prior written permission.
00027  * 
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00029  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00030  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00031  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00032  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00033  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00034  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00035  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00036  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00038  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  */
00046 #include <df1b2fun.h>
00047 #if !defined(__DF1B2FNL__)
00048 #  define __DF1B2FNL__ 
00049 #include <adrndeff.h>
00050 
00055 class funnel_init_var
00056 {
00057 public:
00058   static laplace_approximation_calculator * lapprox;
00059   static df1b2variable * funnel_constraints_penalty;
00060   static void reset_counters(void) { num_vars=0; /*num_all_vars=0;*/}
00061   static int num_vars;
00062   //static int num_all_vars;
00063   static int num_inactive_vars;
00064   static int num_active_parameters;
00065   static init_df1b2vector * py;
00066   static imatrix * plist;
00067   int index;
00068   static   funnel_init_var ** list;
00069   //static   funnel_init_var ** all_list;
00070   static   funnel_init_var ** inactive_list;
00071   funnel_init_var(void) { /*add_to_list();*/ }
00072   void add_to_list(void);
00073   void delete_from_list(void);
00074   void add_to_inactive_list(void);
00075   virtual void allocate(void);
00076   //virtual void xinit(void);
00077   virtual void xinit(init_df1b2vector&,int& ii)=0;
00078   virtual void xinit(dvector&,int& ii)=0;
00079   virtual void set_value(const init_df1b2vector&,const int& ii,
00080     const df1b2variable&)=0;
00081   virtual void set_value(const init_df1b2vector&,const int& ii)=0;
00082   virtual void set_index(imatrix&,int& ii)=0;
00083   virtual int nvar_calc(void)=0;
00084 
00085   static void reset(init_df1b2vector& x);
00086     
00087   static void allocate_all(void);
00088   static int nvarcalc_all(void);
00089 };
00090 
00095 class funnel_dependent_df1b2variable : public df1b2variable 
00096 {
00097   int assign_flag;
00098 public:
00099   double * get_u(void){ return df1b2variable::get_u();}
00100   void operator = (const df1b2variable&) 
00101   {
00102     cerr << "Cannot assign to funnel_dependent_df1b2variable" << endl;
00103     ad_exit(1);
00104   }
00105   funnel_dependent_df1b2variable(const df1b2variable&); 
00106   //virtual void allocate_all(init_df1b2vector&,int& ii);
00107 };
00108 
00113 class funnel_init_df1b2variable : public funnel_init_var, public df1b2variable 
00114 {
00115 public:
00116   int type;
00117   void * pointer;
00118   double xu;
00119   int ind_index;
00120   int nvar_calc(void){return 1;}
00121   funnel_init_df1b2variable(const df1b2_init_number & x); 
00122   funnel_init_df1b2variable(const funnel_init_df1b2variable& x); 
00123   funnel_init_df1b2variable(const df1b2variable & x); 
00124   funnel_init_df1b2variable(void); 
00125   funnel_init_df1b2variable(const random_effects_bounded_vector_info&); 
00126   virtual void allocate(void);
00127   virtual void allocate(const df1b2variable&);
00128   virtual void preallocate(const df1b2variable&);
00129   virtual void xinit(init_df1b2vector&,int& ii);
00130   virtual void xinit(dvector&,int& ii);
00131   virtual void set_value(const init_df1b2vector&,const int& ii);
00132   virtual void set_value(const init_df1b2vector&,const int& ii,
00133     const df1b2variable&);
00134   virtual void set_index(imatrix&,int& ii);
00135 };
00136 
00141 class funnel_init_bounded_df1b2vector : public funnel_init_var, 
00142   public df1b2vector 
00143 {
00144   const df1b2_init_bounded_vector * p;
00145 public:
00146   int nvar_calc(void);
00147   funnel_init_bounded_df1b2vector(const df1b2_init_bounded_vector & x);
00148   virtual void xinit(init_df1b2vector&,int& ii);
00149   virtual void xinit(dvector&,int& ii){ cout << "here"<< endl;}
00150   virtual void set_value(const init_df1b2vector&,const int& ii,
00151     const df1b2variable&);
00152   virtual void set_value(const init_df1b2vector&,const int& ii){ cout << "here"<< endl;}
00153   virtual void set_index(imatrix&,int& ii);
00154 };
00155 
00156 
00161 class funnel_init_df1b2vector : public funnel_init_var, public df1b2vector 
00162 {
00163   const df1b2vector * p;
00164   //const df1b2_init_vector * p;
00165 public:
00166   int nvar_calc(void);
00167   //funnel_init_df1b2vector(const df1b2_init_vector & x);
00168   funnel_init_df1b2vector(const df1b2vector & x);
00169   virtual void xinit(init_df1b2vector&,int& ii);
00170   virtual void xinit(dvector&,int& ii){ cout << "here"<< endl;}
00171   virtual void set_value(const init_df1b2vector&,const int& ii,
00172     const df1b2variable&);
00173   virtual void set_value(const init_df1b2vector&,const int& ii){ cout << "here"<< endl;}
00174   virtual void set_index(imatrix&,int& ii);
00175   virtual void allocate(void);
00176 };
00177 
00178 
00183 class funnel_init_df1b2matrix : public funnel_init_var, public df1b2matrix 
00184 {
00185   const df1b2matrix* p;
00186   //const df1b2_init_vector * p;
00187 public:
00188   int nvar_calc(void);
00189   //funnel_init_df1b2vector(const df1b2_init_vector & x);
00190   funnel_init_df1b2matrix(const df1b2matrix & x);
00191   virtual void xinit(init_df1b2vector&,int& ii);
00192   virtual void xinit(dvector&,int& ii){ cout << "here"<< endl;}
00193   virtual void set_value(const init_df1b2vector&,const int& ii,
00194     const df1b2variable&);
00195   virtual void set_value(const init_df1b2vector&,const int& ii){ cout << "here"<< endl;}
00196   virtual void set_index(imatrix&,int& ii);
00197 };
00198 
00199 
00200 
00201 #endif  //  #if !defined(__DF1B2FNL__)