@Test public void testInteract() throws Exception { InteractionDomain<Integer, Integer> domain = (candidate, opponent, random) -> new InteractionResult(0, 0, 1); List<Integer> solutions = Arrays.asList(1, 2, 3); List<Integer> tests = Arrays.asList(1, 2, 3); ThreadedContext context = new ThreadedContext(123, 8); for (int k = 1; k <= 3; k++) { KRandomOpponentsInteractionScheme<Integer, Integer> scheme = new KRandomOpponentsInteractionScheme<>( domain, k); InteractionTable<Integer, Integer> table = scheme.interact(solutions, tests, context); PayoffTable<Integer, Integer> solutionsPayoffs = table.getSolutionsPayoffs(); PayoffTable<Integer, Integer> testsPayoffs = table.getTestsPayoffs(); EffortTable<Integer, Integer> efforts = table.getEfforts(); for (Integer solution : solutions) { Assert.assertEquals(k, solutionsPayoffs.solutionPayoffs(solution).toList().size()); Assert.assertEquals(k, testsPayoffs.testPayoffs(solution).toList().size()); Assert.assertEquals(k, efforts.computeEffort(solution)); } } }
@Override public InteractionTable<S, T> interact(List<S> solutions, List<T> tests, ThreadedContext context) { tests = RandomUtils.sample(tests, numRandomOpponents, context.getRandomForThread()); return roundRobin.interact(solutions, tests, context); }
KRandomOpponentsInteractionScheme implements InteractionScheme<S, T> { @Override public InteractionTable<S, T> interact(List<S> solutions, List<T> tests, ThreadedContext context) { tests = RandomUtils.sample(tests, numRandomOpponents, context.getRandomForThread()); return roundRobin.interact(solutions, tests, context); } }
KRandomOpponentsInteractionScheme implements InteractionScheme<S, T> { @Override public InteractionTable<S, T> interact(List<S> solutions, List<T> tests, ThreadedContext context) { tests = RandomUtils.sample(tests, numRandomOpponents, context.getRandomForThread()); return roundRobin.interact(solutions, tests, context); } @AccessedViaReflection  KRandomOpponentsInteractionScheme(InteractionDomain<S, T> domain, int numRandomOpponents); }
KRandomOpponentsInteractionScheme implements InteractionScheme<S, T> { @Override public InteractionTable<S, T> interact(List<S> solutions, List<T> tests, ThreadedContext context) { tests = RandomUtils.sample(tests, numRandomOpponents, context.getRandomForThread()); return roundRobin.interact(solutions, tests, context); } @AccessedViaReflection  KRandomOpponentsInteractionScheme(InteractionDomain<S, T> domain, int numRandomOpponents); @Override InteractionTable<S, T> interact(List<S> solutions, List<T> tests, ThreadedContext context); }
KRandomOpponentsInteractionScheme implements InteractionScheme<S, T> { @Override public InteractionTable<S, T> interact(List<S> solutions, List<T> tests, ThreadedContext context) { tests = RandomUtils.sample(tests, numRandomOpponents, context.getRandomForThread()); return roundRobin.interact(solutions, tests, context); } @AccessedViaReflection  KRandomOpponentsInteractionScheme(InteractionDomain<S, T> domain, int numRandomOpponents); @Override InteractionTable<S, T> interact(List<S> solutions, List<T> tests, ThreadedContext context);  }