[ADMB Users] Summary: Fwd: no assignment operator for init_bounded_number_vector
Larry Jacobson
larry.jacobson at noaa.gov
Mon Jul 22 05:50:21 PDT 2013
1) I was trying to initialize an init_bounded_number_vector parameter
called logsrx in the initialization section but there was no assignment
operator.
2) Chris Grandin (many thanks) knew just what to do and suggested the
following code:
> logsrx.set_initial_value(srx_init);
Note that it is important to make sure the argument with the initial value is a double so there is no harm in using:
> logsrx.set_initial_value(value(srx_init));
3) Rick Methot pointed out that assignment to many classes (but not bounded_number_vectors) can be managed using the value function only.
3) I couldn't find any documentation re set_initial_value but Chris mentioned that "The definition is in src/nh99/mcmcvar.h on line 2489."
Cheers!
and later:
> The equals sign and value() will work for most classes, but the param_init_bounded_number_vector class has no assignment operator overloaded so you have to do it with set_initial_value. The definition is in src/nh99/mcmcvar.h on line 2489
> Chris
-------- Original Message --------
Subject: no assignment operator for init_bounded_number_vector
Date: Fri, 19 Jul 2013 13:43:01 -0400
From: Larry Jacobson <larry.jacobson at noaa.gov>
Reply-To: Larry.Jacobson at noaa.gov
To: ADMB Users <Users at admb-project.org>
1) The idea is to ask the user for an arithmetic starting value which is
used to initialize a log scale parameter (unbeknownst to the user who
does not think in logs).
2) I have a vector of doubles declared in the DATA_SECTION called
srx_init(1,2). See line 193 in attached tpl file.
3) I declare a bounded_number_vector in the PARAMETER_SECTION called
logsrx(1,2). See line 283 in tpl file.
4) In the PRELIMINARY_CALCS_SECTION (line 410) I want to initialize the
bounded_number_vector with code like:
logsrx=log(srx_init);
5) However, the compiler complains:
C:\Users\ljacobso\Documents\Assessments\Shrimp_2013\CSA-v4\july18_2013>cl /c
/EHsc /DUSE_LAPLACE /DWIN32 /DSAFE_ALL /D
__MSVC32__=8 /I. /I"C:\Program Files\ADMB"\include /I"C:\Program
Files\ADMB"\contrib\include csav41.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01
for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
csav41.cpp
csav41.cpp(362) : error C2679: binary '=' : no operator found which
takes a right-hand operand of type 'dvector' (or the
re is no acceptable conversion)
C:\Program Files\ADMB\include\admodel.h(2700): could be
'param_init_bounded_number_vector ¶m_init_bounded_nu
mber_vector::operator =(const param_init_bounded_number_vector &)'
while trying to match the argument list
'(param_init_bounded_number_vector, dvector)'
6) I've tried doing the assignment in a loop like:
for (i=1;i<=nsurveys;i++) logsrx(i)=log(srx_init(i));
using an intermediate dvar_vector like:
dvar_vector temp(1,2)=srx_init;
logsrxi=srxinit;
and many other hacks (trying to find a combination of data types with an
assignment operator).
6) Any ideas or suggestions?
Cheers and thanks!
--
**********************
Opinions that may be expressed herein are my own
and not official positions of NOAA or the National
Marine Fisheries Service.
**********************
Larry Jacobson
National Marine Fisheries Service
Northeast Fisheries Science Center
166 Water Street
Woods Hole, MA 02543-1026
Voice: 508-495-2317
Fax: 508-495-2393
E-mail:larry.jacobson at noaa.gov
**********************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20130722/c808aa6f/attachment.html>
More information about the Users
mailing list