8 #ifndef IMPCORE_MONTE_CARLO_H
9 #define IMPCORE_MONTE_CARLO_H
11 #include <IMP/core/core_config.h>
18 #include <IMP/kernel/internal/container_helpers.h>
22 #include <boost/random/uniform_real.hpp>
24 IMPCORE_BEGIN_NAMESPACE
27 #define IMP_CORE_HAS_MONTE_CARLO_MOVER 1
52 IMPCORE_DEPRECATED_FUNCTION_DECL(2.1)
63 void set_return_best(
bool tf) { return_best_ = tf; }
71 void set_kt(
Float t) {
85 <<
" requires return best being on.");
93 return stat_forward_steps_taken_;
97 return stat_upward_steps_taken_;
101 return stat_forward_steps_taken_ + stat_upward_steps_taken_ +
106 return stat_forward_steps_taken_ + stat_upward_steps_taken_;
108 void reset_statistics() {
109 stat_forward_steps_taken_ = 0;
110 stat_upward_steps_taken_ = 0;
111 stat_num_failures_ = 0;
123 double get_maximum_difference()
const {
return max_difference_; }
131 IMP_LIST_ACTION(
public, Mover, Movers, mover, movers, MonteCarloMover *,
143 void set_incremental_scoring_function(IncrementalScoringFunction *isf);
144 bool get_use_incremental_scoring_function()
const {
return isf_; }
145 IncrementalScoringFunction *get_incremental_scoring_function()
const {
152 kernel::ParticleIndexes get_movable_particles()
const;
157 bool do_accept_or_reject_move(
double score,
double last,
158 double proposal_ratio);
159 bool do_accept_or_reject_move(
double score,
double proposal_ratio) {
160 return do_accept_or_reject_move(score, get_last_accepted_energy(),
164 MonteCarloMoverResult do_move();
166 virtual void do_step();
183 isf_->set_moved_particles(moved);
185 if (get_maximum_difference() <
NO_MAX) {
187 false, last_energy_ + max_difference_);
197 double max_difference_;
198 unsigned int stat_forward_steps_taken_;
199 unsigned int stat_upward_steps_taken_;
200 unsigned int stat_num_failures_;
203 ::boost::uniform_real<> rand_;
211 unsigned int num_local_;
216 unsigned int get_number_of_steps()
const {
return num_local_; }
218 Optimizer *get_local_optimizer()
const {
return opt_; }
221 virtual void do_step() IMP_OVERRIDE;
239 virtual void do_step() IMP_OVERRIDE;
243 IMPCORE_END_NAMESPACE
Import IMP/kernel/optimizer_macros.h in the namespace.
const double NO_MAX
Use this value when you want to turn off maximum for restraint evaluation.
unsigned int get_number_of_upward_steps() const
Return how many times the optimizer has stepped to higher energy.
Simple Monte Carlo optimizer.
double evaluate(bool derivatives)
Evaluate and return the score.
A smart pointer to a ref-counted Object that is a class memeber.
void set_maximum_difference(double d)
double get_last_accepted_energy() const
Various important macros for implementing decorators.
#define IMP_UNUSED(variable)
A smart pointer to a reference counted object.
IMP::base::Vector< IMP::base::Pointer< MonteCarloMover > > MonteCarloMovers
Import IMP/kernel/Optimizer.h in the namespace.
Import IMP/kernel/container_macros.h in the namespace.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
virtual void do_step()
a class that inherits from this should override this method
This variant of Monte Carlo uses basis hopping.
unsigned int get_number_of_forward_steps() const
Return how many times the optimizer has succeeded in taking a step.
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
The base class for movers for MC optimization.
unsigned int get_number_of_accepted_steps() const
Get number of accepted moves.
This variant of Monte Carlo that relaxes after each move.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
double get_best_accepted_energy() const
Base class for all optimizers.
virtual double do_evaluate(const kernel::ParticleIndexes &moved) const
Get the current energy.
double Float
Basic floating-point value (could be float, double...)
ScoringFunction * get_scoring_function() const
Return the scoring function that is being used.
virtual double do_optimize(unsigned int ns)=0
override this function to do actual optimization
virtual void do_step()
a class that inherits from this should override this method
Import IMP/kernel/Configuration.h in the namespace.
Functions to generate vectors.
unsigned int get_number_of_proposed_steps() const
Get number of proposed moves.
Class for storing model, its restraints, constraints, and particles.