13 #ifndef IMPCONTAINER_PREDICATE_PAIRS_RESTRAINT_H
14 #define IMPCONTAINER_PREDICATE_PAIRS_RESTRAINT_H
16 #include <IMP/container/container_config.h>
17 #include <IMP/container/internal/robin_map_cereal.h>
18 #include <IMP/container/internal/dense_hash_map_cereal.h>
21 #include <cereal/access.hpp>
22 #include <cereal/types/base_class.hpp>
23 #include <cereal/types/map.hpp>
26 #if IMP_CONTAINER_HAS_ROBIN_MAP==1
27 #define IMP_CONTAINER_PREDICATE_USE_ROBIN_MAP
28 #include <tsl/robin_map.h>
29 #elif IMP_CONTAINER_HAS_GOOGLE_DENSE_HASH_MAP==1
30 #define IMP_CONTAINER_PREDICATE_USE_GOOGLE_DENSE_HASH_MAP
31 #include <google/dense_hash_map>
33 #define IMP_CONTAINER_PREDICATE_USE_KERNEL_MAP
41 IMPCONTAINER_BEGIN_NAMESPACE
55 #if IMP_CONTAINER_HAS_ROBIN_MAP==1
56 typedef tsl::robin_map<int, ParticleIndexPairs> t_lists_map;
57 typedef tsl::robin_map<int, PointerMember<PairScore>> t_score_map;
58 #elif IMP_CONTAINER_HAS_GOOGLE_DENSE_HASH_MAP==1
59 typedef google::dense_hash_map<int, ParticleIndexPairs> t_lists_map;
60 typedef google::dense_hash_map<int, PointerMember<PairScore>> t_score_map;
62 typedef IMP_KERNEL_LARGE_UNORDERED_MAP<int, ParticleIndexPairs> t_lists_map;
63 typedef IMP_KERNEL_LARGE_UNORDERED_MAP<int, PointerMember<PairScore>> t_score_map;
65 mutable t_lists_map lists_;
68 bool is_get_inputs_ignores_individual_scores_;
69 mutable std::size_t input_version_;
71 bool error_on_unknown_;
74 friend class cereal::access;
75 template<
class Archive>
void serialize(Archive &ar) {
76 ar(cereal::base_class<Restraint>(
this),
77 predicate_, input_, scores_,
78 is_get_inputs_ignores_individual_scores_,
79 error_on_unknown_, unknown_score_);
80 if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
89 void update_lists_if_necessary()
const;
95 "PredicatePairsRestraint %1%");
98 #ifdef IMP_CONTAINER_PREDICATE_USE_GOOGLE_DENSE_HASH_MAP
99 lists_.set_empty_key(-1);
100 scores_.set_empty_key(-1);
106 void set_score(
int predicate_value,
PairScore *score);
110 void set_unknown_score(
PairScore *score);
120 return lists_.find(predicate_value)->second;
133 is_get_inputs_ignores_individual_scores_= is_ignore;
149 get_score_for_predicate(
int predicate)
const;
158 PredicatePairsRestraint::get_score_for_predicate
159 (
int predicate)
const
162 t_score_map::const_iterator it= scores_.find(predicate);
163 if(it!=scores_.end()){
167 "unknown interaction type cannot be scored when error_on_unknown is true");
168 score = unknown_score_;
175 IMPCONTAINER_END_NAMESPACE
Abstract class for scoring object(s) of type ParticleIndexPair.
void set_is_complete(bool tf)
Various important functionality for implementing decorators.
void set_is_get_inputs_ignores_individual_scores(bool is_ignore)
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Applies a PairScore to each Pair in a list based on a predicate.
Macros to choose the best set or map for different purposes.
virtual Restraints do_create_current_decomposition() const
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
A smart pointer to a ref-counted Object that is a class member.
Class for adding up scores during ScoringFunction evaluation.
Abstract predicate function.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
ParticleIndexPairs get_indexes(int predicate_value) const
virtual ModelObjectsTemp do_get_inputs() const =0
A restraint is a term in an IMP ScoringFunction.