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>
29 #include <boost/random.hpp>
36 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 &as)=0;
53 virtual Ints get_particle_assignments(
unsigned int i)
const=0;
76 PackedAssignmentContainer::get_number_of_assignments()
const {
77 if (width_==-1)
return 0;
78 return d_.size()/width_;
82 PackedAssignmentContainer::get_assignment(
unsigned int i)
const {
84 "Invalid assignment requested: " << i);
86 return Assignment(d_.begin()+i*width_,
87 d_.begin()+(i+1)*width_);
90 inline void PackedAssignmentContainer::add_assignment(
const Assignment& a) {
96 "Sizes don't match " << width_
97 <<
" vs " << a.size());
99 for (
unsigned int i=0; i< get_number_of_assignments(); ++i) {
101 "Assignment " << a <<
" already here.");
104 d_.insert(d_.end(), a.begin(), a.end());
120 inline unsigned int ListAssignmentContainer::get_number_of_assignments()
const {
125 ListAssignmentContainer::get_assignment(
unsigned int i)
const {
129 inline void ListAssignmentContainer::add_assignment(
const Assignment& a) {
149 boost::uniform_real<double> select_;
150 boost::uniform_int<> place_;
153 std::string name=
"SampleAssignmentsContainer %1%");
159 SampleAssignmentContainer::get_number_of_assignments()
const {
160 return d_.size()/width_;
164 SampleAssignmentContainer::get_assignment(
unsigned int i)
const {
165 return Assignment(d_.begin()+i*width_,
166 d_.begin()+(i+1)*width_);
174 #if IMP_DOMINO_HAS_RMF || defined(IMP_DOXYGEN)
183 RMF::HDF5::IndexDataSet2D ds_;
186 unsigned int max_cache_;
191 const ParticlesTemp &all_particles,
196 const ParticlesTemp &all_particles,
198 void set_cache_size(
unsigned int words);
207 RMF::HDF5::IndexConstDataSet2D ds_;
210 unsigned int max_cache_;
216 const ParticlesTemp &all_particles,
218 void set_cache_size(
unsigned int words);
232 unsigned int max_cache_;
238 const ParticlesTemp &all_particles,
240 void set_cache_size(
unsigned int words);
262 unsigned int max_cache_;
268 const ParticlesTemp &all_particles,
270 void set_cache_size(
unsigned int words);
284 Pointer<AssignmentContainer> inner_;
288 unsigned int begin,
unsigned int end);
296 typedef std::pair<Assignment,double> AP;
297 struct GreaterSecond {
298 bool operator()(
const AP &a,
300 return a.second < b.second;
309 Pointer<RestraintCache> rssf_;
313 std::string name=
"HeapAssignmentsContainer %1%");
322 Pointer<AssignmentContainer> contained_;
324 void check_number()
const;
336 IMPDOMINO_END_NAMESPACE