Program: 57275
Project: 57275
Buggy source:
/** 
 * Returns the row with the minimum ratio as given by the minimum ratio test (MRT).
 * @param tableau simple tableau for the problem
 * @param col the column to test the ratio of.  See {@link #getPivotColumn(SimplexTableau)}
 * @return row with the minimum ratio
 */
private Integer getPivotRow(SimplexTableau tableau,final int col){
  List<Integer> minRatioPositions=new ArrayList<Integer>();
  double minRatio=Double.MAX_VALUE;
  for (int i=tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) {
    final double rhs=tableau.getEntry(i,tableau.getWidth() - 1);
    final double entry=tableau.getEntry(i,col);
    if (Precision.compareTo(entry,0d,maxUlps) > 0) {
      final double ratio=rhs / entry;
      final int cmp=Double.compare(ratio,minRatio);
      if (cmp == 0) {
        minRatioPositions.add(i);
      }
 else       if (cmp < 0) {
        minRatio=ratio;
        minRatioPositions=new ArrayList<Integer>();
        minRatioPositions.add(i);
      }
    }
  }
  if (minRatioPositions.size() == 0) {
    return null;
  }
 else   if (minRatioPositions.size() > 1) {
    if (tableau.getNumArtificialVariables() > 0) {
      for (      Integer row : minRatioPositions) {
        for (int i=0; i < tableau.getNumArtificialVariables(); i++) {
          int column=i + tableau.getArtificialVariableOffset();
          final double entry=tableau.getEntry(row,column);
          if (Precision.equals(entry,1d,maxUlps) && row.equals(tableau.getBasicRow(column))) {
            return row;
          }
        }
      }
    }
    if (getIterations() < getMaxIterations() / 2) {
      Integer minRow=null;
      int minIndex=tableau.getWidth();
      for (      Integer row : minRatioPositions) {
        int i=tableau.getNumObjectiveFunctions();
        for (; i < tableau.getWidth() - 1 && minRow != row; i++) {
          if (row == tableau.getBasicRow(i)) {
            if (i < minIndex) {
              minIndex=i;
              minRow=row;
            }
          }
        }
      }
      return minRow;
    }
  }
  return minRatioPositions.get(0);
}

Fixed version (ground truth):
/** 
 * Returns the row with the minimum ratio as given by the minimum ratio test (MRT).
 * @param tableau simple tableau for the problem
 * @param col the column to test the ratio of.  See {@link #getPivotColumn(SimplexTableau)}
 * @return row with the minimum ratio
 */
private Integer getPivotRow(SimplexTableau tableau,final int col){
  List<Integer> minRatioPositions=new ArrayList<Integer>();
  double minRatio=Double.MAX_VALUE;
  for (int i=tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) {
    final double rhs=tableau.getEntry(i,tableau.getWidth() - 1);
    final double entry=tableau.getEntry(i,col);
    if (Precision.compareTo(entry,0d,maxUlps) > 0) {
      final double ratio=rhs / entry;
      final int cmp=Double.compare(ratio,minRatio);
      if (cmp == 0) {
        minRatioPositions.add(i);
      }
 else       if (cmp < 0) {
        minRatio=ratio;
        minRatioPositions=new ArrayList<Integer>();
        minRatioPositions.add(i);
      }
    }
  }
  if (minRatioPositions.size() == 0) {
    return null;
  }
 else   if (minRatioPositions.size() > 1) {
    if (tableau.getNumArtificialVariables() > 0) {
      for (      Integer row : minRatioPositions) {
        for (int i=0; i < tableau.getNumArtificialVariables(); i++) {
          int column=i + tableau.getArtificialVariableOffset();
          final double entry=tableau.getEntry(row,column);
          if (Precision.equals(entry,1d,maxUlps) && row.equals(tableau.getBasicRow(column))) {
            return row;
          }
        }
      }
    }
    if (getIterations() < getMaxIterations() / 2) {
      Integer minRow=null;
      int minIndex=tableau.getWidth();
      for (      Integer row : minRatioPositions) {
        int i=tableau.getNumObjectiveFunctions();
        for (; i < tableau.getWidth() - 1 && !row.equals(minRow); i++) {
          Integer basicRow=tableau.getBasicRow(i);
          if (basicRow != null && basicRow.equals(row)) {
            if (i < minIndex) {
              minIndex=i;
              minRow=row;
            }
          }
        }
      }
      return minRow;
    }
  }
  return minRatioPositions.get(0);
}