IMP  2.0.1
The Integrative Modeling Platform
Nuisance.h
Go to the documentation of this file.
1 /**
2  * \file IMP/isd/Nuisance.h
3  * \brief A decorator for nuisance parameters particles
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPISD_NUISANCE_H
9 #define IMPISD_NUISANCE_H
10 
11 #include <IMP/isd/isd_config.h>
12 
13 #include <IMP/PairContainer.h>
14 #include <IMP/SingletonContainer.h>
15 #include <IMP/Decorator.h>
16 #include <IMP/decorator_macros.h>
17 #include <IMP/isd/Nuisance.h>
18 
19 IMPISD_BEGIN_NAMESPACE
20 
21 //! Add nuisance parameter to particle
22 /** The value of the nuisance parameter may express data
23  or theory uncertainty. It can be initialized with or without
24  specifying its value. Default is 1. On construction, the Nuisance is
25  unbounded. It can be bounded with set_upper and set_lower. Setting it
26  to values outside of bounds results in setting it to the bound value.
27  */
28 class IMPISDEXPORT Nuisance: public Decorator
29 {
30 public:
32 
33  static Nuisance setup_particle(Particle *p, double nuisance=1.0);
34 
35  static bool particle_is_instance(Particle *p) {
36  return p->has_attribute(get_nuisance_key());
37  }
38 
39  bool has_lower() const;
40 
41  bool has_upper() const;
42 
43  Float get_nuisance() const {
44  return get_particle()->get_value(get_nuisance_key());
45  }
46 
47  Float get_lower() const;
48 
49  Float get_upper() const;
50 
51  void set_nuisance(Float d);
52 
53  /** set upper and lower bound of nuisance by specifying
54  * either a float or another nuisance. Both can be set at the same
55  * time in which case the upper bound is the minimum of the two values.
56  */
57  void set_lower(Float d);
58  void set_lower(Particle * d);
59 
60  void set_upper(Float d);
61  void set_upper(Particle * d);
62 
63  Float get_nuisance_derivative() const {
64  return get_particle()->get_derivative(get_nuisance_key());
65  }
66 
67  void add_to_nuisance_derivative(Float d, DerivativeAccumulator &accum) {
68  get_particle()->add_to_derivative(get_nuisance_key(), d, accum);
69  }
70 
71  static FloatKey get_nuisance_key();
72 
73  static FloatKey get_lower_key();
74  static FloatKey get_upper_key();
75 
76  static ParticleIndexKey get_lower_particle_key();
77  static ParticleIndexKey get_upper_particle_key();
78 
79  bool get_nuisance_is_optimized() const {
80  return get_particle()->get_is_optimized(get_nuisance_key());
81  }
82 
83  void set_nuisance_is_optimized(bool val) {
84  get_particle()->set_is_optimized(get_nuisance_key(), val);
85  }
86 
87 };
88 
89 IMP_DECORATORS(Nuisance, Nuisances, ParticlesTemp);
90 
91 IMPISD_END_NAMESPACE
92 
93 #endif /* IMPISD_NUISANCE_H */