[ADMB Users] FW: less-than issue in ADMB-RE? (probably boneheaded)

Ben Bolker bbolker at gmail.com
Mon May 23 14:17:27 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11-05-26 10:38 AM, Alex Campbell wrote:
> Hi Ben, I just ran into the same issue yesterday. My guess is its just
> not implemented. Along with inv() and fill_seqadd and probably lots of
> other useful functions.
> Strange, but ADMB land is strange! :)
> 

  Thanks for your quick response.

  I  guess I should have waited to post -- while I was waiting for
answers I looked up the definition and found that the following
definition seems to work fine ...

 #include <admodel.h>
 #include <df1b2fun.h>

  int operator < (const df1b2variable& x, double y)
  {
    if (value(x)<value(y))
      return 1;
    else
      return 0;
  }

  I don't know if it will make it through to the list, but I have
included a patch against df1b2loc.cpp in case the developers find it
useful ...

  cheers
    Ben Bolker

> -alex
> 
> On Fri, May 27, 2011 at 12:29 AM, Campbell, Alex
> <Alex.Campbell at deedi.qld.gov.au> wrote:
>>
>> -------------------------------------------
>> From: users-bounces at admb-project.org on behalf of Ben Bolker[SMTP:BBOLKER at GMAIL.COM]
>> Sent: Tuesday, May 24, 2011 6:54:24 AM
>> To: 'users at admb-project.org'
>> Subject: [ADMB Users] less-than issue in ADMB-RE? (probably boneheaded)
>> Auto forwarded by a Rule
>>
>>
>>   I am trying to do something seemingly straightforward, which is not
>> working, therefore I suspect I am doing something stupid.
>>
>>  The random effects model below fails to compile with an error "no
>> match for 'operator<' ..."
>>
>>  The critical lines of code are two loops where I set a minimum value
>> on variables, e.g.
>>
>>   for (int i=1; i<=nobs; i++)
>>        if (x1(i)<eps1) x1(i)=eps1;
>>
>> and
>>
>>   for (int i=1; i<=nobs; i++)
>>        if (p(i)<eps2) p(i)=eps2;
>>
>> where eps1, eps2 are numbers and x1 and p are vectors (in a previous
>> attempt eps1 and eps2 were just numeric constants instead).
>>
>>   An earlier non-random-effects version of this code worked fine.
>>
>>   I would guess that the error message is telling me that the less-than
>> operator hasn't been defined for the data types I'm comparing, but at
>> the moment I'm finding easier to believe that I'm doing something stupid
>> than that "<" is not defined for the comparison of a (double precision?)
>> vector element and a scalar or numeric constant ...
>>
>>   Alternatively, has anyone written an implementation of R's 'pmax()'
>> function that would work here?
>>
>>  Error messages and full TPL file included below.  I am also happy to
>> receive stylistic/coding suggestions ...
>>
>>  Apologies for any mangling of the line spacing by my mail client.
>>
>>  cheers
>>    Ben Bolker
>>
>>
>> ==================
>>
>> *** adcomp -r weibR1_gen
>> g++ -c -O3 -Wno-deprecated -D__GNUDOS__ -Dlinux -DOPT_LIB -DUSE_LAPLACE
>> -fpermissive -I. -I/usr/local/admb/include weibR1_gen.cpp
>> weibR1_gen.cpp: In member function ‘virtual void
>> df1b2_parameters::user_function()’:
>> weibR1_gen.cpp:165: error: no match for ‘operator<’ in
>> ‘((df1b2_parameters*)this)->df1b2_parameters::x1.df1b2vector::operator()(i)
>> < ((df1b2_parameters*)this)->df1b2_parameters::eps1’
>> /usr/local/admb/include/fvar.hpp:7862: note: candidates are: int
>> operator<(double, const prevariable&)
>> /usr/local/admb/include/df32fun.h:289: note:                 int
>> operator<(const df3_two_variable&, double)
>> /usr/local/admb/include/df32fun.h:295: note:                 int
>> operator<(const df3_two_variable&, const df3_two_variable&)
>> weibR1_gen.cpp:169: error: no match for ‘operator<’ in
>> ‘((df1b2_parameters*)this)->df1b2_parameters::p.df1b2vector::operator()(i)
>> < ((df1b2_parameters*)this)->df1b2_parameters::eps2’
>> /usr/local/admb/include/fvar.hpp:7862: note: candidates are: int
>> operator<(double, const prevariable&)
>> /usr/local/admb/include/df32fun.h:289: note:                 int
>> operator<(const df3_two_variable&, double)
>> /usr/local/admb/include/df32fun.h:295: note:                 int
>> operator<(const df3_two_variable&, const df3_two_variable&)
>>
>>
>>
>> ============================
>> DATA_SECTION
>>
>>  init_int nobs
>>  init_int nttt
>>  init_matrix ttt(1,7599,1,4)
>>  init_vector eclosed(1,7599)
>>  init_vector avail(1,7599)
>>  init_vector hour(1,7599)
>>  init_vector prevhour(1,7599)
>>  init_ivector lineind(1,7599)
>>  init_ivector vialind(1,7599)
>>
>> PARAMETER_SECTION
>>
>>  objective_function_value f
>>  init_vector tttcoefs(1,4)
>>  init_number logk
>>  init_bounded_number starthour(210,215.99)
>>  init_bounded_number sigma_L(1e-04,5)
>>  init_bounded_number sigma_V(1e-04,5)
>>  vector loglam(1,nobs)
>>  vector lambda(1,nobs)
>>  vector x1(1,nobs)
>>  vector x2(1,nobs)
>>  vector p(1,nobs)
>>  vector u_L_sc(1,nobs)
>>  vector u_V_sc(1,nobs)
>>  number eps1
>>  number eps2
>>  random_effects_vector u_L(1,8)
>>  random_effects_vector u_V(1,447)
>>
>> LOCAL_CALCS
>>
>>   eps1=0.001;
>>   eps2=1.0e-6;
>>
>> PROCEDURE_SECTION
>>
>>     loglam=ttt*tttcoefs;
>>     for (int i=1; i<=nobs; i++) {
>>       loglam[i] += u_L_sc[lineind[i]]+u_V_sc[vialind[i]];
>>     }
>>     lambda=exp(loglam);
>>     x1=prevhour-starthour;
>>     for (int i=1; i<=nobs; i++)
>>        if (x1(i)<eps1) x1(i)=eps1;
>>     x2=hour-starthour;
>> p=exp(-pow(elem_div(x1,lambda),exp(logk)))-exp(-pow(elem_div(x2,lambda),exp(logk)));
>>     for (int i=1; i<=nobs; i++)
>>        if (p(i)<eps2) p(i)=eps2;
>>     f-=sum(elem_prod(eclosed,log(p))+elem_prod((avail-eclosed),log(1-p)));
>>
>>
>> TOP_OF_MAIN_SECTION
>>     arrmblsize = 2147483647;
>>
>> _______________________________________________
>> Users mailing list
>> Users at admb-project.org
>> http://lists.admb-project.org/mailman/listinfo/users
>>
>>
>> ********************************DISCLAIMER****************************
>> The information contained in the above e-mail message or messages
>> (which includes any attachments) is confidential and may be legally
>> privileged.  It is intended only for the use of the person or entity
>> to which it is addressed.  If you are not the addressee any form of
>> disclosure, copying, modification, distribution or any action taken
>> or omitted in reliance on the information is unauthorised.  Opinions
>> contained in the message(s) do not necessarily reflect the opinions
>> of the Queensland Government and its authorities.  If you received
>> this communication in error, please notify the sender immediately
>> and delete it from your computer system network.
>>
>>
>>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3azucACgkQc5UpGjwzenN7CACfeE0DxXXeqRGMr+VqukqwZwwl
5rIAn3gIXq+UFNVmwIteGm3Cqw+FylZ8
=KImu
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lessthan-patch.txt
URL: <http://lists.admb-project.org/pipermail/users/attachments/20110523/6e36bf88/attachment.txt>


More information about the Users mailing list