IMP logo
IMP Reference Guide  2.20.2
The Integrative Modeling Platform
SubsetMover.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/SubsetMover.h
3  * \brief A mover that applies a random subset of movers
4  *
5  * Copyright 2007-2023 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_SUBSET_MOVER_H
10 #define IMPCORE_SUBSET_MOVER_H
11 
12 #include <IMP/core/core_config.h>
13 #include "MonteCarlo.h"
14 #include "MonteCarloMover.h"
15 #include <cereal/access.hpp>
16 #include <cereal/types/base_class.hpp>
17 #include <cereal/types/polymorphic.hpp>
18 #include <cereal/types/vector.hpp>
19 
20 IMPCORE_BEGIN_NAMESPACE
21 
22 //! Applies a subset of a list of movers
23 /** Each time a move is requested, a random fixed-length subset
24  of the list of moves is applied. Movers are sampled without
25  replacement with uniform probabilities.
26  */
27 class IMPCOREEXPORT SubsetMover : public MonteCarloMover {
28  MonteCarloMovers movers_;
29  unsigned int n_;
30  std::vector<unsigned int> subset_inds_;
31 
32  friend class cereal::access;
33 
34  template<class Archive> void serialize(Archive &ar) {
35  ar(cereal::base_class<MonteCarloMover>(this),
36  movers_, n_, subset_inds_);
37  }
39 
40  public:
41  /** Constructor.
42  \param[in] mvs list of movers
43  \param[in] n number of movers to be randomly chosen for subset
44  of moves
45  */
46  SubsetMover(const MonteCarloMoversTemp& mvs, unsigned int n);
47 
48  SubsetMover() {}
49 
50  const MonteCarloMovers& get_movers() const { return movers_; }
51 
52  unsigned int get_subset_size() const { return n_; }
53 
54  protected:
55  virtual ModelObjectsTemp do_get_inputs() const override;
56  virtual MonteCarloMoverResult do_propose() override;
57  virtual void do_reject() override;
58  virtual void do_accept() override;
60 };
61 
62 IMPCORE_END_NAMESPACE
63 
64 #endif /* IMPCORE_SUBSET_MOVER_H */
Simple Monte Carlo optimizer.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual void do_accept()
Implement accept_proposed_move(); default implementation is empty.
Applies a subset of a list of movers.
Definition: SubsetMover.h:27
virtual void do_reject()=0
Implement reset_proposed_move()
Return value of the MonteCarloMover::propose() function.
A base class for classes which perturb particles.
The base class for movers for Monte Carlo optimization.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
virtual MonteCarloMoverResult do_propose()=0
Implement propose_move()
virtual ModelObjectsTemp do_get_inputs() const =0