IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
MonteCarloWithWte.h
Go to the documentation of this file.
1 /**
2  * \file IMP/spb/MonteCarloWithWte.h
3  * \brief An exotic version of MonteCarlo
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPSPB_MONTE_CARLO_WITH_WTE_H
9 #define IMPSPB_MONTE_CARLO_WITH_WTE_H
10 
11 #include <IMP/spb/spb_config.h>
12 
13 #include <IMP/Restraint.h>
14 #include <IMP/core.h>
15 #include <boost/scoped_array.hpp>
16 
17 IMPSPB_BEGIN_NAMESPACE
18 
19 //! MonteCarlo in the Well-Tempered Ensemble
20 class IMPSPBEXPORT MonteCarloWithWte : public core::MonteCarlo {
21  double min_;
22  double max_;
23  double sigma_;
24  double gamma_;
25  double dx_;
26  double w0_;
27  boost::scoped_array<double> bias_;
28  int nbin_;
29  bool full_;
31 
32  void do_initialize(double emin, double emax, double sigma, double gamma,
33  double w0);
34 
35  void update_bias(double score);
36  virtual double do_evaluate(
37  const ParticleIndexes &moved, bool) const override;
38  double get_spline(double score) const;
39 
40  public:
41  MonteCarloWithWte(Model *m, double emin, double emax, double sigma,
42  double gamma, double w0);
43 
44  MonteCarloWithWte(Model *m, double emin, double emax, double sigma,
45  double gamma, double w0, RestraintSet *rset);
46 
47  double get_bias(double score) const;
48 
49 #ifndef SWIG
50  double *get_bias_buffer() const { return bias_.get(); }
51 #endif
52 
53  Floats get_bias_asfloats() const {
54  Floats buffer(bias_.get(), bias_.get() + nbin_);
55  return buffer;
56  }
57 
58  int get_nbin() const { return nbin_; }
59 
60  void set_w0(double w0) { w0_ = w0; }
61 
62  void set_bias(const Floats &bias) {
63  IMP_USAGE_CHECK(bias.size() == static_cast<unsigned int>(nbin_),
64  "Don't match");
65  std::copy(bias.begin(), bias.end(), bias_.get());
66  }
67 
68  // IMP_MONTE_CARLO(MonteCarloWithWte);
69  virtual void do_step() override;
70 
72 };
73 
74 IMPSPB_END_NAMESPACE
75 
76 #endif /* IMPSPB_MONTE_CARLO_WITH_WTE_H */
A Monte Carlo optimizer.
Definition: MonteCarlo.h:44
virtual double do_evaluate(const ParticleIndexes &moved, bool force_full_score) const
Get the current energy.
Definition: MonteCarlo.h:182
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Include all non-deprecated headers in IMP.core.
MonteCarlo in the Well-Tempered Ensemble.
Object used to hold a set of restraints.
Definition: RestraintSet.h:41
virtual void do_step()
a class that inherits from this should override this method
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:143
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
Abstract base class for all restraints.