Ejemplo n.º 1
0
void Colour_Generator::PickTwoColours(const size_t & beam,int * cols) {
  Flow flow;
  size_t index;
  cols[0] = cols[1] = -1;
  for (index=0;index<2;index++) {
    if (m_col[beam][index].size()==0) cols[index] = flow.Counter();
    else {
      cols[index] = (*m_col[beam][index].begin());
    }
  }
  if (cols[0]==cols[1]) {
    if (m_col[beam][0].size()==1 && m_col[beam][1].size()==1) {
      cols[ran->Get()>0.5?0:1] = flow.Counter();
    }
    else {
      index = m_col[beam][0].size()>m_col[beam][1].size()?0:1;
      set<int>::iterator cit=m_col[beam][index].begin();
      cit++;
      cols[index] = (*cit);
      m_col[beam][index].erase(cols[index]);
    }
  }
  for (index=0;index<2;index++) {
    if (cols[index]==(*m_col[beam][1-index].begin())) {
      m_col[beam][1-index].erase(cols[index]);
    }
  }
  msg_Tracking()<<METHOD<<" yields "<<cols[0]<<" "<<cols[1]<<".\n";
}
Ejemplo n.º 2
0
int Colour_Generator::
PickColourPair(const size_t & beam,const size_t & index) {
  msg_Tracking()<<METHOD<<"(beam = "<<beam<<", index = "<<index<<"): "
		<<m_col[beam][index].size()<<" "<<m_col[1-beam][1-index].size();
  int col(-1);
  for (set<int>::iterator cit1=m_col[beam][index].begin();
       cit1!=m_col[beam][index].end();cit1++) {
    for (set<int>::iterator cit2=m_col[1-beam][1-index].begin();
	 cit2!=m_col[1-beam][1-index].end();cit2++) {
      if ((*cit1)==(*cit2)) {
	col = (*cit1);
	m_col[beam][index].erase(col);
	m_col[1-beam][1-index].erase(col);
	break;
      }
    }
    if (col!=-1) break;
  }
  if (col==-1) {
    Flow Flow;
    col = Flow.Counter();
    m_col[beam][1-index].insert(col);
    m_col[1-beam][index].insert(col);
  }
  msg_Tracking()<<" ---> "<<col<<".\n";
  return col;
}
Ejemplo n.º 3
0
int Colour_Generator::
PickOneColour(const size_t & beam,const size_t & index,const int & avoid) {
  msg_Tracking()<<METHOD<<"(beam = "<<beam<<", index = "<<index<<", "
		<<"avoid = "<<avoid<<"): sizes = "
		<<m_col[beam][index].size()<<" "<<m_col[1-beam][1-index].size();
  int col(-1);
  for (set<int>::iterator cit=m_col[beam][index].begin();
       cit!=m_col[beam][index].end();cit++) {
    if ((*cit)!=avoid) {
      col = (*cit);
      m_col[beam][index].erase(col);
      break;
    }
  }
  if (col==-1) {
    Flow Flow;
    col = Flow.Counter();
    m_col[beam][1-index].insert(col);
  }
  msg_Tracking()<<" ---> "<<col<<".\n";
  return col;
}