Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BoundConstraint.hh
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 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
6 // vi: set ts=2 noet:
7 //
8 // (c) Copyright Rosetta Commons Member Institutions.
9 // (c) This file is part of the Rosetta software suite and is made available under license.
10 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
11 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
12 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
13 
14 /// @file
15 /// @brief
16 /// @author Oliver Lange
17 
18 #ifndef INCLUDED_core_scoring_constraints_BoundConstraint_hh
19 #define INCLUDED_core_scoring_constraints_BoundConstraint_hh
20 
22 //#include <core/scoring/constraints/Constraint.hh>
23 //#include <core/scoring/constraints/AtomPairConstraint.hh>
25 #include <core/types.hh>
26 #include <basic/basic.hh>
27 
28 
29 // C++ Headers
30 //#include <cstdlib>
31 #include <iostream>
32 
33 //#include <map>
34 //#include <utility>
35 
36 
37 namespace core {
38 namespace scoring {
39 namespace constraints {
40 
41 ///
42 class BoundFunc : public Func {
43 public:
44  BoundFunc( Real const lb, Real const ub, Real sd, std::string type ): lb_( lb ), ub_( ub ), sd_ ( sd ), rswitch_( 0.5 ), type_( type ) {}
46  : lb_( lb ), ub_( ub ), sd_ ( sd ), rswitch_( rswitch ), type_( type ) {}
47 
48  virtual
49  FuncOP clone() const { return new BoundFunc( *this ); };
50 
51  virtual
52  void read_data( std::istream& );
53 
54  virtual
55  Real
56  func( Real const x ) const;
57 
58  virtual
59  Real
60  dfunc( Real const x ) const;
61 
62  virtual
63  void show_definition( std::ostream &out ) const;
64 
65  virtual
66  Size show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold = 1 ) const;
67 
68  Real lb() const { return lb_; }
69  Real ub() const { return ub_; }
70  Real sd() const { return sd_; }
71  Real rswitch() const {return rswitch_;}
72  std::string type() const {return type_;}
73 
74 private:
80 };
81 
82 
83 /// a variant of the bound func that is periodic
85 {
86 public:
87  typedef BoundFunc parent;
88 
89 public:
91  Real const lb, Real const ub, Real sd, std::string type, Real const periodicity_in
92  ) :
93  BoundFunc(
94  basic::periodic_range(lb, periodicity_in),
95  basic::periodic_range(ub,periodicity_in),
96  sd, type
97  ),
98  periodicity_( periodicity_in )
99  {}
100 
101  FuncOP clone() const { return new PeriodicBoundFunc( *this ); };
102 
103  void read_data( std::istream& );
104 
105  Real func(Real const x ) const
106  {
107  return parent::func( basic::periodic_range(x , periodicity_ ) );
108  }
109 
110  Real dfunc( Real const x ) const
111  {
112  return parent::dfunc( basic::periodic_range(x , periodicity_ ) );
113  }
114 
115  void show_definition( std::ostream& out ) const;
116 
117  virtual Size show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold = 1) const
118  {
119  return parent::show_violations( out, basic::periodic_range( x, periodicity_ ), verbose_level, threshold );
120  }
121 
122 private:
124 
125 };
126 
127 
128 /// a variant of the bound func that is periodic
130 {
131 public:
132  typedef BoundFunc parent;
133 
134 public:
136  Real const lb, Real const ub, Real sd, std::string type, Real const periodicity_in, Real const offset_in
137  ) :
138  BoundFunc(
139  lb,ub,
140  sd, type
141  ),
142  periodicity_( periodicity_in ),
143  offset_( offset_in )
144  {}
145 
146  FuncOP clone() const { return new OffsetPeriodicBoundFunc( *this ); };
147 
148  void read_data( std::istream& );
149 
150  Real func(Real const x ) const
151  {
152  return parent::func( basic::periodic_range(x - offset_, periodicity_ ) );
153  }
154 
155  Real dfunc( Real const x ) const
156  {
157  return parent::dfunc( basic::periodic_range(x - offset_, periodicity_ ) );
158  }
159 
160  void show_definition( std::ostream& out ) const;
161 
162  virtual Size show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold = 1) const
163  {
164  return parent::show_violations( out, basic::periodic_range( x, periodicity_ ), verbose_level, threshold );
165  }
166 
167 
168 private:
171 
172 };
173 
174 
175 } //constraints
176 } //scoring
177 } //core
178 
179 #endif
180 // (c) This file is part of the Rosetta software suite and is made available under license.
181 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
182 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
183 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
184 
185 /// @file
186 /// @brief
187 /// @author Oliver Lange
188 
189 #ifndef INCLUDED_core_scoring_constraints_BoundConstraint_hh
190 #define INCLUDED_core_scoring_constraints_BoundConstraint_hh
191 
193 //#include <core/scoring/constraints/Constraint.hh>
194 //#include <core/scoring/constraints/AtomPairConstraint.hh>
196 #include <core/types.hh>
197 #include <basic/basic.hh>
198 
199 
200 // C++ Headers
201 //#include <cstdlib>
202 #include <iostream>
203 
204 //#include <map>
205 //#include <utility>
206 
207 
208 namespace core {
209 namespace scoring {
210 namespace constraints {
211 
212 ///
213 class BoundFunc : public Func {
214 public:
215  BoundFunc( Real const lb, Real const ub, Real sd, std::string type ): lb_( lb ), ub_( ub ), sd_ ( sd ), rswitch_( 0.5 ), type_( type ) {}
216  BoundFunc( Real const lb, Real const ub, Real sd, Real rswitch, std::string type )
217  : lb_( lb ), ub_( ub ), sd_ ( sd ), rswitch_( rswitch ), type_( type ) {}
218 
219  virtual
220  FuncOP clone() const { return new BoundFunc( *this ); };
221 
222  virtual
223  void read_data( std::istream& );
224 
225  virtual
226  Real
227  func( Real const x ) const;
228 
229  virtual
230  Real
231  dfunc( Real const x ) const;
232 
233  virtual
234  void show_definition( std::ostream &out ) const;
235 
236  virtual
237  Size show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold = 1 ) const;
238 
239  Real lb() const { return lb_; }
240  Real ub() const { return ub_; }
241  Real sd() const { return sd_; }
242 
243 private:
244  Real lb_;
245  Real ub_;
246  Real sd_;
247  Real rswitch_;
249 };
250 
251 
252 /// a variant of the bound func that is periodic
253 class PeriodicBoundFunc : public BoundFunc
254 {
255 public:
256  typedef BoundFunc parent;
257 
258 public:
260  Real const lb, Real const ub, Real sd, std::string type, Real const periodicity_in
261  ) :
262  BoundFunc(
263  basic::periodic_range(lb, periodicity_in),
264  basic::periodic_range(ub,periodicity_in),
265  sd, type
266  ),
267  periodicity_( periodicity_in )
268  {}
269 
270  FuncOP clone() const { return new PeriodicBoundFunc( *this ); };
271 
272  void read_data( std::istream& );
273 
274  Real func(Real const x ) const
275  {
276  return parent::func( basic::periodic_range(x , periodicity_ ) );
277  }
278 
279  Real dfunc( Real const x ) const
280  {
281  return parent::dfunc( basic::periodic_range(x , periodicity_ ) );
282  }
283 
284  void show_definition( std::ostream& out ) const;
285 
286  virtual Size show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold = 1) const
287  {
288  return parent::show_violations( out, basic::periodic_range( x, periodicity_ ), verbose_level, threshold );
289  }
290 
291 private:
293 
294 };
295 
296 
297 /// a variant of the bound func that is periodic
298 class OffsetPeriodicBoundFunc : public BoundFunc
299 {
300 public:
301  typedef BoundFunc parent;
302 
303 public:
305  Real const lb, Real const ub, Real sd, std::string type, Real const periodicity_in, Real const offset_in
306  ) :
307  BoundFunc(
308  lb,ub,
309  sd, type
310  ),
311  periodicity_( periodicity_in ),
312  offset_( offset_in )
313  {}
314 
315  FuncOP clone() const { return new OffsetPeriodicBoundFunc( *this ); };
316 
317  void read_data( std::istream& );
318 
319  Real func(Real const x ) const
320  {
321  return parent::func( basic::periodic_range(x - offset_, periodicity_ ) );
322  }
323 
324  Real dfunc( Real const x ) const
325  {
326  return parent::dfunc( basic::periodic_range(x - offset_, periodicity_ ) );
327  }
328 
329  void show_definition( std::ostream& out ) const;
330 
331  virtual Size show_violations( std::ostream& out, Real x, Size verbose_level, Real threshold = 1) const
332  {
333  return parent::show_violations( out, basic::periodic_range( x, periodicity_ ), verbose_level, threshold );
334  }
335 
336 private:
338  Real offset_;
339 
340 };
341 
342 
343 } //constraints
344 } //scoring
345 } //core
346 
347 #endif