Revision 1209
trunk/src/linad99/posfunv.cpp (revision 1209)  

12  12 
#include <fvar.hpp> 
13  13  
14  14 
/**Retuns a positive function of the argument \f$x\f$ and sets a penalty for 
15 
\f$x<0\f$. The penalty should be added to the objective function. 

15 
\f$x<0\f$. This function will add the penalty (when applicable) onto the existing value of pen. 

16 
Somewhere in the code after using posfun, the penalty should be added to the objective function. 

16  17 
This function is intended to keep model state variables in the positive 
17 
domain to avoid mathematical errors. See Section 2.3 of the ADMB Manual. 

18 
domain to avoid mathematical errors. See Section 2.3 of the ADMB Manual. (Note, the returned value is less than \f$\epsilon\f$.)


18  19 
\param x Argument, \f$x\f$. 
19  20 
\param eps Threshold, \f$\epsilon\f$, 
20 
a double constant containing the minimum allowed value of \f$x\f$.


21 
a double constant. 

21  22 
The choice of a value for \f$\epsilon\f$ is model dependent, 
22 
but \f$10^{3}\f$ is sufficient for some applications.


23 
but \f$10^{3}\f$ is sufficient for some applications. 

23  24 
\param _pen The penalty value \b incremented by \f$ 0.01(x\epsilon)^2 \f$ 
24  25 
if \f$x<\epsilon\f$. 
25  26 
\return \f$\left\{\begin{array} {r@{\quad:\quad}l} 
Also available in: Unified diff