00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPCORE_MONTE_CARLO_H
00009 #define IMPCORE_MONTE_CARLO_H
00010
00011 #include "core_config.h"
00012 #include "Mover.h"
00013
00014 #include <IMP/Optimizer.h>
00015 #include <IMP/container_macros.h>
00016
00017 IMPCORE_BEGIN_NAMESPACE
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 class IMPCOREEXPORT MonteCarlo: public Optimizer
00031 {
00032 public:
00033 MonteCarlo(Model *m=NULL);
00034
00035 IMP_OPTIMIZER(MonteCarlo);
00036 public:
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 void set_local_optimizer(Optimizer* cg);
00050
00051 Optimizer *get_local_optimizer() const {
00052 return cg_.get();
00053 }
00054
00055 int get_local_steps() const {
00056 return num_local_steps_;
00057 }
00058 void set_local_steps(unsigned int n) {
00059 num_local_steps_=n;
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069 void set_return_best(bool tf) {
00070 return_best_=tf;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079 void set_temperature(Float t) {
00080 IMP_INTERNAL_CHECK(t>0, "Temperature must be positive");
00081 temp_=t;
00082 }
00083 Float get_temperature() const {
00084 return temp_;
00085 }
00086
00087
00088
00089
00090
00091
00092 void set_score_threshold(Float t) {
00093 stop_energy_=t;
00094 }
00095 Float get_score_threshold() const {
00096 return stop_energy_;
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106 void set_move_probability(Float p) {
00107 IMP_USAGE_CHECK(p > 0 && p <= 1, "Not a valid probability");
00108 probability_=p;
00109 }
00110
00111
00112
00113
00114 unsigned int get_number_of_forward_steps() const {
00115 return stat_forward_steps_taken_;
00116 }
00117
00118 unsigned int get_number_of_upward_steps() const {
00119 return stat_upward_steps_taken_;
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 IMP_LIST(public, Mover, mover, Mover*, Movers);
00131
00132 private:
00133 Float temp_;
00134 Float stop_energy_;
00135 Float probability_;
00136 IMP::internal::OwnerPointer<Optimizer> cg_;
00137 unsigned int num_local_steps_;
00138 unsigned int stat_forward_steps_taken_;
00139 unsigned int stat_upward_steps_taken_;
00140 unsigned int stat_num_failures_;
00141 bool return_best_;
00142 };
00143
00144 IMP_OUTPUT_OPERATOR(MonteCarlo);
00145
00146 IMPCORE_END_NAMESPACE
00147
00148 #endif