Ejemplo n.º 1
0
  public ValuesArray reduce(ArrayList<Integer> upMappings, Summarize sum) {
    if (this.size() != upMappings.size())
      throw new ArrayIndexOutOfBoundsException("Can not reduce to a higher number of elements");

    TreeSet<Integer> reduced = new TreeSet<Integer>(upMappings);

    final int len = reduced.size();
    ValuesArray result = new ValuesArray(len);
    for (int i = 0; i < len; i++) {
      // Fetch the best value that maps to i
      double bestValue = sum.getNoGood();

      for (int j = 0, len2 = size(); j < len2; j++) {
        // Skip it if it doesn't map to i
        if (upMappings.get(j) != i) continue;

        final double value = get(j);
        if (sum.isBetter(value, bestValue)) bestValue = value;
      }

      // Set the result
      result.add(bestValue);
    }

    return result;
  }
Ejemplo n.º 2
0
 public double getBest(Summarize sum) {
   double res = sum.getNoGood();
   for (Double v : this) {
     if (sum.isBetter(v, res)) {
       res = v;
     }
   }
   return res;
 }
Ejemplo n.º 3
0
 public int getBestIndex(Summarize sum) {
   double best = sum.getNoGood();
   int idx = 0;
   for (int i = 0; i < size(); i++) {
     final double v = get(i);
     if (sum.isBetter(v, best)) {
       best = v;
       idx = i;
     }
   }
   return idx;
 }