9 #ifndef IMPDOMINO_SUBSET_SCORES_H
10 #define IMPDOMINO_SUBSET_SCORES_H
22 #include <boost/unordered_map.hpp>
24 #if IMP_DOMINO_HAS_RMF
25 #include <RMF/HDF5/Group.h>
28 IMPDOMINO_BEGIN_NAMESPACE
42 Subset, subset,
double, max, );
50 typedef boost::unordered_map<kernel::Restraint *, RestraintData> RMap;
52 typedef boost::unordered_map<kernel::Restraint *, SetData> SMap;
58 typedef double result_type;
59 typedef Key argument_type;
60 template <
class Cache>
61 result_type operator()(
const argument_type &k,
const Cache &cache)
const {
62 RMap::const_iterator it = rmap_.find(k.get_restraint());
63 if (it != rmap_.end()) {
64 Subset s = rmap_.find(k.get_restraint())->second.get_subset();
69 e = it->second.get_scoring_function()->evaluate_if_below(
70 false, it->second.get_max());
73 <<
" evaluated to " << e <<
" on "
74 << k.get_assignment() <<
" vs "
75 << it->second.get_max() << std::endl);
77 if (e > it->second.get_max()) e = std::numeric_limits<double>::max();
80 SMap::const_iterator it = sets_.find(k.get_restraint());
82 << Showable(k.get_restraint())
85 for (
unsigned int i = 0; i < it->second.get_members().size(); ++i) {
86 Assignment cur = it->second.get_members()[i].get_slice().get_sliced(
88 double score = cache.get(
89 argument_type(it->second.get_members()[i].get_restraint(), cur));
90 total += score * k.get_restraint()->get_weight();
91 if (total >= it->second.get_max()) {
96 <<
" evaluated to " << total <<
" on "
97 << k.get_assignment() <<
" with max "
98 << it->second.get_max() << std::endl);
99 if (total >= it->second.get_max()) {
100 return std::numeric_limits<double>::max();
109 "don't pass restraint sets here as second arg");
110 sets_[rs].access_members().push_back(RestraintSetData(slice, r));
111 sets_[rs].set_max(max);
115 "don't pass restraint sets here");
116 if (rmap_.find(e) == rmap_.end()) {
120 "Subsets don't match on restraint update");
121 rmap_[e].set_max(std::min(rmap_[e].get_max(), max));
125 void show_restraint_information(std::ostream &out)
const;
127 #endif // IMP_DOXYGEN
129 struct ApproximatelyEqual {
130 bool operator()(
double a,
double b)
const {
131 return std::abs(a - b) < .1 * (a + b) + .1;
134 typedef boost::unordered_map<kernel::Particle *, kernel::ParticlesTemp>
138 Subset parent_subset,
const DepMap &dependencies);
145 const Subset &cur_subset,
double cur_max,
146 const DepMap &dependencies);
153 typedef boost::unordered_map<base::Pointer<kernel::Restraint>,
Subset>
155 KnownRestraints known_restraints_;
157 typedef boost::unordered_map<base::Pointer<kernel::Restraint>,
int>
159 RestraintIndex restraint_index_;
160 unsigned int next_index_;
164 unsigned int size = std::numeric_limits<unsigned int>::max());
178 double s = cache_.get(Key(r, a));
196 const Subsets &exclusions)
const;
200 #if IMP_DOMINO_HAS_RMF || defined(IMP_DOXYGEN)
211 RMF::HDF5::Group group,
unsigned int max_entries);
222 void validate()
const;
225 void show_restraint_information(std::ostream &out = std::cout)
const;
226 double get_hit_rate()
const {
return cache_.get_hit_rate(); }
230 IMPDOMINO_END_NAMESPACE
A beyesian infererence-based sampler.
void set_was_used(bool tf) const
void add_restraints(RMF::FileHandle fh, const kernel::Restraints &hs)
A smart pointer to a ref-counted Object that is a class memeber.
Object used to hold a set of restraints.
kernel::RestraintsTemp get_restraints(const Subset &s, const ParticleStatesTable *pst, const DependencyGraph &dg, kernel::RestraintSet *rs)
Represent a subset of the particles being optimized.
A class to change and restore log state.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
#define IMP_LOG_TERSE(expr)
Store a subset of a subset or assignment.
Abstract base class for all restraints.
Various general useful functions for IMP.
A restraint is a term in an IMP ScoringFunction.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
double get_score(kernel::Restraint *r, const Assignment &a) const
Get the score of a set or restraint.
Common base class for heavy weight IMP objects.
A beyesian infererence-based sampler.
A beyesian infererence-based sampler.
Functions to get report statistics about the used attributes.
virtual ScoringFunction * create_scoring_function(double weight=1.0, double max=NO_MAX) const
Store a configuration of a subset.
unsigned int get_number_of_entries() const
Logging and error reporting support.
A shared base class to help in debugging and things.
void load_particle_states(const Subset &s, const Assignment &ss, const ParticleStatesTable *pst)
A beyesian infererence-based sampler.
void add_restraint(RMF::FileHandle fh, kernel::Restraint *hs)
Slice get_slice(Subset outer, Subset inner, const Subsets &excluded)