[ADMB Users] bounded_vector elements

John Sibert sibert at hawaii.edu
Wed Nov 10 15:33:49 PST 2010


Making certain parameters negative in the .dat file when the bounds are 
 >0 probably wouldn't work as you expect.

You could consider the declared parameters (init_number_vector) to be 
"dummies", declare a dvar_vector of the real parameters, and assign 
appropriate values, changing the sign as necessary, to the from the 
init_number_vector to the dvar_vector. You need to do the assignments in 
the PROCEDURE_SECTION because the value of dummy will change after each 
function evaluation. A bit kludgy perhaps, but it would work.

PARAMETER_SECTION
!! const double ub = 2.0;
init_bounded_number dummy(1,n, 0.0, ub);
vector a(1,n);


PROCEDURE_SECTION
   for (int i = 1; i < n/2; i++)
     a(i) = dummy(i);
   for (int i = n/2; i <= n; i++)
     a(i) = -1.0*dummy(i);

You could make it a bit more elegant (and save a loop) by creating a 
vector of constant multipliers (either -1.0 or 1.0) in the .dat file.

John

On 11/10/2010 11:35 AM, Steve Martell wrote:
> Yes read the manual on init_bounded_number_vectors
>
> DATA_SECTION
> init_int n
> // ...
> PARAMETER_SECTION
> // need to create some vectors to hold the bounds and
> // phase numbers
> LOC_CALCS
> dvector lb(1,n);
> dvector ub(1,n);
> ivector ph(1,n);
> // get the desired values into lb,ub,ph somehow
> lb.fill_seqadd(1,0.5);
> ub.fill_seqadd(2,0.5);
> ph.fill_seqadd(1,1);
> END_CALCS
> init_bounded_number_vector a(1,n,lb,ub,ph)
>
> On 2010-11-10, at 1:28 PM, Mollie Brooks wrote:
>
>> I think the answer is probably "no", but is there a way to create a 
>> bounded_vector with different bounds on different elements?
>> I need this because I store my model coefficients in a vector to be 
>> multiplied by the matrix of predictors and I want to restrict some 
>> coefficients to be positive and others negative. Maybe this could go 
>> on a to-do list?
>>
>> I guess I could hack this by restricting the coefficients to be 
>> positive and making certain predictors negative in my .dat file.
>> thanks,
>> Mollie
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at admb-project.org <mailto:Users at admb-project.org>
>> http://lists.admb-project.org/mailman/listinfo/users
>
> Steve Martell
> s.martell at fisheries.ubc.ca <mailto:s.martell at fisheries.ubc.ca>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users
>    

-- 
John Sibert
Emeritus Researcher, SOEST
University of Hawaii at Manoa

Visit the ADMB project http://admb-project.org/




More information about the Users mailing list