9 #ifndef IMPISD_GAUSSIAN_ANCHOR_EMRESTRAINT_H
10 #define IMPISD_GAUSSIAN_ANCHOR_EMRESTRAINT_H
12 #include <IMP/isd/isd_config.h>
21 IMPISD_BEGIN_NAMESPACE
51 bool rigid,
bool tabexp,
52 std::string name=
"GaussianAnchorEMRestraint%1%"):
55 model_sigs_(model_sigs),
56 model_weights_(model_weights),
57 density_ps_(density_ps),
58 density_sigs_(density_sigs),
59 density_weights_(density_weights),
60 global_sigma_(global_sigma),
61 cutoff_dist_(cutoff_dist),
64 msize_=model_ps.size();
65 dsize_=density_ps.size();
67 model_weights.size()==msize_,
68 "All model inputs must be same size");
70 density_sigs.size()==dsize_ &&
71 density_weights.size()==dsize_,
72 "All input vectors must be same size");
75 unsigned exparg_grid_size=1000001;
77 invdx_=double(exparg_grid_size)/argmax_;
78 for(
unsigned k=0;k<exparg_grid_size;++k){
79 double argvalue=double(k)/invdx_;
80 exp_grid_.push_back(std::exp(-argvalue));
87 for (
size_t m1=0;m1<msize_;m1++){
88 init_mm_score_+=calc_prefactor(model_sigs_[m1],model_weights_[m1],
89 model_sigs[m1],model_weights_[m1]);
90 for (
size_t m2=m1;m2<msize_;m2++){
95 Float pref=calc_prefactor(model_sigs_[m1],model_weights_[m1],
96 model_sigs[m2],model_weights_[m2]);
97 Float prod=calc_prod(model_sigs_[m1],model_sigs_[m2]);
98 mm_prefactors_[pp1]=pref;
99 mm_prefactors_[pp2]=pref;
103 init_mm_score_+=2.0*pref*calc_score(dist,prod);
108 for (
size_t d1=0;d1<dsize_;d1++){
110 md_prefactors_[ppd1]=
111 calc_prefactor(model_sigs_[m1],model_weights_[m1],
112 density_sigs[d1],density_weights_[d1]);
113 md_prods_[ppd1]=calc_prod(model_sigs_[m1],density_sigs[d1]);
118 for (
size_t d1=0;d1<dsize_;d1++){
120 dd_score_+=calc_prefactor(density_sigs_[d1],density_weights_[d1],
121 density_sigs_[d1],density_weights_[d1]);
122 for (
size_t d2=d1+1;d2<dsize_;d2++){
125 Float pref=calc_prefactor(density_sigs_[d1],density_weights_[d1],
126 density_sigs_[d2],density_weights_[d2]);
127 Float prod=calc_prod(density_sigs_[d1],density_sigs_[d2]);
128 dd_score_+=2.0*pref*calc_score(dist,prod);
139 model_ps,density_ps,cutoff_dist_);
145 double get_probability()
const override {
155 Floats model_sigs_,model_weights_;
157 Floats density_sigs_,density_weights_;
162 Float dd_score_,init_mm_score_;
163 std::map<ParticlePair,Float> mm_prefactors_,
164 md_prefactors_,mm_prods_,md_prods_;
165 size_t msize_,dsize_;
174 pow(s1*s1+s2*s2,1.5);
177 return 1.0/(2.0*(s1*s1+s2*s2));
180 double argvalue=dist*dist*prod;
183 double minarg=std::min(argvalue,argmax_);
184 unsigned k =
static_cast<unsigned>( std::floor(minarg*invdx_) );
188 expn=std::exp(-argvalue);
A base class for ISD Restraints.
static const double PI
the constant pi
A class to store a fixed array of same-typed values.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
GaussianAnchorEMRestraint(ParticlesTemp model_ps, Floats model_sigs, Floats model_weights, ParticlesTemp density_ps, Floats density_sigs, Floats density_weights, Particle *global_sigma, Float cutoff_dist, bool rigid, bool tabexp, std::string name="GaussianAnchorEMRestraint%1%")
Constructor.
A decorator for scale parameters particles.
Return all spatially-proximal pairs of particles (a,b) from the two SingletonContainers A and B...
virtual ModelObjectsTemp do_get_inputs() const override
Return all pairs from a SingletonContainer.
Restraint between two sets of anchor points "model" and "EM density".
A decorator for a particle with x,y,z coordinates.
virtual double unprotected_evaluate(DerivativeAccumulator *accum) const override
Return the unweighted score for the restraint.
double Float
Basic floating-point value (could be float, double...)
Class to handle individual particles of a Model object.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
double get_distance(const Surface &s, const XYZR &d)
Get distance from sphere to surface.
Class for adding derivatives from restraints to the model.