Esempio n. 1
0
 /* cols are experiment (already set), probeid, block, row, col, ip, wce, mor */
 public void processBodyLine(String fields[]) {
   try {
     double ip = 0.001 + Double.parseDouble(fields[ipcol]);
     double wce = 0.001 + Double.parseDouble(fields[wcecol]);
     insert.setString(2, fields[idcol]);
     insert.setInt(3, blockcol == -1 ? 1 : Integer.parseInt(fields[blockcol]));
     insert.setInt(4, Integer.parseInt(fields[rowcol]));
     insert.setInt(5, Integer.parseInt(fields[colcol]));
     insert.setDouble(6, ip);
     insert.setDouble(7, wce);
     insert.setDouble(8, Math.pow(10, Double.parseDouble(fields[lrcol])));
     insert.execute();
   } catch (SQLException e) {
     throw new DatabaseException(e.toString(), e);
   } catch (ArrayIndexOutOfBoundsException e) {
     System.err.println("Skipping a line of input because of ");
     e.printStackTrace();
   }
 }
 public WeightMatrix getRepresentative(Cluster<WeightMatrix> cluster) {
   Set<WeightMatrix> matrices = cluster.getElements();
   WeightMatrix bestwm = null;
   double bestdist = Double.MAX_VALUE;
   for (WeightMatrix i : matrices) {
     double sum = 0;
     for (WeightMatrix j : matrices) {
       sum += Math.pow(comp.compare(i, j), 2);
     }
     //            System.err.println("  " + i + " : " + sum + " <? " + bestdist);
     sum = sum / matrices.size();
     if (sum < bestdist) {
       bestwm = i;
       bestdist = sum;
     }
   }
   if (bestwm == null) {
     System.err.println("OOPS!" + bestdist);
     System.err.println(matrices.toString());
   }
   return bestwm;
 }