public void forwardSelect(boolean withReplacement, Instances instances,
      int metric) throws Exception {
    
    double bestPerformance = -1.0;
    int bestIndex = -1;
    double tempPredictions[][];
    for (int i = 0; i < m_bagSize; ++i) {
      // For each model in the bag
      if ((m_timesChosen[i] == 0) || withReplacement) {
	// If the model has not been chosen, or we're allowing
	// replacement
	// Get the predictions we would have if we add this model to the
	// ensemble
	tempPredictions = computePredictions(i, true);
	// And find out how the hypothetical ensemble would perform.
	double metric_value = evaluatePredictions(instances,
	    tempPredictions, metric);
	if (metric_value > bestPerformance) {
	  // If it's better than our current best, make it our NEW
	  // best.
	  bestIndex = i;
	  bestPerformance = metric_value;
	}
      }
    }
    if (bestIndex == -1) {
      // Replacement must be false, with more hillclimb iterations than
      // models. Do nothing and return.
      if (m_debug) {
	System.out.println("Couldn't add model.  No action performed.");
      }
      return;
    }
    // We picked bestIndex as our best model. Update appropriate info.
    m_timesChosen[bestIndex]++;
    m_numChosen++;
    if (bestPerformance > m_bestPerformance) {
      // We find the peak of our performance over all hillclimb
      // iterations.
      // If this forwardSelect step improved our overall performance,
      // update
      // our best ensemble info.
      updateBestTimesChosen();
      m_bestPerformance = bestPerformance;
    }
  }