SimpleAllToAllWiringMethod.cpp

Go to the documentation of this file.
00001 
00011 #include "SimpleAllToAllWiringMethod.h"
00012 
00013 #include <iostream>
00014 using std::cout;
00015 using std::cerr;
00016 using std::endl;
00017 
00018 SimObject::ID::Vector SimpleAllToAllWiringMethod::connect(
00019     const SimObjectPopulation &srcPopulation,
00020     const SimObjectPopulation &destPopulation,
00021     const SimObjectFactory &connector,
00022     ConnectionIterator &decider,
00023     bool collectIDs,
00024     bool collectPairs,
00025     WiringMethod::ConnectPairsVector connectPairs)
00026 {
00027     decider.setRNDEngine(net->getMainConstructRNGEngine());
00028     decider.init(srcPopulation, destPopulation);
00029 //    decider.setRNDEngine(net->getMainConstructRNGEngine());
00030 
00031     SimObject::ID::SortedVector  src_vec(  srcPopulation.idVector(), net->mpi_rank(), false);
00032     SimObject::ID::SortedVector dest_vec( destPopulation.idVector(), net->mpi_rank(), false);
00033 
00034     SimObject::ID id;
00035     SimObject::ID::Vector collids(new vector<SimObject::ID::Packed>);
00036 
00037     decider.reset(src_vec.begin(), src_vec.end(), dest_vec.begin(), dest_vec.end());
00038 
00039     unsigned cnt = 0;
00040     pair<SimObject::ID, SimObject::ID> connect_pair;
00041 
00042     while( decider.next(connect_pair) ) {
00043         net->connect( connect_pair.first, connect_pair.second, connector, id );
00044         if (collectPairs)
00045             connectPairs->push_back(connect_pair);
00046         if (collectIDs) {
00047             collids->push_back(id.packed() );
00048         }
00049         cnt++;
00050     }
00051 
00052     if (!collectIDs)
00053         collids->push_back( (SimObject::ID::Packed)cnt );
00054 
00055     return collids;
00056 }
00057 
00058 
00059 unsigned SimpleAllToAllWiringMethod::connect(
00060     const SimObjectPopulation &srcPopulation,
00061     const SimObjectPopulation &destPopulation,
00062     ConnectionIterator &decider,
00063     bool collectPairs,
00064     WiringMethod::ConnectPairsVector connectPairs )
00065 {
00066     decider.setRNDEngine(net->getMainConstructRNGEngine());
00067     decider.init(srcPopulation, destPopulation);
00068 //    decider.setRNDEngine(net->getMainConstructRNGEngine());
00069 
00070     SimObject::ID::SortedVector src_vec(srcPopulation.idVector(), net->mpi_rank(), false);
00071     SimObject::ID::SortedVector dest_vec(destPopulation.idVector(), net->mpi_rank(), false);
00072     unsigned cnt = 0;
00073     decider.reset(src_vec.begin(), src_vec.end(), dest_vec.begin(), dest_vec.end());
00074     pair<SimObject::ID, SimObject::ID> connect_pair;
00075     if (collectPairs) {
00076         while( decider.next( connect_pair ) ) {
00077             net->connect(connect_pair.first, connect_pair.second);
00078             connectPairs->push_back(connect_pair);
00079             cnt++;
00080         }
00081     } else {
00082         while( decider.next( connect_pair ) ) {
00083             net->connect(connect_pair.first, connect_pair.second);
00084             cnt++;
00085         }
00086     }
00087     return cnt;
00088 }
00089 
00090 
00091 SimObject::ID::Vector SimpleAllToAllWiringMethod::connect(
00092     const SimObjectPopulation &srcPopulation,
00093     const SimObjectPopulation &destPopulation,
00094     ConnObjectFactory &connector,
00095     ConnectionIterator &decider,
00096     bool collectIDs,
00097     bool collectPairs,
00098     WiringMethod::ConnectPairsVector connectPairs)
00099 {
00100     decider.setRNDEngine(net->getMainConstructRNGEngine());
00101     decider.init(srcPopulation, destPopulation);
00102 //    decider.setRNDEngine(net->getMainConstructRNGEngine());
00103 
00104     SimObject::ID::SortedVector  src_vec(  srcPopulation.idVector(), net->mpi_rank(), false);
00105     SimObject::ID::SortedVector dest_vec( destPopulation.idVector(), net->mpi_rank(), false);
00106 
00107     SimObject::ID id;
00108     SimObject::ID::Vector collids(new vector<SimObject::ID::Packed>);
00109 
00110     decider.reset(src_vec.begin(), src_vec.end(), dest_vec.begin(), dest_vec.end());
00111 
00112     unsigned cnt = 0;
00113     pair<SimObject::ID, SimObject::ID> connect_pair;
00114 
00115     while( decider.next(connect_pair) )
00116     {
00117         size_t src_idx, dst_idx;
00118         decider.getIdx(src_idx, dst_idx);
00119         connector.init(srcPopulation, src_idx, destPopulation, dst_idx);
00120 
00121         net->connect(connect_pair.first, connect_pair.second, connector, id);
00122 
00123         if (collectPairs)
00124             connectPairs->push_back(connect_pair);
00125 
00126         if (collectIDs) 
00127             collids->push_back(id.packed());
00128 
00129         cnt++;
00130     }
00131 
00132     if (!collectIDs)
00133         collids->push_back( (SimObject::ID::Packed)cnt );
00134 
00135     return collids;
00136 }
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 

Generated on Wed Jul 9 16:34:37 2008 for PCSIM by  doxygen 1.5.5