Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SigmoidFunc.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file src/core/scoring/constraints/SigmoidFunc.hh
11 /// @brief Definition for functions used in definition of constraints.
12 /// @author Hetu Kamisetty
13 
14 
16 #include <math.h>
17 
18 #include <core/types.hh>
19 
20 #include <utility/pointer/ReferenceCount.hh>
21 
22 // AUTO-REMOVED #include <numeric/angle.functions.hh>
23 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
24 // AUTO-REMOVED #include <basic/Tracer.hh>
25 
26 #include <sstream>
27 
28 
29 // C++ Headers
30 
31 
32 namespace core {
33 namespace scoring {
34 namespace constraints {
35 
36 Real
37 SigmoidFunc::func( Real const x ) const
38 {
39  Real const z = slope_*( x-x0_ );
40  return (1/(1+exp(-z)) - 0.5); // so at x0_, you get 0
41 }
42 
43 Real
44 SigmoidFunc::dfunc( Real const x ) const
45 {
46  Real fval = 1/(1+exp(-slope_*( x-x0_ )));
47  return fval*fval*exp(-slope_*(x-x0_));
48 }
49 
50 void
51 SigmoidFunc::read_data( std::istream& in ) {
52  in >> x0_ >> slope_;
53 }
54 
55 void
56 SigmoidFunc::show_definition( std::ostream &out ) const {
57  out << "SIGMOID " << x0_ << " " << slope_ << std::endl;
58 }
59 
60 Size
61 SigmoidFunc::show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold) const {
62  //I don't know what to put here.
63  if (verbose_level > 100 ) {
64  out << "HARM " << ( x - x0_ )/slope_ << std::endl;
65  } else if (verbose_level > 70 ) {
66  if ( x < x0_ && ( this->func(x) > threshold ) ) out << "-";
67  else if ( x > x0_ && ( this->func(x) > threshold )) out << "+";
68  else out << ".";
69  }
70  return Func::show_violations( out, x, verbose_level, threshold);
71 }
72 
73 } // namespace constraints
74 } // namespace scoring
75 } // namespace core
76