[ADMB Users] Missing overloaded operators (+=, -=) in random effects

Mark Payne mpa at aqua.dtu.dk
Tue Apr 5 06:27:47 PDT 2011


Hi,

I have been developing a model in ADMB using the "standard" (ie non-RE) system. However, I now want to start to use this in conjunction with some random effects, but unfortunately, making the switch has thrown up some problems. First, heres a very stripped down version of my tpl file



[mpayne at oleander run]$ cat transient.tpl

DATA_SECTION
  int nboxes
  !!nboxes = 14;
  vector bprodredf(1,nboxes)
  vector dbn(1,nboxes)

PARAMETER_SECTION
  //Fitting parameters
  init_number alpha
  random_effects_vector N15(1,nboxes)

  //Objective function
  objective_function_value nll

PRELIMINARY_CALCS_SECTION
  bprodredf= 1;
  dbn= 1;

PROCEDURE_SECTION
  nll = 0;


FUNCTION dvar_vector SMS(dvar_vector ninv,int t)
  //Source minus sink terms
  //Given a set of (total) nitrogen concentrations, ninv, calculate net
  //production of N at time step t
  dvar_vector bs(1,nboxes);
  bs=0;
  //Sum the invidiual terms
  //bs += bprodredf ;        //Jprod - biological productivity
  bs -= dbn ;              //Si - Sediment burial
  return bs;





If you remove the random_effects_vector line, this builds fine under normal ADMB. However, compiling with the -r line throws the following error



[mpayne at oleander run]$ admb -r transient

*** Parsing: tpl2rem transient

*** Compiling: adcomp -r transient
g++ -c  -O3 -Wno-deprecated  -DOPT_LIB -D__GNUDOS__ -Dlinux -DUSE_LAPLACE -fpermissive -I. -I/home/mpayne/admb/include transient.cpp
transient.cpp: In member function ‘df1b2vector df1b2_parameters::SMS(df1b2vector, int)’:
transient.cpp:123: error: no match for ‘operator-=’ in ‘bs -= ((df1b2_parameters*)this)->df1b2_parameters::<anonymous>.df1b2_pre_parameters::<anonymous>.model_parameters::<anonymous>.model_data::dbn’
/home/mpayne/admb/include/df1b2fun.h:979: note: candidates are: df1b2vector& df1b2vector::operator-=(const df1b2vector&)
/home/mpayne/admb/include/df1b2fun.h:983: note:                 df1b2vector& df1b2vector::operator-=(const df1b2variable&)

Error: Failed to build executable.
[mpayne at oleander run]$




If you replace "bs -= dbn" with "bs = bs + dbn" it compiles correctly. Similar bugs are encountered if you reinstate the currently commented out the commented out line "//bs += bprodredf ;" I interpret this  as meaning that the += and -= operators have not been overloaded in ADMB-RE for this type of variable. Is this a correct interpretation, or am I doing something silly?

Best wishes,

Mark



More information about the Users mailing list