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_distribution.hpp>
23 #include <boost/random/uniform_real_distribution.hpp>
24 #include <boost/shared_array.hpp>
28 #ifdef IMP_DOMINO_USE_IMP_RMF
29 # include <RMF/config.h>
30 # if RMF_HAS_DEPRECATED_BACKENDS
31 # include <RMF/HDF5/Group.h>
32 # include <RMF/HDF5/File.h>
40 IMPDOMINO_BEGIN_NAMESPACE
50 virtual unsigned int get_number_of_assignments()
const = 0;
51 virtual Assignment get_assignment(
unsigned int i)
const = 0;
52 virtual Assignments get_assignments(IntRange ir)
const = 0;
54 virtual void add_assignment(
const Assignment &a) = 0;
55 virtual void add_assignments(
const Assignments &asgn) = 0;
57 virtual Ints get_particle_assignments(
unsigned int i)
const = 0;
74 "PackedAssignmentContainer %1%");
75 virtual unsigned int get_number_of_assignments()
const override;
76 virtual Assignment get_assignment(
unsigned int i)
const override;
77 virtual void add_assignment(
const Assignment &a)
override;
84 inline unsigned int PackedAssignmentContainer::get_number_of_assignments()
86 if (width_ == -1)
return 0;
87 return d_.size() / width_;
90 inline Assignment PackedAssignmentContainer::get_assignment(
unsigned int i)
93 "Invalid assignment requested: " << i);
94 IMP_USAGE_CHECK(width_ > 0,
"Uninitialized PackedAssignmentContainer.");
95 return Assignment(d_.begin() + i * width_, d_.begin() + (i + 1) * width_);
98 inline void PackedAssignmentContainer::add_assignment(
const Assignment &a) {
104 "Sizes don't match " << width_ <<
" vs " << a.size());
106 for (
unsigned int i = 0; i < get_number_of_assignments(); ++i) {
108 << a <<
" already here.");
111 d_.insert(d_.end(), a.begin(), a.end());
124 virtual unsigned int get_number_of_assignments()
const override;
125 virtual Assignment get_assignment(
unsigned int i)
const override;
126 virtual void add_assignment(
const Assignment &a)
override;
132 inline unsigned int ListAssignmentContainer::get_number_of_assignments()
const {
136 inline Assignment ListAssignmentContainer::get_assignment(
unsigned int i)
141 inline void ListAssignmentContainer::add_assignment(
const Assignment &a) {
155 boost::random::uniform_real_distribution<double> select_;
156 boost::random::uniform_int_distribution<> place_;
161 "SampleAssignmentContainer %1%");
162 virtual unsigned int get_number_of_assignments()
const override;
163 virtual Assignment get_assignment(
unsigned int i)
const override;
164 virtual void add_assignment(
const Assignment &a)
override;
170 inline unsigned int SampleAssignmentContainer::get_number_of_assignments()
172 return d_.size() / width_;
175 inline Assignment SampleAssignmentContainer::get_assignment(
unsigned int i)
177 return Assignment(d_.begin() + i * width_, d_.begin() + (i + 1) * width_);
181 #if RMF_HAS_DEPRECATED_BACKENDS || defined(IMP_DOXYGEN)
191 RMF::HDF5::IndexDataSet2D ds_;
194 unsigned int max_cache_;
196 virtual void do_destroy()
override { flush(); }
207 void set_cache_size(
unsigned int words);
208 virtual unsigned int get_number_of_assignments()
const override;
209 virtual Assignment get_assignment(
unsigned int i)
const override;
210 virtual void add_assignment(
const Assignment &a)
override;
219 RMF::HDF5::IndexConstDataSet2D ds_;
222 unsigned int max_cache_;
230 void set_cache_size(
unsigned int words);
231 virtual unsigned int get_number_of_assignments()
const override;
232 virtual Assignment get_assignment(
unsigned int i)
const override;
233 virtual void add_assignment(
const Assignment &a)
override;
248 unsigned int max_cache_;
265 void set_cache_size(
unsigned int words);
266 virtual unsigned int get_number_of_assignments()
const override;
267 virtual Assignment get_assignment(
unsigned int i)
const override;
268 virtual void add_assignment(
const Assignment &a)
override;
281 unsigned int max_cache_;
296 void set_cache_size(
unsigned int words);
297 virtual unsigned int get_number_of_assignments()
const override;
298 virtual Assignment get_assignment(
unsigned int i)
const override;
299 virtual void add_assignment(
const Assignment &a)
override;
315 virtual unsigned int get_number_of_assignments()
const override;
316 virtual Assignment get_assignment(
unsigned int i)
const override;
317 virtual void add_assignment(
const Assignment &a)
override;
324 typedef std::pair<Assignment, double> AP;
325 struct GreaterSecond {
326 bool operator()(
const AP &a,
const AP &b) {
return a.second < b.second; }
337 std::string name =
"HeapAssignmentContainer %1%");
338 virtual unsigned int get_number_of_assignments()
const override;
339 virtual Assignment get_assignment(
unsigned int i)
const override;
340 virtual void add_assignment(
const Assignment &a)
override;
353 void check_number()
const;
358 virtual unsigned int get_number_of_assignments()
const override;
359 virtual Assignment get_assignment(
unsigned int i)
const override;
360 virtual void add_assignment(
const Assignment &a)
override;
365 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.