IMP  2.1.0
The Integrative Modeling Platform
Scale.h
Go to the documentation of this file.
1 /**
2  * \file IMP/isd/Scale.h
3  * \brief A decorator for scale parameters particles
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPISD_SCALE_H
9 #define IMPISD_SCALE_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 scale parameter to particle
22 /** This is just syntactic sugar for a Nuisance bounded to be positive.
23  */
24 class IMPISDEXPORT Scale: public Nuisance
25 {
26  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi, double scale=1.0);
27 
28 public:
31  IMP_DECORATOR_SETUP_1(Scale, double, scale);
32 
33  static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi) {
34  return Nuisance::get_is_setup(m, pi) && Nuisance(m, pi).get_lower()>=0;
35  }
36 
37  Float get_scale() const {
38  return Nuisance(get_particle()).get_nuisance();
39  }
40 
41  void set_scale(Float d) { set_nuisance(d); }
42 
43  void add_to_scale_derivative(Float d, DerivativeAccumulator &accum)
44  {
45  add_to_nuisance_derivative(d, accum);
46  }
47 
48  Float get_scale_derivative() const
49  {
50  return get_nuisance_derivative();
51  }
52 
53  static FloatKey get_scale_key() { return get_nuisance_key(); }
54 
55  bool get_scale_is_optimized() const
56  {
57  return get_nuisance_is_optimized();
58  }
59 
60  void set_scale_is_optimized(bool val)
61  {
62  set_nuisance_is_optimized(val);
63  }
64 
65 };
66 
67 
68 IMP_DECORATORS(Scale, Scales, Nuisances);
69 
70 IMPISD_END_NAMESPACE
71 
72 #endif /* IMPISD_SCALE_H */
Import IMP/kernel/Decorator.h in the namespace.
Import IMP/kernel/SingletonContainer.h in the namespace.
Particle * get_particle() const
IMP::kernel::DerivativeAccumulator DerivativeAccumulator
#define IMP_DECORATOR_METHODS(Name, Parent)
A decorator for nuisance parameters particles.
Add scale parameter to particle.
Definition: Scale.h:24
Import IMP/kernel/PairContainer.h in the namespace.
#define IMP_DECORATOR_SETUP_0(Name)
Add nuisance parameter to particle.
Definition: Nuisance.h:26
Import IMP/kernel/decorator_macros.h in the namespace.
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
Class for storing model, its restraints, constraints, and particles.