Example #1
0
 /**
  * @param record
  * @return the group which has nearest center to the <tt>record</tt>
  */
 private EvaluationRecordGroup getNearestGroup(EvaluationRecord record) {
   EvaluationRecordGroup minGroup = null;
   double minGroupDistance = 0;
   for (EvaluationRecordGroup group : groupClusterCenter.keySet()) {
     double testDistance = groupClusterCenter.get(group).getLength(record.getConsideringValues());
     if (minGroup == null || testDistance < minGroupDistance) {
       minGroup = group;
       minGroupDistance = testDistance;
     }
   }
   return minGroup;
 }
Example #2
0
 /**
  * calculates center of <tt>records</tt> using averaging algorithm.
  *
  * @param records
  * @return
  */
 private Coordination calculateCenter(Collection<EvaluationRecord> records) {
   if (records.size() > 0) {
     double[] centerCoord = new double[coordinateSize];
     for (EvaluationRecord record : records) {
       List<Double> cFactors = record.getConsideringValues();
       for (int i = 0; i < centerCoord.length; i++) {
         centerCoord[i] += cFactors.get(i);
       }
     }
     for (int i = 0; i < centerCoord.length; i++) {
       centerCoord[i] /= records.size();
     }
     return new Coordination(centerCoord);
   }
   double[] returnVal = new double[coordinateSize];
   Arrays.fill(returnVal, 0d);
   return new Coordination(returnVal);
 }