admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

Fix random effects type with bounds #76

Closed johnoel closed 11 months ago

johnoel commented 7 years ago

https://groups.google.com/a/admb-project.org/d/msg/users/pB7SaJXyEp4/s7D3LyYzBgAJ

johnoel commented 5 years ago

See funnel_init_df1b2variable::set_value

johnoel commented 5 years ago

Below is a possible workaround, this should be discussed at the next developers workshop.

diff --git a/src/df1b2-separable/adrndeff.h b/src/df1b2-separable/adrndeff.h
index 89c439ca..bad7178e 100644
--- a/src/df1b2-separable/adrndeff.h
+++ b/src/df1b2-separable/adrndeff.h
@@ -97,6 +97,14 @@ class random_effects_bounded_vector : public param_init_bounded_vector
   virtual void set_random_effects_inactive();
   virtual void set_only_random_effects_active();
   virtual void set_only_random_effects_inactive();
+public:
+  void sd_scale(const dvector& v, const dvector& x, const int& ii)
+  {
+    int length = static_cast<int>(size() - 1);
+    dvector x2(v.indexmin(), ii + length);
+    x2 = 1;
+    param_init_bounded_vector::sd_scale(v, x2, ii);
+  }
 };

 /**
diff --git a/src/df1b2-separable/df1b2fnl.cpp b/src/df1b2-separable/df1b2fnl.cpp
index 293b24e3..c59d0206 100644
--- a/src/df1b2-separable/df1b2fnl.cpp
+++ b/src/df1b2-separable/df1b2fnl.cpp
@@ -553,7 +553,7 @@ void funnel_init_df1b2variable::set_value(const init_df1b2vector& _x,
         int uf=-1;
         if (ind_index>0)
         {
-          uf=l->used_flags(ind_index);
+          //uf=l->used_flags(ind_index);
         }
         if (uf > 1 && (l->hesstype ==2))
         {
diff --git a/src/nh99/admodel.h b/src/nh99/admodel.h
index 4938663d..30adc425 100644
--- a/src/nh99/admodel.h
+++ b/src/nh99/admodel.h
@@ -1128,6 +1128,8 @@ public:
   void pvm_pack(void){::pvm_pack(*this);}
   void pvm_unpack(void){::pvm_unpack(*this);}
 #endif
+
+  friend class random_effects_bounded_vector;
 };