Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LinearPenaltyFunction.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/LinearPenaltyFunction.hh
11 /// @author Dominik Gront
12 
13 
15 #include <core/types.hh>
16 
17 // C++ Headers
18 #include <cmath>
19 #include <iostream>
20 
21 
22 namespace core {
23 namespace scoring {
24 namespace constraints {
25 
26 Real
28 
29  Real dev = fabs(x-x_middle_);
30  if ( dev <= half_width_ ) {
31  return well_depth_;
32  }
33  return well_depth_ + slope_ * (dev-half_width_);
34 }
35 
36 Real
37 LinearPenaltyFunction::dfunc( Real const /*x*/ ) const
38 {
39  return 0.0;
40 }
41 
42 void
43 LinearPenaltyFunction::read_data( std::istream& in ) {
44  in >> x_middle_ >> well_depth_ >> half_width_ >> slope_;
45 }
46 
47 void
48 LinearPenaltyFunction::show_definition( std::ostream &out ) const {
49  out << "LINEAR_PENALTY " << x_middle_ << " " << well_depth_ << " " << half_width_ <<
50  " " << slope_ << std::endl;
51 }
52 
53 Size
54 LinearPenaltyFunction::show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold) const {
55 
56  if (verbose_level > 100 ) {
57  out << "LINEAR_PENALTY " << ( x < x_middle_ ) << std::endl;
58  }
59  return Func::show_violations( out, x, verbose_level, threshold);
60 }
61 
62 
63 } // namespace constraints
64 } // namespace scoring
65 } // namespace core
66