Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TopOutFunc.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/TopOutFunc.hh
11 /// @brief Implementation of phenix "top-out" function
12 /// Similar to Geman-McClure: harmonic near 'x0_', flat past 'limit_'
13 /// @author Frank DiMaio
14 
15 
17 #include <core/types.hh>
18 #include <utility/pointer/ReferenceCount.hh>
19 
20 #include <cmath>
21 #include <sstream>
22 
23 // C++ Headers
24 namespace core {
25 namespace scoring {
26 namespace constraints {
27 
28 Real
29 TopOutFunc::func( Real const x ) const {
30  Real xoff = x-x0_;
31  Real top = weight_ * limit_ * limit_;
32  Real score = top * (1.0 - exp(-weight_*xoff*xoff/top));
33  return score;
34 }
35 
36 Real
37 TopOutFunc::dfunc( Real const x ) const {
38  Real xoff = x-x0_;
39  Real top = weight_ * limit_ * limit_;
40  Real grad = 2.0 * weight_ * xoff * exp(-(weight_*xoff*xoff)/top);
41  return (grad);
42 }
43 
44 void
45 TopOutFunc::read_data( std::istream& in ) {
46  in >> weight_ >> x0_ >> limit_;
47 }
48 
49 void
50 TopOutFunc::show_definition( std::ostream &out ) const {
51  out << "TOPOUT " << weight_ << " " << x0_ << " " << limit_ << std::endl;
52 }
53 
54 Size
55 TopOutFunc::show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold) const {
56  if (verbose_level > 100 ) {
57  out << "TOPOUT " << func(x) << std::endl;
58  }
59  return Func::show_violations( out, x, verbose_level, threshold);
60 }
61 
62 } // namespace constraints
63 } // namespace scoring
64 } // namespace core
65