[Developers] checking for uninitialized parameters
John Sibert
sibert at hawaii.edu
Wed Feb 20 15:05:06 PST 2013
Dave recently sent around some code to check for incorrectly variables
in an admb template. The code is integrated into the derivative checker.
To use it, run you application to check the derivatives before the first
function evaluation; ie "my_app -dd 0". Enter '0' a the the prompt "to
check for unitialized variables enter 0)".
This code is currently only available for those who build their own admb
libraries from source in. Check out revision 759. It will eventually
find its way into the next stable release. It has not been extensively
tested.
Incorrectly initialized variables can lead to unpredictable results. An
obvious example is:
> PARAMETER_SECTION
> init_vector x(1,5)
> number ssum
> objective_function_value f
> PROCEDURE_SECTION
> ssum+=norm2(x-1.0);
> f=ssum;
The first time the code in the PROCEDURE_SECTION is executed, the value
of ssum is not guaranteed to be zero. A more correct version would be:
> PROCEDURE_SECTION
> ssum = 0.0;
> ssum+=norm2(x-1.0);
> f=ssum;
Thanks to an ADMB user for bringing this to our attention and to Dave
for fixing it.
Cheers,
John
--
John Sibert
Emeritus Researcher, SOEST
University of Hawaii at Manoa
Honolulu HI (GMT-10)
808-294-3842
Visit the ADMB project http://admb-project.org/
More information about the Developers
mailing list