[ADMB Users] How to use vector elements in PARAMETER_SECTION
Jim Ianelli - NOAA Federal
jim.ianelli at noaa.gov
Tue Apr 2 17:16:15 PDT 2013
hi!
Great to see you the other week!
Not such a beginner issue!
Well it might seem like it should be obvious but without going into too
much detail, ADMB parameter bounds (which I try to avoid whenever possible)
are set up a little differently. Short answer, I don't know how to do
exactly what you want (others may know).
On the other hand, perhaps if you think about it from a vector of
parameters, x dimensioned 1 to np things can become efficient for you.
In the data section you can read in vectors of lower bounds (lb_x) and
upper bounds (ub_x) and even an ivector of phases from which you wish to
turn each element on (phase_x). Then the code below sets any number of
parameters with the same number of ADMB lines (I think 3 total, 4 with
phases vector)
PARAMETER_SECTION
...
init_bounded_number_vector x(1,np,1,lb_x,ub_x,phase_x)
So this becomes economical perhaps in a different way than what you are
thinking.
Cheers,
Jim
On Tue, Apr 2, 2013 at 4:40 PM, Steve Teo - NOAA Federal <steve.teo at noaa.gov
> wrote:
> Steve,
>
> That's not it. I am not trying to declare the dimensions of a vector. I
> am just trying to set up the bounds of a bounded parameter in the
> PARM_SECTION. I know that if I declare a double first and then use that
> double in the PARM_SECTION to set bounds, it works. But that is ugly
> coding (6 lines and 3 variable names extra per parm). So I am wondering if
> there is an elegant way of calling an element in the vector directly when
> setting up the bounds and phases. If there is not, that's fine - just
> wanted to know. Thanks.
>
> Steve
>
>
>
>
> On Tue, Apr 2, 2013 at 4:14 PM, Martell, Steven <
> s.martell at fisheries.ubc.ca> wrote:
>
>> You need to use vectors to declare the dimensions of a vector. your
>> trying to use double precision numbers to delcare the dimensions:
>>
>> try:
>>
>> DATA_SECTION
>> init_ivector x_input(1,2)
>> int x_lb
>>
>> !! x_lb=x_input(1);
>>
>> PARA
>> init_bounded_number x(x_input(1),x_input(2))..
>>
>> S
>> On 2013-04-02, at 3:08 PM, Steve Teo - NOAA Federal <steve.teo at noaa.gov>
>> wrote:
>>
>> > Hi,
>> >
>> > Beginner with ADMB here. I am trying to read in a vector, which I then
>> use to set up the bounds in my parameter section. The code runs if I
>> initialize the elements as numbers before I use them. But it chokes if I
>> directly reference the vector element. See below for example code.
>> >
>> > Is there an elegant way of doing this without having to initialize lots
>> of numbers just to set up the bounds?
>> >
>> > DATA_SECTION
>> > init_vector x_input(1,2)
>> >
>> > number x_lb
>> > number x_ub
>> > !!x_lb = x_input[1];
>> > !!x_ub = x_input[2];
>> >
>> > PARAMETER_SECTION
>> > init_bounded_number x(x_lb,x_ub) // works
>> > init_bounded_number x(x_input[1], x_input[2]) // does NOT work
>> >
>> > Thanks.
>> >
>> > Steve
>> > _______________________________________________
>> > Users mailing list
>> > Users at admb-project.org
>> > http://lists.admb-project.org/mailman/listinfo/users
>>
>>
>
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users
>
>
--
James Ianelli
NMFS/NOAA Building 4
7600 Sand Pt Way NE
Seattle WA 98115
206 526 6510
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20130402/4454baaa/attachment.html>
More information about the Users
mailing list