ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
posfunc.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
7 
13 #include <fvar.hpp>
14 
19 double dfposfun(const double &x, const double eps)
20 {
21  if (x>=eps)
22  {
23  return 1;
24  }
25  else
26  {
27  //double z=eps/(2-x/eps);
28  double dfx=1.0/square(2-x/eps);
29  //double z= 0.5*eps*(1.0+1.0/(3.0-2.0*x/eps));
30  //double dfx=1.0/square(3.0-2.0*x/eps);
31  return dfx;
32  }
33 }
34 
39 double dfposfun1(const double &x, const double eps)
40 {
41  if (x>=eps)
42  {
43  return 0;
44  }
45  else
46  {
47  double dfx=.02*(x-eps);
48  return dfx;
49  }
50 }
51 
57 double posfun(const double &x, const double eps, const double& _pen)
58 {
59  double& pen=(double&)_pen;
60  if (x>=eps)
61  {
62  return x;
63  }
64  else
65  {
66  pen+=.01*square(x-eps);
67  //return 0.5*eps*(1.0+1.0/(3.0-2.0*x/eps));
68  return eps/(2.0-x/eps);
69  }
70 }
71 
77 double posfun2(const double &x, const double eps, const double& _pen)
78 {
79  double& pen=(double&)_pen;
80  if (x>=eps)
81  {
82  return x;
83  }
84  else
85  {
86  double y=eps-x;
87  double tmp=y/eps;
88  double tmp2=tmp*tmp;
89  double tmp3=tmp2*tmp;
90  pen+=.01*cube(tmp3);
91  return eps/(1.0+tmp+tmp2+tmp3);
92  }
93 }
double dfposfun(const double &x, const double eps)
Adjoint code for posfun; possibly not used.
Definition: posfunc.cpp:19
#define x
d3_array cube(const d3_array &m)
Description not yet available.
Definition: d3arr5.cpp:17
double dfposfun1(const double &x, const double eps)
Adjoint code for posfun; possibly not used.
Definition: posfunc.cpp:39
dvar_vector posfun(const dvar_vector &x, double eps, const prevariable &pen)
Description not yet available.
Definition: fvar_a62.cpp:17
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
double eps
Definition: ftweak.cpp:13
dvariable posfun2(const dvariable &x, const double eps, const prevariable &pen)
Retuns a positive function of the argument and sets a penalty for .
Definition: posfunv.cpp:88
double square(const double value)
Return square of value; constant object.
Definition: d3arr4.cpp:16