Program: 19731
Project: 19731
Buggy source:
/** 
 * This method updates the panel for this group. The panel is the set of leaders in this group The size of the panel depends on the social position of the group. If it is at the very top it has a single leader (dictator). If it is at the bottom then every member belongs to the panel (anarchism).
 * @param none
 * @return The new panel members.
 */
public TreeSet<String> updatePanel(){
  double groupSocialPosition;
  int population, panelSize;
  population=getDataModel().getMemberList().size();
  groupSocialPosition=getDataModel().getEstimatedSocialLocation();
  panelSize=(int)Math.ceil(population * groupSocialPosition - 0.5);
  if (panelSize == 0) {
    panelSize=1;
  }
  List<Tuple<String,Double>> panelCandidates=new LinkedList<Tuple<String,Double>>();
  List<String> groupMembers=getDataModel().getMemberList();
  for (  String candidate : groupMembers) {
    double sum=0;
    int numKnownTrustValues=0;
    for (    String member : groupMembers) {
      if ((getConn().getAgentById(member).getTrust(candidate) != null) && (!member.equals(candidate))) {
        sum+=getConn().getAgentById(member).getTrust(candidate);
        numKnownTrustValues++;
      }
    }
    Tuple<String,Double> tuple;
    if (numKnownTrustValues != 0) {
      tuple=new Tuple<String,Double>(candidate,sum / numKnownTrustValues);
      panelCandidates.add(tuple);
    }
  }
  Collections.sort(panelCandidates,d);
  TreeSet<String> newPanel=new TreeSet<String>();
  if (!panelCandidates.isEmpty()) {
    for (int i=0; i < panelSize; i++) {
      newPanel.add(panelCandidates.get(i).getKey());
    }
  }
  return newPanel;
}

Fixed version (ground truth):
/** 
 * This method updates the panel for this group. The panel is the set of leaders in this group The size of the panel depends on the social position of the group. If it is at the very top it has a single leader (dictator). If it is at the bottom then every member belongs to the panel (anarchism).
 * @param none
 * @return The new panel members.
 */
public TreeSet<String> updatePanel(){
  double groupSocialPosition;
  int population, panelSize;
  population=getDataModel().getMemberList().size();
  groupSocialPosition=getDataModel().getEstimatedSocialLocation();
  panelSize=(int)Math.ceil(population * groupSocialPosition - 0.5);
  if (panelSize == 0) {
    panelSize=1;
  }
  List<Tuple<String,Double>> panelCandidates=new LinkedList<Tuple<String,Double>>();
  List<String> groupMembers=getDataModel().getMemberList();
  for (  String candidate : groupMembers) {
    double sum=0;
    int numKnownTrustValues=0;
    for (    String member : groupMembers) {
      if ((getConn().getAgentById(member).getTrust(candidate) != null) && (!member.equals(candidate))) {
        sum+=getConn().getAgentById(member).getTrust(candidate);
        numKnownTrustValues++;
      }
    }
    Tuple<String,Double> tuple;
    if (numKnownTrustValues != 0) {
      tuple=new Tuple<String,Double>(candidate,sum / numKnownTrustValues);
      panelCandidates.add(tuple);
    }
  }
  Collections.sort(panelCandidates,d);
  TreeSet<String> newPanel=new TreeSet<String>();
  if (!panelCandidates.isEmpty() && (panelCandidates.size() > panelSize)) {
    for (int i=0; i < panelSize; i++) {
      newPanel.add(panelCandidates.get(i).getKey());
    }
  }
  return newPanel;
}