Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ScalarWeightedFunc.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/ScalarWeightedFunc.cc
11 /// @brief Weighted constraint function that reweights other constraints
12 /// by a constant scalar value.
13 /// @author James Thompson, Greg Taylor
14 
15 
18 
19 #include <core/types.hh>
20 
21 #include <utility/pointer/ReferenceCount.hh>
22 
23 // AUTO-REMOVED #include <numeric/angle.functions.hh>
24 // AUTO-REMOVED #include <basic/Tracer.hh>
25 
26 // C++ Headers
27 // AUTO-REMOVED #include <string>
28 
29 #include <sstream>
30 #include <iostream>
31 #include <string>
32 
33 
34 namespace core {
35 namespace scoring {
36 namespace constraints {
37 
39 
40  Real
41  ScalarWeightedFunc::func( Real const x ) const
42  {
43  return func_to_weight_->func( x ) * weight_;
44  }
45 
46 
47 
48  Real
50  {
51  return func_to_weight_->dfunc( x ) * weight_;
52  }
53 
54  void
55  ScalarWeightedFunc::read_data( std::istream& in )
56  {
57  in >> weight_;
58 
59  FuncFactory func_factory;
60  std::string func_type;
61  in >> func_type;
62  func_to_weight_ = func_factory.func_types_[ func_type ]->clone();
63  func_to_weight_->read_data( in );
64  }
65 
66 
67  void
68  ScalarWeightedFunc::show_definition( std::ostream &out ) const
69  {
70  out << "SCALARWEIGHTEDFUNC weight: " << weight_ << " func_to_weight: ";
71  func_to_weight_->show_definition(out);
72  }
73 
74  Size
75  ScalarWeightedFunc::show_violations(std::ostream &out, Real x, Size verbose_level, Real threshold) const
76  {
77  out << "SCALARWEIGHTEDFUNC with weight: " << weight_ << std::endl;
78  func_to_weight_->show_definition(out);
79  out << " with verbose_level " << verbose_level << ", threshold " << threshold << " and weighted_score " << ScalarWeightedFunc::func(x) << std::endl;
80  return func_to_weight_->show_violations(out,x,verbose_level,threshold);
81  }
82 
83 
84 } // namespace constraints
85 } // namespace scoring
86 } // namespace core
87