9 #ifndef IMPDOMINO_ASSIGNMENT_CONTAINERS_H
10 #define IMPDOMINO_ASSIGNMENT_CONTAINERS_H
12 #include <IMP/domino/domino_config.h>
18 #include <boost/unordered_map.hpp>
22 #include <boost/random/uniform_int.hpp>
23 #include <boost/random/uniform_real.hpp>
24 #include <boost/shared_array.hpp>
28 #if IMP_DOMINO_HAS_RMF
29 #include <RMF/HDF5/Group.h>
30 #include <RMF/HDF5/File.h>
37 IMPDOMINO_BEGIN_NAMESPACE
46 virtual unsigned int get_number_of_assignments()
const = 0;
47 virtual Assignment get_assignment(
unsigned int i)
const = 0;
48 virtual Assignments get_assignments(IntRange ir)
const = 0;
50 virtual void add_assignment(
const Assignment &a) = 0;
51 virtual void add_assignments(
const Assignments &asgn) = 0;
53 virtual Ints get_particle_assignments(
unsigned int i)
const = 0;
70 "PackedAssignmentContainer %1%");
71 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
80 inline unsigned int PackedAssignmentContainer::get_number_of_assignments()
82 if (width_ == -1)
return 0;
83 return d_.size() / width_;
86 inline Assignment PackedAssignmentContainer::get_assignment(
unsigned int i)
89 "Invalid assignment requested: " << i);
90 IMP_USAGE_CHECK(width_ > 0,
"Uninitialized PackedAssignmentContainer.");
91 return Assignment(d_.begin() + i * width_, d_.begin() + (i + 1) * width_);
94 inline void PackedAssignmentContainer::add_assignment(
const Assignment &a) {
100 "Sizes don't match " << width_ <<
" vs " << a.size());
102 for (
unsigned int i = 0; i < get_number_of_assignments(); ++i) {
104 << a <<
" already here.");
107 d_.insert(d_.end(), a.begin(), a.end());
120 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
128 inline unsigned int ListAssignmentContainer::get_number_of_assignments()
const {
132 inline Assignment ListAssignmentContainer::get_assignment(
unsigned int i)
137 inline void ListAssignmentContainer::add_assignment(
const Assignment &a) {
153 boost::uniform_real<double> select_;
154 boost::uniform_int<> place_;
159 "SampleAssignmentContainer %1%");
160 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
168 inline unsigned int SampleAssignmentContainer::get_number_of_assignments()
170 return d_.size() / width_;
173 inline Assignment SampleAssignmentContainer::get_assignment(
unsigned int i)
175 return Assignment(d_.begin() + i * width_, d_.begin() + (i + 1) * width_);
179 #if IMP_DOMINO_HAS_RMF || defined(IMP_DOXYGEN)
189 RMF::HDF5::IndexDataSet2D ds_;
192 unsigned int max_cache_;
205 void set_cache_size(
unsigned int words);
206 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
217 RMF::HDF5::IndexConstDataSet2D ds_;
220 unsigned int max_cache_;
228 void set_cache_size(
unsigned int words);
229 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
245 unsigned int max_cache_;
262 void set_cache_size(
unsigned int words);
263 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
278 unsigned int max_cache_;
293 void set_cache_size(
unsigned int words);
294 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
312 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
322 typedef std::pair<Assignment, double> AP;
323 struct GreaterSecond {
324 bool operator()(
const AP &a,
const AP &b) {
return a.second < b.second; }
335 std::string name =
"HeapAssignmentContainer %1%");
336 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
349 void check_number()
const;
354 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
361 IMPDOMINO_END_NAMESPACE
#define IMP_IF_CHECK(level)
Execute the code block if a certain level checks are on.
A Bayesian inference-based sampler.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Store a persistent ordering for a subset based on the list.
#define IMP_OBJECT_LOG
Set the log level to the object's log level.
Represent a subset of the particles being optimized.
A smart pointer to a reference counted object.
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
virtual void do_destroy()
Common base class for heavy weight IMP objects.
#define IMP_ASSIGNMENT_CONTAINER_METHODS(Name)
A Bayesian inference-based sampler.
A class for storing lists of IMP items.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Store a configuration of a subset.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
A Bayesian inference-based sampler.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.