@Test public void testHaresTortoise() throws Exception { ParentSet[] hares = new ParentSet[6]; ParentSet[] tortoise = new ParentSet[6]; int sk = 1; RankerScores ranker = new RankerScores(); ranker.debug = 2; int n = 10; tortoise[0] = new ParentSet(-sk, ArrayUtils.hashToParentSet(sk++, n)); for (int i = 0; i < 5; i++) { hares[i] = new ParentSet(-sk, ArrayUtils.hashToParentSet(sk++, n)); } for (int i = 1; i < 6; i++) { tortoise[i] = new ParentSet(-sk, ArrayUtils.hashToParentSet(sk++, n)); } hares[5] = new ParentSet(-sk, ArrayUtils.hashToParentSet(sk++, n)); System.out.println(Arrays.toString(tortoise)); System.out.println(Arrays.toString(hares)); Pair<Double, Double> res = ranker.compare(tortoise, hares); System.out.println(res); assertTrue(res.getFirst() == 11); assertTrue(res.getSecond() == 25); }
public Pair<Double, Double> compare(ParentSet[] f_pset, ParentSet[] s_pset) { double f_skore = 0, s_skore = 0; int f_ix = 0, s_ix = 0, f_l = f_pset.length, s_l = s_pset.length; boolean f, s; while (f_ix < f_l || s_ix < s_l) { int r; if (f_ix == f_l) { r = -1; } else if (s_ix == s_l) { r = 1; } else { r = Double.compare(f_pset[f_ix].sk, s_pset[s_ix].sk); } switch (r) { case 1: f_ix++; f_skore += s_l - s_ix; break; case 0: f_ix++; s_ix++; f_skore += 0.5 + s_l - s_ix; s_skore += 0.5 + f_l - f_ix; break; case -1: s_ix++; s_skore += f_l - f_ix; break; } } return new Pair<Double, Double>(f_skore, s_skore); }
RankerScores { public Pair<Double, Double> compare(ParentSet[] f_pset, ParentSet[] s_pset) { double f_skore = 0, s_skore = 0; int f_ix = 0, s_ix = 0, f_l = f_pset.length, s_l = s_pset.length; boolean f, s; while (f_ix < f_l || s_ix < s_l) { int r; if (f_ix == f_l) { r = -1; } else if (s_ix == s_l) { r = 1; } else { r = Double.compare(f_pset[f_ix].sk, s_pset[s_ix].sk); } switch (r) { case 1: f_ix++; f_skore += s_l - s_ix; break; case 0: f_ix++; s_ix++; f_skore += 0.5 + s_l - s_ix; s_skore += 0.5 + f_l - f_ix; break; case -1: s_ix++; s_skore += f_l - f_ix; break; } } return new Pair<Double, Double>(f_skore, s_skore); } }
RankerScores { public Pair<Double, Double> compare(ParentSet[] f_pset, ParentSet[] s_pset) { double f_skore = 0, s_skore = 0; int f_ix = 0, s_ix = 0, f_l = f_pset.length, s_l = s_pset.length; boolean f, s; while (f_ix < f_l || s_ix < s_l) { int r; if (f_ix == f_l) { r = -1; } else if (s_ix == s_l) { r = 1; } else { r = Double.compare(f_pset[f_ix].sk, s_pset[s_ix].sk); } switch (r) { case 1: f_ix++; f_skore += s_l - s_ix; break; case 0: f_ix++; s_ix++; f_skore += 0.5 + s_l - s_ix; s_skore += 0.5 + f_l - f_ix; break; case -1: s_ix++; s_skore += f_l - f_ix; break; } } return new Pair<Double, Double>(f_skore, s_skore); }  }
RankerScores { public Pair<Double, Double> compare(ParentSet[] f_pset, ParentSet[] s_pset) { double f_skore = 0, s_skore = 0; int f_ix = 0, s_ix = 0, f_l = f_pset.length, s_l = s_pset.length; boolean f, s; while (f_ix < f_l || s_ix < s_l) { int r; if (f_ix == f_l) { r = -1; } else if (s_ix == s_l) { r = 1; } else { r = Double.compare(f_pset[f_ix].sk, s_pset[s_ix].sk); } switch (r) { case 1: f_ix++; f_skore += s_l - s_ix; break; case 0: f_ix++; s_ix++; f_skore += 0.5 + s_l - s_ix; s_skore += 0.5 + f_l - f_ix; break; case -1: s_ix++; s_skore += f_l - f_ix; break; } } return new Pair<Double, Double>(f_skore, s_skore); }  int execute(ParentSet[][] f_psets, ParentSet[][] s_psets); Pair<Double, Double> compare(ParentSet[] f_pset, ParentSet[] s_pset); }
RankerScores { public Pair<Double, Double> compare(ParentSet[] f_pset, ParentSet[] s_pset) { double f_skore = 0, s_skore = 0; int f_ix = 0, s_ix = 0, f_l = f_pset.length, s_l = s_pset.length; boolean f, s; while (f_ix < f_l || s_ix < s_l) { int r; if (f_ix == f_l) { r = -1; } else if (s_ix == s_l) { r = 1; } else { r = Double.compare(f_pset[f_ix].sk, s_pset[s_ix].sk); } switch (r) { case 1: f_ix++; f_skore += s_l - s_ix; break; case 0: f_ix++; s_ix++; f_skore += 0.5 + s_l - s_ix; s_skore += 0.5 + f_l - f_ix; break; case -1: s_ix++; s_skore += f_l - f_ix; break; } } return new Pair<Double, Double>(f_skore, s_skore); }  int execute(ParentSet[][] f_psets, ParentSet[][] s_psets); Pair<Double, Double> compare(ParentSet[] f_pset, ParentSet[] s_pset); public double alpha; public int debug; }