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
47 virtual unsigned int get_number_of_assignments()
const = 0;
48 virtual Assignment get_assignment(
unsigned int i)
const = 0;
49 virtual Assignments get_assignments(IntRange ir)
const = 0;
51 virtual void add_assignment(
const Assignment &a) = 0;
52 virtual void add_assignments(
const Assignments &asgn) = 0;
54 virtual Ints get_particle_assignments(
unsigned int i)
const = 0;
71 "PackedAssignmentContainer %1%");
72 virtual unsigned int get_number_of_assignments()
const override;
73 virtual Assignment get_assignment(
unsigned int i)
const override;
74 virtual void add_assignment(
const Assignment &a)
override;
81 inline unsigned int PackedAssignmentContainer::get_number_of_assignments()
83 if (width_ == -1)
return 0;
84 return d_.size() / width_;
87 inline Assignment PackedAssignmentContainer::get_assignment(
unsigned int i)
90 "Invalid assignment requested: " << i);
91 IMP_USAGE_CHECK(width_ > 0,
"Uninitialized PackedAssignmentContainer.");
92 return Assignment(d_.begin() + i * width_, d_.begin() + (i + 1) * width_);
95 inline void PackedAssignmentContainer::add_assignment(
const Assignment &a) {
101 "Sizes don't match " << width_ <<
" vs " << a.size());
103 for (
unsigned int i = 0; i < get_number_of_assignments(); ++i) {
105 << a <<
" already here.");
108 d_.insert(d_.end(), a.begin(), a.end());
121 virtual unsigned int get_number_of_assignments()
const override;
122 virtual Assignment get_assignment(
unsigned int i)
const override;
123 virtual void add_assignment(
const Assignment &a)
override;
129 inline unsigned int ListAssignmentContainer::get_number_of_assignments()
const {
133 inline Assignment ListAssignmentContainer::get_assignment(
unsigned int i)
138 inline void ListAssignmentContainer::add_assignment(
const Assignment &a) {
152 boost::uniform_real<double> select_;
153 boost::uniform_int<> place_;
158 "SampleAssignmentContainer %1%");
159 virtual unsigned int get_number_of_assignments()
const override;
160 virtual Assignment get_assignment(
unsigned int i)
const override;
161 virtual void add_assignment(
const Assignment &a)
override;
167 inline unsigned int SampleAssignmentContainer::get_number_of_assignments()
169 return d_.size() / width_;
172 inline Assignment SampleAssignmentContainer::get_assignment(
unsigned int i)
174 return Assignment(d_.begin() + i * width_, d_.begin() + (i + 1) * width_);
178 #if IMP_DOMINO_HAS_RMF || defined(IMP_DOXYGEN)
188 RMF::HDF5::IndexDataSet2D ds_;
191 unsigned int max_cache_;
193 virtual void do_destroy()
override { flush(); }
204 void set_cache_size(
unsigned int words);
205 virtual unsigned int get_number_of_assignments()
const override;
206 virtual Assignment get_assignment(
unsigned int i)
const override;
207 virtual void add_assignment(
const Assignment &a)
override;
216 RMF::HDF5::IndexConstDataSet2D ds_;
219 unsigned int max_cache_;
227 void set_cache_size(
unsigned int words);
228 virtual unsigned int get_number_of_assignments()
const override;
229 virtual Assignment get_assignment(
unsigned int i)
const override;
230 virtual void add_assignment(
const Assignment &a)
override;
245 unsigned int max_cache_;
262 void set_cache_size(
unsigned int words);
263 virtual unsigned int get_number_of_assignments()
const override;
264 virtual Assignment get_assignment(
unsigned int i)
const override;
265 virtual void add_assignment(
const Assignment &a)
override;
278 unsigned int max_cache_;
293 void set_cache_size(
unsigned int words);
294 virtual unsigned int get_number_of_assignments()
const override;
295 virtual Assignment get_assignment(
unsigned int i)
const override;
296 virtual void add_assignment(
const Assignment &a)
override;
312 virtual unsigned int get_number_of_assignments()
const override;
313 virtual Assignment get_assignment(
unsigned int i)
const override;
314 virtual void add_assignment(
const Assignment &a)
override;
321 typedef std::pair<Assignment, double> AP;
322 struct GreaterSecond {
323 bool operator()(
const AP &a,
const AP &b) {
return a.second < b.second; }
334 std::string name =
"HeapAssignmentContainer %1%");
335 virtual unsigned int get_number_of_assignments()
const override;
336 virtual Assignment get_assignment(
unsigned int i)
const override;
337 virtual void add_assignment(
const Assignment &a)
override;
350 void check_number()
const;
355 virtual unsigned int get_number_of_assignments()
const override;
356 virtual Assignment get_assignment(
unsigned int i)
const override;
357 virtual void add_assignment(
const Assignment &a)
override;
362 IMPDOMINO_END_NAMESPACE
The base class for containers of assignments.
#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.
Helper functions for implementing hashes.
Represent a subset of the particles being optimized.
Store the assignments in an HDF5DataSet.
Store a list of k assignments chosen from all those added to this table.
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.
Store no more than a max number of states.
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.
Simple storage of a set of Assignments.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Read the assignments from binary data on disk.
Store a configuration of a subset.
Store assignments in a compact form in memory.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
A Bayesian inference-based sampler.
Expose a range [begin, end) of an inner assignment container to consumers.
Store a set of k top scoring assignments.
Store the assignments on disk as binary data.
Store the assignments in an HDF5DataSet.