8 #ifndef IMPCORE_MONTE_CARLO_H
9 #define IMPCORE_MONTE_CARLO_H
11 #include <IMP/core/core_config.h>
16 #include <IMP/kernel/internal/container_helpers.h>
20 #include <boost/random/uniform_real.hpp>
22 IMPCORE_BEGIN_NAMESPACE
25 #define IMP_CORE_HAS_MONTE_CARLO_MOVER 1
57 void set_return_best(
bool tf) { return_best_ = tf; }
65 void set_kt(
Float t) {
77 <<
" requires return best being on.");
86 IMPCORE_DEPRECATED_FUNCTION_DECL(2.2)
87 unsigned
int get_number_of_forward_steps()
const {
88 IMPCORE_DEPRECATED_FUNCTION_DEF(2.2,
89 "Use get_number_of_accepted_steps() instead.");
90 return get_number_of_accepted_steps();
95 return stat_downward_steps_taken_;
99 return stat_upward_steps_taken_;
103 return stat_downward_steps_taken_ + stat_upward_steps_taken_ +
108 return stat_downward_steps_taken_ + stat_upward_steps_taken_;
110 void reset_statistics() {
111 stat_downward_steps_taken_ = 0;
112 stat_upward_steps_taken_ = 0;
113 stat_num_failures_ = 0;
132 double get_maximum_difference()
const {
return max_difference_; }
140 IMP_LIST_ACTION(
public, Mover, Movers, mover, movers, MonteCarloMover *,
152 void set_incremental_scoring_function(IncrementalScoringFunction *isf);
153 bool get_use_incremental_scoring_function()
const {
return isf_; }
154 IncrementalScoringFunction *get_incremental_scoring_function()
const {
161 kernel::ParticleIndexes get_movable_particles()
const;
166 bool do_accept_or_reject_move(
double score,
double last,
167 double proposal_ratio);
168 bool do_accept_or_reject_move(
double score,
double proposal_ratio) {
169 return do_accept_or_reject_move(score, get_last_accepted_energy(),
173 MonteCarloMoverResult do_move();
175 virtual void do_step();
192 isf_->set_moved_particles(moved);
194 if (get_maximum_difference() <
NO_MAX) {
196 false, last_energy_ + max_difference_);
206 double max_difference_;
207 unsigned int stat_downward_steps_taken_;
208 unsigned int stat_upward_steps_taken_;
209 unsigned int stat_num_failures_;
213 ::boost::uniform_real<> rand_;
221 unsigned int num_local_;
226 unsigned int get_number_of_steps()
const {
return num_local_; }
228 Optimizer *get_local_optimizer()
const {
return opt_; }
253 IMPCORE_END_NAMESPACE
double get_kt(double T)
Return kT for a given temperature.
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 score.
Simple Monte Carlo optimizer.
double get_score_threshold() const
Get the score threshold.
double evaluate(bool derivatives)
Evaluate and return the score.
A smart pointer to a ref-counted Object that is a class member.
void set_maximum_difference(double d)
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
double get_last_accepted_energy() const
Return the energy of the last accepted state.
A smart pointer to a reference counted object.
IMP::base::Vector< IMP::base::Pointer< MonteCarloMover > > MonteCarloMovers
Import IMP/kernel/Optimizer.h in the namespace.
void set_score_threshold(double s)
Set the score threshold.
Import IMP/kernel/container_macros.h in the namespace.
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
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_downward_steps() const
Return how many times the optimizer has stepped to lower score.
#define IMP_UNUSED(variable)
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.
double get_best_accepted_energy() const
If return best is on, returns the best energy found so far.
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.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
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.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.