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
47 bool rigid,
bool tabexp,
48 std::string name=
"GaussianAnchorEMRestraint%1%"):
51 model_sigs_(model_sigs),
52 model_weights_(model_weights),
53 density_ps_(density_ps),
54 density_sigs_(density_sigs),
55 density_weights_(density_weights),
56 global_sigma_(global_sigma),
57 cutoff_dist_(cutoff_dist),
60 msize_=model_ps.size();
61 dsize_=density_ps.size();
63 model_weights.size()==msize_,
64 "All model inputs must be same size");
66 density_sigs.size()==dsize_ &&
67 density_weights.size()==dsize_,
68 "All input vectors must be same size");
71 unsigned exparg_grid_size=1000001;
73 invdx_=double(exparg_grid_size)/argmax_;
74 for(
unsigned k=0;k<exparg_grid_size;++k){
75 double argvalue=double(k)/invdx_;
76 exp_grid_.push_back(std::exp(-argvalue));
83 for (
size_t m1=0;m1<msize_;m1++){
84 init_mm_score_+=calc_prefactor(model_sigs_[m1],model_weights_[m1],
85 model_sigs[m1],model_weights_[m1]);
86 for (
size_t m2=m1;m2<msize_;m2++){
91 Float pref=calc_prefactor(model_sigs_[m1],model_weights_[m1],
92 model_sigs[m2],model_weights_[m2]);
93 Float prod=calc_prod(model_sigs_[m1],model_sigs_[m2]);
94 mm_prefactors_[pp1]=pref;
95 mm_prefactors_[pp2]=pref;
99 init_mm_score_+=2.0*pref*calc_score(dist,prod);
104 for (
size_t d1=0;d1<dsize_;d1++){
106 md_prefactors_[ppd1]=
107 calc_prefactor(model_sigs_[m1],model_weights_[m1],
108 density_sigs[d1],density_weights_[d1]);
109 md_prods_[ppd1]=calc_prod(model_sigs_[m1],density_sigs[d1]);
114 for (
size_t d1=0;d1<dsize_;d1++){
116 dd_score_+=calc_prefactor(density_sigs_[d1],density_weights_[d1],
117 density_sigs_[d1],density_weights_[d1]);
118 for (
size_t d2=d1+1;d2<dsize_;d2++){
121 Float pref=calc_prefactor(density_sigs_[d1],density_weights_[d1],
122 density_sigs_[d2],density_weights_[d2]);
123 Float prod=calc_prod(density_sigs_[d1],density_sigs_[d2]);
124 dd_score_+=2.0*pref*calc_score(dist,prod);
135 model_ps,density_ps,cutoff_dist_);
141 double get_probability()
const override {
151 Floats model_sigs_,model_weights_;
153 Floats density_sigs_,density_weights_;
158 Float dd_score_,init_mm_score_;
159 std::map<ParticlePair,Float> mm_prefactors_,
160 md_prefactors_,mm_prods_,md_prods_;
161 size_t msize_,dsize_;
170 pow(s1*s1+s2*s2,1.5);
173 return 1.0/(2.0*(s1*s1+s2*s2));
176 double argvalue=dist*dist*prod;
179 double minarg=std::min(argvalue,argmax_);
180 unsigned k =
static_cast<unsigned>( std::floor(minarg*invdx_) );
184 expn=std::exp(-argvalue);
Helper functions to check for NaN or infinity.
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-proximals 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.