コード例 #1
0
ファイル: FWSingle.cpp プロジェクト: jyamu/qmc
void FWSingle::fillIDMatrix()
{
  if (verbose>0)
    app_log()<<" There are "<<numSteps<<" steps"<<endl;
  IDs.resize(numSteps);
  PIDs.resize(numSteps);
  Weights.resize(numSteps);
  vector<vector<long> >::iterator stepIDIterator(IDs.begin());
  vector<vector<long> >::iterator stepPIDIterator(PIDs.begin());
  int st(0);
  do
  {
    readInLong(st ,WIDstring ,*(stepIDIterator));
    readInLong(st ,PIDstring ,*(stepPIDIterator));
    walkersPerBlock.push_back( (*stepIDIterator).size() );
    stepIDIterator++;
    stepPIDIterator++;
    st++;
    if (verbose>1)
      app_log()<<"step:"<<st<<endl;
  }
  while (st<numSteps);
  //     Weights.resize( IDs.size());
  for(int i=0; i<numSteps; i++)
    Weights[i].resize(IDs[i].size(),1);
  realPIDs = PIDs;
  realIDs = IDs;
}
コード例 #2
0
ファイル: FWSingle.cpp プロジェクト: jyamu/qmc
void FWSingle::FWOneStep()
{
  //create an ordered version of the ParentIDs to make the weight calculation faster
  vector<vector<long> > orderedPIDs=(PIDs);
  vector<vector<long> >::iterator it(orderedPIDs.begin());
  do
  {
    std::sort((*it).begin(),(*it).end());
    it++;
  }
  while(it<orderedPIDs.end());
  if (verbose>2)
    app_log()<<" Done Sorting IDs"<<endl;
  resetWeights();
  vector<vector<long> >::iterator stepIDIterator(IDs.begin());
  vector<vector<long> >::iterator stepPIDIterator(orderedPIDs.begin() + gensTransferred);
  vector<vector<int> >::iterator stepWeightsIterator(Weights.begin());
  //we start comparing the next generations ParentIDs with the current generations IDs
  int i=0;
  do
  {
    if (verbose>2)
      app_log()<<"  calculating weights for gen:"<<gensTransferred<<" step:"<<i<<"/"<<orderedPIDs.size()<<endl;
    //       if (verbose>2) app_log()<<"Nsamples ="<<(*stepWeightsIteratoetWeights).size()<<endl;
    vector<long>::iterator IDit( (*stepIDIterator).begin()     );
    vector<long>::iterator PIDit( (*stepPIDIterator).begin()   );
    vector<int>::iterator  Wit( (*stepWeightsIterator).begin() );
    if (verbose>2)
      app_log()<<"ID size:"<<(*stepIDIterator).size()<<" PID size:"<<(*stepPIDIterator).size()<<" Weight size:"<<(*stepWeightsIterator).size()<<endl;
    do
    {
      if ((*PIDit)==(*IDit))
      {
        (*Wit)++;
        PIDit++;
      }
      else
      {
        IDit++;
        Wit++;
        if (IDit==(*stepIDIterator).end())
        {
          IDit=(*stepIDIterator).begin();
          Wit=(*stepWeightsIterator).begin();
        }
      }
    }
    while(PIDit<(*stepPIDIterator).end());
    //       if (verbose>2) { printIDs((*stepIDIterator));printIDs((*stepPIDIterator));}
    //       if (verbose>2) printInts((*stepWeightsIterator));
    stepIDIterator++;
    stepPIDIterator++;
    stepWeightsIterator++;
    i++;
  }
  while(stepPIDIterator<orderedPIDs.end());
}
コード例 #3
0
ファイル: FWSingle.cpp プロジェクト: jyamu/qmc
void FWSingle::transferParentsOneGeneration( )
{
  vector<vector<long> >::reverse_iterator stepIDIterator(IDs.rbegin());
  vector<vector<long> >::reverse_iterator stepPIDIterator(PIDs.rbegin()), nextStepPIDIterator(realPIDs.rbegin());
  stepIDIterator+=gensTransferred;
  nextStepPIDIterator+=gensTransferred;
  int i(0);
  do
  {
    vector<long>::iterator hereID( (*stepIDIterator).begin() ) ;
    vector<long>::iterator nextStepPID( (*nextStepPIDIterator).begin() );
    vector<long>::iterator herePID( (*stepPIDIterator).begin() );
    if (verbose>2)
      app_log()<<"  calculating Parent IDs for gen:"<<gensTransferred<<" step:"<<i<<"/"<<PIDs.size()-gensTransferred<<endl;
    if (verbose>2)
    {
      printIDs((*nextStepPIDIterator));
      printIDs((*stepIDIterator));
      printIDs((*stepPIDIterator));
    }
    do
    {
      if ((*herePID)==(*hereID))
      {
        (*herePID)=(*nextStepPID);
        herePID++;
      }
      else
      {
        hereID++;
        nextStepPID++;
        if (hereID==(*stepIDIterator).end())
        {
          hereID=(*stepIDIterator).begin();
          nextStepPID=(*nextStepPIDIterator).begin();
          //             if (verbose>2) app_log()<<"resetting to beginning of parents"<<endl;
        }
      }
    }
    while(herePID<(*stepPIDIterator).end());
    stepIDIterator++;
    nextStepPIDIterator++;
    stepPIDIterator++;
    i++;
  }
  while(stepIDIterator<IDs.rend());
  gensTransferred++; //number of gens backward to compare parents
  if (verbose>2)
    app_log()<<"  Finished generation block"<<endl;
}
コード例 #4
0
ファイル: FWSingleOMP.cpp プロジェクト: digideskio/qmcpack
 void FWSingleOMP::fillIDMatrix()
 {
   if (verbose>0) app_log()<<" There are "<<numSteps<<" steps"<<endl;
   IDs.resize(numSteps); PIDs.resize(numSteps); Weights.resize(numSteps);
   vector<vector<long> >::iterator stepIDIterator(IDs.begin());
   vector<vector<long> >::iterator stepPIDIterator(PIDs.begin());
   int st(0);
   hdf_ID_data.openFile(fname.str());
   hdf_PID_data.openFile(fname.str());
   do
   {
     hdf_ID_data.readAll(st,*(stepIDIterator));
     hdf_PID_data.readAll(st,*(stepPIDIterator));
     walkersPerBlock.push_back( (*stepIDIterator).size() );
     stepIDIterator++; stepPIDIterator++; st++;
     if (verbose>1) app_log()<<"step:"<<st<<endl;
   } while (st<numSteps);
   hdf_ID_data.closeFile();
   hdf_PID_data.closeFile();
   //     Weights.resize( IDs.size());
   for(int i=0;i<numSteps;i++) Weights[i].resize(IDs[i].size(),1);
   realPIDs = PIDs;
   realIDs = IDs;
 }