private List<Subset> generateNeighborhood(BitSet S, int numNeighborhood)
  throws Exception{
    int counter = 0;
    List<Subset> neighborhood = new ArrayList<Subset>();

    int numAttribs = (m_classIndex == -1) ? m_numAttribs  : m_numAttribs - 1;

    if(numNeighborhood >= numAttribs){
      for (int i = 0; i < m_numAttribs; i++) {
        if(i == m_classIndex)continue;

        BitSet aux = (BitSet)S.clone ();
        aux.flip (i);

        if(!m_vectorTabu.contains (aux)){
          neighborhood.add (new Subset((BitSet)aux.clone (), ASEvaluator.evaluateSubset (aux)));
          m_totalEvals ++;
        }
      }
    }
    else{
      while (counter < numNeighborhood) {
        BitSet aux = (BitSet)S.clone ();

        int randomNumber = m_random.nextInt (m_numAttribs);
        if(randomNumber == m_classIndex)
          continue;

        aux.flip (randomNumber);
        if(!m_vectorTabu.contains (aux)){
          neighborhood.add (new Subset((BitSet)aux.clone (), ASEvaluator.evaluateSubset (aux)));
          m_totalEvals ++;
          counter ++;
        }
      }
    }

    if(neighborhood.isEmpty ())
      return null;

    return bubbleSubsetSort (neighborhood);
  }