8 #ifndef IMPCORE_MONTE_CARLO_H
9 #define IMPCORE_MONTE_CARLO_H
11 #include <IMP/core/core_config.h>
16 #include <IMP/internal/container_helpers.h>
20 #include <boost/random/uniform_real.hpp>
22 IMPCORE_BEGIN_NAMESPACE
25 #define IMP_CORE_HAS_MONTE_CARLO_MOVER 1
58 void set_return_best(
bool tf) { return_best_ = tf; }
82 void set_kt(
Float t) {
94 <<
" requires return best being on.");
102 return stat_downward_steps_taken_;
106 return stat_upward_steps_taken_;
110 return stat_downward_steps_taken_ + stat_upward_steps_taken_ +
115 return stat_downward_steps_taken_ + stat_upward_steps_taken_;
117 void reset_statistics() {
118 stat_downward_steps_taken_ = 0;
119 stat_upward_steps_taken_ = 0;
120 stat_num_failures_ = 0;
139 double get_maximum_difference()
const {
return max_difference_; }
147 IMP_LIST_ACTION(
public, Mover, Movers, mover, movers, MonteCarloMover *,
156 IMPCORE_DEPRECATED_METHOD_DECL(2.17)
157 void set_incremental_scoring_function(IncrementalScoringFunction *isf);
159 bool get_use_incremental_scoring_function()
const {
return isf_; }
161 IncrementalScoringFunction *get_incremental_scoring_function()
const {
168 ParticleIndexes get_movable_particles()
const;
173 bool do_accept_or_reject_move(
double score,
double last,
174 const MonteCarloMoverResult &moved);
176 bool do_accept_or_reject_move(
double score,
177 const MonteCarloMoverResult &moved) {
178 return do_accept_or_reject_move(score, get_last_accepted_energy(), moved);
181 MonteCarloMoverResult do_move();
183 virtual void do_step();
198 bool force_full_score)
const {
200 isf_->set_moved_particles(moved);
202 if (get_maximum_difference() <
NO_MAX) {
203 if (score_moved_ && !force_full_score) {
205 false, moved, reset_pis_, last_energy_ + max_difference_);
208 false, last_energy_ + max_difference_);
211 if (score_moved_ && !force_full_score) {
223 double max_difference_;
224 unsigned int stat_downward_steps_taken_;
225 unsigned int stat_upward_steps_taken_;
226 unsigned int stat_num_failures_;
231 ::boost::uniform_real<> rand_;
239 unsigned int num_local_;
244 unsigned int get_number_of_steps()
const {
return num_local_; }
246 Optimizer *get_local_optimizer()
const {
return opt_; }
249 virtual void do_step()
override;
267 virtual void do_step()
override;
271 IMPCORE_END_NAMESPACE
double get_kt(double T)
Return kT for a given temperature in units of [kcal/mol].
unsigned int get_number_of_upward_steps() const
Return how many times the optimizer has stepped to higher score.
Score model efficiently when a small number of particles are changed.
double get_score_threshold() const
Get the score threshold.
const double NO_MAX
Use this value when you want to turn off maximum for restraint evaluation.
virtual double do_evaluate(const ParticleIndexes &moved, bool force_full_score) const
Get the current energy.
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.
void set_score_moved(bool mv)
If set true (default false), only rescore moved particles.
Base class for all optimizers.
void set_score_threshold(double s)
Set the score threshold.
Macros to define containers of objects.
A smart pointer to a reference counted object.
#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
Class for storing model, its restraints, constraints, and particles.
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.
virtual double do_optimize(unsigned int ns)=0
override this function to do actual optimization
virtual void do_step() override
a class that inherits from this should override this method
Base class for all optimizers.
The base class for movers for Monte Carlo optimization.
unsigned int get_number_of_accepted_steps() const
Get number of accepted moves.
A smart pointer to a ref-counted Object that is a class member.
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.
double evaluate_moved(bool derivatives, const ParticleIndexes &moved_pis, const ParticleIndexes &reset_pis)
Score when some particles have moved.
double Float
Basic floating-point value (could be float, double...)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Store a set of configurations of the model.
Functions to search over vectors.
double evaluate(bool derivatives)
Evaluate and return the score for the current state of the model.
unsigned int get_number_of_proposed_steps() const
Get number of proposed moves.
ScoringFunction * get_scoring_function() const
Return the scoring function that is being used.