Program: 58753
Project: 58753
Buggy source:
/** 
 * Calculates the similarity matrix for a given set and VA�s
 * @param set
 * @param iVAIdContent
 * @param iVAIdStorage
 * @return
 */
public int determineSimilarities(ISet set,Integer iVAIdContent,Integer iVAIdStorage,EClustererType eClustererType){
  this.iVAIdContent=iVAIdContent;
  this.iVAIdStorage=iVAIdStorage;
  IVirtualArray contentVA=set.getVA(iVAIdContent);
  IVirtualArray storageVA=set.getVA(iVAIdStorage);
  IDistanceMeasure distanceMeasure;
  if (eDistanceMeasure == EDistanceMeasure.EUCLIDEAN_DISTANCE)   distanceMeasure=new EuclideanDistance();
 else   distanceMeasure=new PearsonCorrelation();
  int iPercentage=1;
  if (eClustererType == EClustererType.GENE_CLUSTERING) {
    float[] dArInstance1=new float[storageVA.size()];
    float[] dArInstance2=new float[storageVA.size()];
    int icnt1=0, icnt2=0, isto=0;
    int count=0;
    for (    Integer iContentIndex1 : contentVA) {
      if (bClusteringCanceled == false) {
        int tempPercentage=(int)((float)icnt1 / contentVA.size() * 100);
        if (iPercentage == tempPercentage) {
          GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,true));
          iPercentage++;
        }
        isto=0;
        for (        Integer iStorageIndex1 : storageVA) {
          dArInstance1[isto]=set.get(iStorageIndex1).getFloat(EDataRepresentation.NORMALIZED,iContentIndex1);
          isto++;
        }
        icnt2=0;
        for (        Integer iContentIndex2 : contentVA) {
          isto=0;
          for (          Integer iStorageIndex2 : storageVA) {
            dArInstance2[isto]=set.get(iStorageIndex2).getFloat(EDataRepresentation.NORMALIZED,iContentIndex2);
            isto++;
          }
          if (icnt1 != icnt2) {
            s[count]=-distanceMeasure.getMeasure(dArInstance1,dArInstance2);
            i[count]=icnt1;
            k[count]=icnt2;
            count++;
          }
          icnt2++;
        }
        icnt1++;
        processEvents();
      }
 else {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,false));
        return -1;
      }
    }
    float median=ClusterHelper.median(s);
    int cnt=0;
    for (    Integer iContentIndex1 : contentVA) {
      s[count]=median * fClusterFactor;
      i[count]=cnt;
      k[count]=cnt;
      count++;
      cnt++;
    }
  }
 else {
    float[] dArInstance1=new float[contentVA.size()];
    float[] dArInstance2=new float[contentVA.size()];
    int isto1=0, isto2=0, icnt=0;
    int count=0;
    for (    Integer iStorageIndex1 : storageVA) {
      if (bClusteringCanceled == false) {
        int tempPercentage=(int)((float)isto1 / storageVA.size() * 100);
        if (iPercentage == tempPercentage) {
          GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,true));
          iPercentage++;
        }
        icnt=0;
        for (        Integer iContentIndex1 : contentVA) {
          dArInstance1[icnt]=set.get(iStorageIndex1).getFloat(EDataRepresentation.NORMALIZED,iContentIndex1);
          icnt++;
        }
        isto2=0;
        for (        Integer iStorageIndex2 : storageVA) {
          icnt=0;
          for (          Integer iContentIndex2 : contentVA) {
            dArInstance2[icnt]=set.get(iStorageIndex2).getFloat(EDataRepresentation.NORMALIZED,iContentIndex2);
            icnt++;
          }
          if (isto1 != isto2) {
            s[count]=-distanceMeasure.getMeasure(dArInstance1,dArInstance2);
            i[count]=isto1;
            k[count]=isto2;
            count++;
          }
          isto2++;
        }
        isto1++;
        processEvents();
      }
 else {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,false));
        return -1;
      }
    }
    float median=ClusterHelper.median(s);
    int sto=0;
    for (    Integer iStorageIndex1 : storageVA) {
      s[count]=median * fClusterFactor;
      i[count]=sto;
      k[count]=sto;
      count++;
      sto++;
    }
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
  return 0;
}

Fixed version (ground truth):
/** 
 * Calculates the similarity matrix for a given set and VA�s
 * @param set
 * @param iVAIdContent
 * @param iVAIdStorage
 * @return
 */
public int determineSimilarities(ISet set,Integer iVAIdContent,Integer iVAIdStorage,EClustererType eClustererType){
  this.iVAIdContent=iVAIdContent;
  this.iVAIdStorage=iVAIdStorage;
  IVirtualArray contentVA=set.getVA(iVAIdContent);
  IVirtualArray storageVA=set.getVA(iVAIdStorage);
  IDistanceMeasure distanceMeasure;
  if (eDistanceMeasure == EDistanceMeasure.EUCLIDEAN_DISTANCE)   distanceMeasure=new EuclideanDistance();
 else   distanceMeasure=new PearsonCorrelation();
  int iPercentage=1;
  if (eClustererType == EClustererType.GENE_CLUSTERING) {
    float[] dArInstance1=new float[storageVA.size()];
    float[] dArInstance2=new float[storageVA.size()];
    int icnt1=0, icnt2=0, isto=0;
    int count=0;
    for (    Integer iContentIndex1 : contentVA) {
      if (bClusteringCanceled == false) {
        int tempPercentage=(int)((float)icnt1 / contentVA.size() * 100);
        if (iPercentage == tempPercentage) {
          GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,true));
          iPercentage++;
        }
        isto=0;
        for (        Integer iStorageIndex1 : storageVA) {
          dArInstance1[isto]=set.get(iStorageIndex1).getFloat(EDataRepresentation.NORMALIZED,iContentIndex1);
          isto++;
        }
        icnt2=0;
        for (        Integer iContentIndex2 : contentVA) {
          isto=0;
          for (          Integer iStorageIndex2 : storageVA) {
            dArInstance2[isto]=set.get(iStorageIndex2).getFloat(EDataRepresentation.NORMALIZED,iContentIndex2);
            isto++;
          }
          if (icnt1 != icnt2) {
            s[count]=-distanceMeasure.getMeasure(dArInstance1,dArInstance2);
            i[count]=contentVA.indexOf(iContentIndex1);
            k[count]=contentVA.indexOf(iContentIndex2);
            count++;
          }
          icnt2++;
        }
        icnt1++;
        processEvents();
      }
 else {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,false));
        return -1;
      }
    }
    float median=ClusterHelper.median(s);
    int cnt=0;
    for (    Integer iContentIndex : contentVA) {
      s[count]=median * fClusterFactor;
      i[count]=contentVA.indexOf(iContentIndex);
      k[count]=contentVA.indexOf(iContentIndex);
      count++;
      cnt++;
    }
  }
 else {
    float[] dArInstance1=new float[contentVA.size()];
    float[] dArInstance2=new float[contentVA.size()];
    int isto1=0, isto2=0, icnt=0;
    int count=0;
    for (    Integer iStorageIndex1 : storageVA) {
      if (bClusteringCanceled == false) {
        int tempPercentage=(int)((float)isto1 / storageVA.size() * 100);
        if (iPercentage == tempPercentage) {
          GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,true));
          iPercentage++;
        }
        icnt=0;
        for (        Integer iContentIndex1 : contentVA) {
          dArInstance1[icnt]=set.get(iStorageIndex1).getFloat(EDataRepresentation.NORMALIZED,iContentIndex1);
          icnt++;
        }
        isto2=0;
        for (        Integer iStorageIndex2 : storageVA) {
          icnt=0;
          for (          Integer iContentIndex2 : contentVA) {
            dArInstance2[icnt]=set.get(iStorageIndex2).getFloat(EDataRepresentation.NORMALIZED,iContentIndex2);
            icnt++;
          }
          if (isto1 != isto2) {
            s[count]=-distanceMeasure.getMeasure(dArInstance1,dArInstance2);
            i[count]=storageVA.indexOf(iStorageIndex1);
            k[count]=storageVA.indexOf(iStorageIndex2);
            count++;
          }
          isto2++;
        }
        isto1++;
        processEvents();
      }
 else {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,false));
        return -1;
      }
    }
    float median=ClusterHelper.median(s);
    int sto=0;
    for (    Integer iStorageIndex : storageVA) {
      s[count]=median * fClusterFactor;
      i[count]=storageVA.indexOf(iStorageIndex);
      k[count]=storageVA.indexOf(iStorageIndex);
      count++;
      sto++;
    }
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
  return 0;
}