00001 #ifndef LOG_SIGMOID_DEC_2007 00002 #define LOG_SIGMOID_DEC_2007 00003 00004 00005 //currently LogSigMoid(t, a) is taking the form -log(1+exp(a*(t-x))) 00006 class LogSigMoid 00007 { 00008 public: 00009 LogSigMoid() 00010 { 00011 strictness_ = 0; 00012 threshold_ = 0; 00013 } 00014 00015 LogSigMoid(double strictness, double threshold): strictness_(strictness), threshold_(threshold) 00016 {} 00017 00018 double funcValue(double x) //compute function value 00019 { 00020 return -log(1+exp(strictness_*(threshold_-x))); 00021 } 00022 00023 double firstDerivative(double x) //compute first derivative 00024 { 00025 // first derivative is of the form 00026 // a*exp(a*(t-x))/(1+exp(a*(t-x))) 00027 return strictness_*exp(strictness_*(threshold_-x))/(1+exp(strictness_*(threshold_-x))); 00028 } 00029 00030 double solveConstraint(double th) // solve constraint of the form logSigmoid(a, t, x) > th 00031 { 00032 if (th >=0 ) return NOSOL; 00033 00034 double root = threshold_ - log(exp(-1*th) - 1)/strictness_; 00035 00036 return root; 00037 } 00038 public: 00039 double strictness_; // x > t if strictness_ > 0, x < t if strictness < 0 00040 double threshold_; // 00041 }; 00042 #endif