00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPCORE_MOVER_BASE_H
00009 #define IMPCORE_MOVER_BASE_H
00010
00011 #include "core_config.h"
00012 #include "Mover.h"
00013
00014 #include <IMP/SingletonContainer.h>
00015 #include <IMP/macros.h>
00016
00017 #include <vector>
00018
00019 IMPCORE_BEGIN_NAMESPACE
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 class IMPCOREEXPORT MoverBase: public Mover
00030 {
00031 std::vector<Floats> floats_;
00032 std::vector<Ints> ints_;
00033 IMP::internal::OwnerPointer<SingletonContainer> pc_;
00034 public:
00035 virtual void accept_move(){}
00036 virtual void reject_move();
00037
00038
00039
00040 virtual void propose_move(Float f);
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 IMP_LIST(protected, FloatKey, float_key, FloatKey, FloatKeys);
00051 IMP_LIST(public, IntKey, int_key, IntKey, IntKeys);
00052
00053 SingletonContainer* get_container() const {
00054 return pc_;
00055 }
00056
00057 protected:
00058
00059
00060
00061 virtual void generate_move(Float f)=0;
00062
00063
00064
00065
00066
00067 Float get_float(unsigned int i, unsigned int j) const {
00068 IMP_INTERNAL_CHECK(pc_->get_number_of_particles() == floats_.size(),
00069 "Only call get_float from within generate_proposal");
00070 return pc_->get_particle(i)->get_value(get_float_key(j));
00071 }
00072
00073
00074
00075
00076
00077 Int get_int(unsigned int i, unsigned int j) const {
00078 IMP_INTERNAL_CHECK(pc_->get_number_of_particles() == ints_.size(),
00079 "Only call get_int from within generate_proposal");
00080 return pc_->get_particle(i)->get_value(get_int_key(j));
00081 }
00082
00083
00084
00085
00086
00087
00088 void propose_value(unsigned int i, unsigned int j, Float t) {
00089 if (pc_->get_particle(i)->get_is_optimized(get_float_key(j))) {
00090 pc_->get_particle(i)->set_value(get_float_key(j), t);
00091 }
00092 }
00093
00094
00095
00096
00097
00098 void propose_value(unsigned int i, unsigned int j, Int t) {
00099 pc_->get_particle(i)->set_value(get_int_key(j), t);
00100 }
00101
00102 MoverBase(SingletonContainer *sc): pc_(sc) {}
00103 IMP_REF_COUNTED_DESTRUCTOR(MoverBase);
00104 };
00105
00106 IMPCORE_END_NAMESPACE
00107
00108 #endif