9 #ifndef IMPDOMINO_ASSIGNMENT_CONTAINERS_H
10 #define IMPDOMINO_ASSIGNMENT_CONTAINERS_H
12 #include <IMP/domino/domino_config.h>
18 #if IMP_DOMINO_HAS_RMF
19 #include <RMF/HDF5/Group.h>
20 #include <RMF/HDF5/File.h>
22 #include <boost/shared_array.hpp>
34 IMPDOMINO_BEGIN_NAMESPACE
43 virtual unsigned int get_number_of_assignments()
const = 0;
44 virtual Assignment get_assignment(
unsigned int i)
const = 0;
45 virtual Assignments get_assignments(IntRange ir)
const = 0;
47 virtual void add_assignment(
const Assignment &a) = 0;
48 virtual void add_assignments(
const Assignments &as) = 0;
50 virtual Ints get_particle_assignments(
unsigned int i)
const = 0;
67 "PackedAssignmentsContainer %1%");
68 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
69 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
70 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
77 inline unsigned int PackedAssignmentContainer::get_number_of_assignments()
79 if (width_ == -1)
return 0;
80 return d_.size() / width_;
83 inline Assignment PackedAssignmentContainer::get_assignment(
84 unsigned int i)
const {
86 "Invalid assignment requested: " << i);
87 IMP_USAGE_CHECK(width_ > 0,
"Uninitualized PackedAssignmentContainer.");
88 return Assignment(d_.begin() + i * width_, d_.begin() + (i + 1) * width_);
91 inline void PackedAssignmentContainer::add_assignment(
const Assignment &a) {
97 "Sizes don't match " << width_ <<
" vs " << a.size());
99 for (
unsigned int i = 0; i < get_number_of_assignments(); ++i) {
101 << a <<
" already here.");
104 d_.insert(d_.end(), a.begin(), a.end());
117 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
118 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
119 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
125 inline unsigned int ListAssignmentContainer::get_number_of_assignments()
const {
129 inline Assignment ListAssignmentContainer::get_assignment(
130 unsigned int i)
const {
134 inline void ListAssignmentContainer::add_assignment(
const Assignment &a) {
150 boost::uniform_real<double> select_;
151 boost::uniform_int<> place_;
156 "SampleAssignmentsContainer %1%");
157 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
158 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
159 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
165 inline unsigned int SampleAssignmentContainer::get_number_of_assignments()
167 return d_.size() / width_;
170 inline Assignment SampleAssignmentContainer::get_assignment(
171 unsigned int i)
const {
172 return Assignment(d_.begin() + i * width_, d_.begin() + (i + 1) * width_);
176 #if IMP_DOMINO_HAS_RMF || defined(IMP_DOXYGEN)
186 RMF::HDF5::IndexDataSet2D ds_;
189 unsigned int max_cache_;
191 virtual void do_destroy() IMP_OVERRIDE { flush(); }
202 void set_cache_size(
unsigned int words);
203 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
204 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
205 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
214 RMF::HDF5::IndexConstDataSet2D ds_;
217 unsigned int max_cache_;
226 void set_cache_size(
unsigned int words);
227 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
228 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
229 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
243 unsigned int max_cache_;
260 void set_cache_size(
unsigned int words);
261 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
262 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
263 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
276 unsigned int max_cache_;
291 void set_cache_size(
unsigned int words);
292 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
293 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
294 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
310 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
311 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
312 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
320 typedef std::pair<Assignment, double> AP;
321 struct GreaterSecond {
322 bool operator()(
const AP &a,
const AP &b) {
return a.second < b.second; }
333 std::string name =
"HeapAssignmentsContainer %1%");
334 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
335 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
336 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
347 void check_number()
const;
352 virtual unsigned int get_number_of_assignments()
const IMP_OVERRIDE;
353 virtual Assignment get_assignment(
unsigned int i)
const IMP_OVERRIDE;
354 virtual void add_assignment(
const Assignment &a) IMP_OVERRIDE;
359 IMPDOMINO_END_NAMESPACE
A beyesian infererence-based sampler.
Store a persistent ordering for a subset based on the list.
A smart pointer to a reference counted object.
Represent a subset of the particles being optimized.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
#define IMP_ASSIGNMENT_CONTAINER_METHODS(Name)
A class for storing lists of IMP items.
#define IMP_IF_CHECK(level)
Execute the code block if a certain level checks are on.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A beyesian infererence-based sampler.
Common base class for heavy weight IMP objects.
#define IMP_OBJECT_LOG
Set the log level to the object's log level.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Store a configuration of a subset.
virtual void do_destroy()
A beyesian infererence-based sampler.
Declare an efficient stl-compatible map.