ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
df1b2fnl.h
Go to the documentation of this file.
00001 /*
00002  * $Id$
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   funnel_init_var() { /*add_to_list();*/ }
00059   ~funnel_init_var() {}
00060 
00061   static laplace_approximation_calculator * lapprox;
00062   static df1b2variable * funnel_constraints_penalty;
00063   static void reset_counters(void) { num_vars=0; /*num_all_vars=0;*/}
00064   static unsigned int num_vars;
00065   //static int num_all_vars;
00066   static int num_inactive_vars;
00067   static unsigned int num_active_parameters;
00068   static init_df1b2vector * py;
00069   static imatrix * plist;
00070   int index;
00071   static   funnel_init_var ** list;
00072   //static   funnel_init_var ** all_list;
00073   static   funnel_init_var ** inactive_list;
00074   void add_to_list(void);
00075   void delete_from_list(void);
00076   void add_to_inactive_list(void);
00077   virtual void allocate(void);
00078   //virtual void xinit(void);
00079   virtual void xinit(init_df1b2vector&,int& ii)=0;
00080   virtual void xinit(dvector&,int& ii)=0;
00081   virtual void set_value(const init_df1b2vector&,const int& ii,
00082     const df1b2variable&)=0;
00083   virtual void set_value(const init_df1b2vector&,const int& ii)=0;
00084   virtual void set_index(imatrix&,int& ii)=0;
00085   virtual int nvar_calc(void)=0;
00086 
00087   static void reset(init_df1b2vector& x);
00088 
00089   static void allocate_all(void);
00090   static void deallocate_all(void);
00091   static unsigned int nvarcalc_all();
00092 };
00093 
00098 class funnel_dependent_df1b2variable : public df1b2variable
00099 {
00100 public:
00101   double * get_u(void){ return df1b2variable::get_u();}
00102   void operator = (const df1b2variable&)
00103   {
00104     cerr << "Cannot assign to funnel_dependent_df1b2variable" << endl;
00105     ad_exit(1);
00106   }
00107   funnel_dependent_df1b2variable(const df1b2variable&);
00108   //virtual void allocate_all(init_df1b2vector&,int& ii);
00109 };
00110 
00115 class funnel_init_df1b2variable : public funnel_init_var, public df1b2variable
00116 {
00117 public:
00118   int type;
00119   void * pointer;
00120   double xu;
00121   int ind_index;
00122   int nvar_calc(void){return 1;}
00123   funnel_init_df1b2variable(const df1b2_init_number & x);
00124   funnel_init_df1b2variable(const funnel_init_df1b2variable& x);
00125   funnel_init_df1b2variable(const df1b2variable & x);
00126   funnel_init_df1b2variable(void);
00127   funnel_init_df1b2variable(const random_effects_bounded_vector_info&);
00128   virtual void allocate(void);
00129   virtual void allocate(const df1b2variable&);
00130   virtual void preallocate(const df1b2variable&);
00131   virtual void xinit(init_df1b2vector&,int& ii);
00132   virtual void xinit(dvector&,int& ii);
00133   virtual void set_value(const init_df1b2vector&,const int& ii);
00134   virtual void set_value(const init_df1b2vector&,const int& ii,
00135     const df1b2variable&);
00136   virtual void set_index(imatrix&,int& ii);
00137 };
00138 
00143 class funnel_init_bounded_df1b2vector : public funnel_init_var,
00144   public df1b2vector
00145 {
00146   const df1b2_init_bounded_vector * p;
00147 public:
00148   int nvar_calc(void);
00149   funnel_init_bounded_df1b2vector(const df1b2_init_bounded_vector & x);
00150   virtual void xinit(init_df1b2vector&,int& ii);
00151   virtual void xinit(dvector&, int&){ cout << "here"<< endl;}
00152   virtual void set_value(const init_df1b2vector&,const int& ii,
00153     const df1b2variable&);
00154   virtual void set_value(const init_df1b2vector&, const int&)
00155     { cout << "here"<< endl;}
00156   virtual void set_index(imatrix&,int& ii);
00157 };
00158 
00163 class funnel_init_df1b2vector : public funnel_init_var, public df1b2vector
00164 {
00165   const df1b2vector * p;
00166   //const df1b2_init_vector * p;
00167 public:
00168   funnel_init_df1b2vector()
00169     { p = 0; }
00170   ~funnel_init_df1b2vector();
00171   int nvar_calc(void);
00172   //funnel_init_df1b2vector(const df1b2_init_vector & x);
00173   funnel_init_df1b2vector(const df1b2vector & x);
00174   virtual void xinit(init_df1b2vector&,int& ii);
00175   virtual void xinit(dvector&, int&){ cout << "here"<< endl;}
00176   virtual void set_value(const init_df1b2vector&,const int& ii,
00177     const df1b2variable&);
00178   virtual void set_value(const init_df1b2vector&, const int&)
00179     { cout << "here"<< endl;}
00180   virtual void set_index(imatrix&,int& ii);
00181   virtual void allocate(void);
00182 };
00183 
00188 class funnel_init_df1b2matrix : public funnel_init_var, public df1b2matrix
00189 {
00190   const df1b2matrix* p;
00191   //const df1b2_init_vector * p;
00192 public:
00193   int nvar_calc(void);
00194   //funnel_init_df1b2vector(const df1b2_init_vector & x);
00195   funnel_init_df1b2matrix(const df1b2matrix & x);
00196   virtual void xinit(init_df1b2vector&,int& ii);
00197   virtual void xinit(dvector&, int&){ cout << "here"<< endl;}
00198   virtual void set_value(const init_df1b2vector&,const int& ii,
00199     const df1b2variable&);
00200   virtual void set_value(const init_df1b2vector&, const int&)
00201     { cout << "here"<< endl;}
00202   virtual void set_index(imatrix&,int& ii);
00203 };
00204 #endif  //  #if !defined(__DF1B2FNL__)