Revision 1143 trunk/src/linad99/posfunc.cpp
posfunc.cpp (revision 1143)  

13  13 
#include <fvar.hpp> 
14  14  
15  15 
/** 
16 
Adjoint code for posfun; possibly not used. 

16 
Adjoint code for posfun; possibly not used. 

17 
Retained in source code to support legacy models with userwritten adjoint code. 

17  18 
*/ 
18  19 
double dfposfun(const double &x, const double eps) 
19  20 
{ 
...  ...  
32  33 
} 
33  34  
34  35 
/** 
35 
Adjoint code for posfun; possibly not used. 

36 
*/ 

36 
\brief \copybrief dfposfun(const double&, const double) 

37 
\details \copydetails dfposfun(const double&, const double) 

38 
*/ 

37  39 
double dfposfun1(const double &x, const double eps) 
38  40 
{ 
39  41 
if (x>=eps) 
...  ...  
48  50 
} 
49  51  
50  52 
/** 
51 
Retuns a positive function of the argument \f$x\f$ and sets a penalty for 

52 
\f$x<0\f$. The penalty should be added to the objective function. 

53 
\param x Argument, \f$x\f$. 

54 
\param eps Threshold, \f$\epsilon\f$, 

55 
a double constant containing the minimum allowed value of \f$x\f$. 

56 
\param _pen The penalty value \b incremented by \f$ 0.01(x\epsilon)^2 \f$ 

57 
if \f$x<\epsilon\f$. 

58 
\return \f$\left\{\begin{array} {r@{\quad:\quad}l} 

59 
x\ge\epsilon & x\\ 

60 
x<\epsilon & \frac{\epsilon}{2x/\epsilon} 

61 
\end{array}\right.\f$ 

62 
\ingroup misc 

63 
*/ 

53 
\brief \copybrief posfun(const dvariable&, const double, const prevariable&) 

54 
\details \copydetails posfun(const dvariable&, const double, const prevariable&) 

55 
\ingroup misc 

56 
*/ 

64  57 
double posfun(const double &x, const double eps, const double& _pen) 
65  58 
{ 
66  59 
double& pen=(double&)_pen; 
...  ...  
77  70 
} 
78  71  
79  72 
/** 
80 
Retuns a positive function of the argument \f$x\f$ and sets a penalty for 

81 
\f$x<0\f$. The penalty should be added to the objective function. 

82 
A more coersive version. 

83 
\param x Argument, \f$x\f$. 

84 
\param eps Threshold, \f$\epsilon\f$, 

85 
a double constant containing the minimum allowed value of \f$x\f$. 

86 
\param _pen The penalty value \b incremented by \f$ 0.01(x\epsilon)^3 \f$ 

87 
if \f$x<\epsilon\f$. 

88 
\return \f$\left\{\begin{array} {r@{\quad:\quad}l} 

89 
x\ge\epsilon & x\\ 

90 
x<\epsilon & \frac{\epsilon}{1+x/\epsilon 

91 
+(x/\epsilon)^2 

92 
+(x/\epsilon)^3} 

93 
\end{array}\right.\f$ 

73 
\brief \copybrief posfun2(const dvariable&, const double, const prevariable&) 

74 
\details \copydetails posfun2(const dvariable&, const double, const prevariable&) 

94  75 
\ingroup misc 
95  76 
*/ 
96  77 
double posfun2(const double &x, const double eps, const double& _pen) 
Also available in: Unified diff