13 #ifndef IMPCONTAINER_PREDICATE_TRIPLETS_RESTRAINT_H
14 #define IMPCONTAINER_PREDICATE_TRIPLETS_RESTRAINT_H
16 #include <IMP/container/container_config.h>
17 #include <IMP/container/internal/robin_map_cereal.h>
20 #include <cereal/access.hpp>
21 #include <cereal/types/base_class.hpp>
22 #include <cereal/types/map.hpp>
25 #if IMP_CONTAINER_HAS_ROBIN_MAP==1
26 #define IMP_CONTAINER_PREDICATE_USE_ROBIN_MAP
27 #include <tsl/robin_map.h>
28 #elif IMP_CONTAINER_HAS_GOOGLE_DENSE_HASH_MAP==1
29 #define IMP_CONTAINER_PREDICATE_USE_GOOGLE_DENSE_HASH_MAP
30 #include <google/dense_hash_map>
32 #define IMP_CONTAINER_PREDICATE_USE_KERNEL_MAP
40 IMPCONTAINER_BEGIN_NAMESPACE
54 #if IMP_CONTAINER_HAS_ROBIN_MAP==1
55 typedef tsl::robin_map<int, ParticleIndexTriplets> t_lists_map;
56 typedef tsl::robin_map<int, PointerMember<TripletScore> > t_score_map;
57 #elif IMP_CONTAINER_HAS_GOOGLE_DENSE_HASH_MAP==1
58 typedef google::dense_hash_map<int, ParticleIndexTriplets> t_lists_map;
59 typedef google::dense_hash_map<int, PointerMember<TripletScore> > t_score_map;
61 typedef IMP_KERNEL_LARGE_UNORDERED_MAP<int, ParticleIndexTriplets> t_lists_map;
62 typedef IMP_KERNEL_LARGE_UNORDERED_MAP<int, PointerMember<TripletScore> > t_score_map;
64 mutable t_lists_map lists_;
67 bool is_get_inputs_ignores_individual_scores_;
68 mutable std::size_t input_version_;
70 bool error_on_unknown_;
73 friend class cereal::access;
74 template<
class Archive>
void serialize(Archive &ar) {
75 ar(cereal::base_class<Restraint>(
this),
76 predicate_, input_, scores_,
77 is_get_inputs_ignores_individual_scores_,
78 error_on_unknown_, unknown_score_);
79 if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
88 void update_lists_if_necessary()
const;
94 "PredicateTripletsRestraint %1%");
100 void set_score(
int predicate_value,
TripletScore *score);
114 return lists_.find(predicate_value)->second;
127 is_get_inputs_ignores_individual_scores_= is_ignore;
143 get_score_for_predicate(
int predicate)
const;
152 PredicateTripletsRestraint::get_score_for_predicate
153 (
int predicate)
const
156 t_score_map::const_iterator it= scores_.find(predicate);
157 if(it!=scores_.end()){
161 "unknown interaction type cannot be scored when error_on_unknown is true");
162 score = unknown_score_;
169 IMPCONTAINER_END_NAMESPACE
void set_is_get_inputs_ignores_individual_scores(bool is_ignore)
Applies a TripletScore to each Triplet in a list based on a predicate.
Various important functionality for implementing decorators.
void set_is_complete(bool tf)
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Macros to choose the best set or map for different purposes.
Abstract predicate function.
virtual Restraints do_create_current_decomposition() const
ParticleIndexTriplets get_indexes(int predicate_value) 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.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Abstract class for scoring object(s) of type ParticleIndexTriplet.
virtual ModelObjectsTemp do_get_inputs() const =0
A restraint is a term in an IMP ScoringFunction.