00001 00012 #ifndef RANDOMFIXNUMBERCONNECTIONS_H 00013 #define RANDOMFIXNUMBERCONNECTIONS_H 00014 00015 #include <ConnectionIterator.h> 00016 #include <set> 00017 using std::set; 00018 00020 00023 class RandomFixNumberConnections : public ConnectionIterator 00024 { 00025 public: 00026 typedef set< pair<int, int> > ConnectedPairsVector; 00027 00029 RandomFixNumberConnections( const double conn_prob ); 00030 00032 RandomFixNumberConnections( const double conn_prob, MPI::Intracomm const& mpiComm ); 00033 00034 virtual ~RandomFixNumberConnections(); 00035 00036 virtual void init(const SimObjectPopulation &srcPopulation, const SimObjectPopulation &destPopulation); 00037 00038 virtual void reset(SimObject::ID::SortedVector::const_iterator src_begin_it, 00039 SimObject::ID::SortedVector::const_iterator src_end_it, 00040 SimObject::ID::SortedVector::const_iterator dest_begin_it, 00041 SimObject::ID::SortedVector::const_iterator dest_end_it); 00042 00043 virtual bool next( pair<SimObject::ID, SimObject::ID> &connection ); 00044 00045 virtual size_t estimate(); 00046 00047 00048 protected: 00049 ConnectedPairsVector connected_pairs; 00050 00051 double conn_prob; 00052 const SimObjectPopulation * src_popul; 00053 const SimObjectPopulation * dest_popul; 00054 00055 UniformDistribution *uni_rnd; 00056 00057 int curr_src_idx; 00058 int curr_dest_idx; 00059 00060 int src_max_idx; 00061 int dest_max_idx; 00062 00063 unsigned int num_connections; 00064 00065 SimObject::ID::SortedVector::const_iterator from_begin_it; 00066 SimObject::ID::SortedVector::const_iterator to_begin_it; 00067 }; 00068 00069 #endif