Beispiel #1
0
 public void setUp() {
   mover = new City2Opt();
   setUpSequence();
   solution = mock(Solution.class);
   problem = mock(TSPInstance.class);
   when(solution.getSolution()).thenReturn(sequence);
   when(solution.getProblem()).thenReturn(problem);
 }
Beispiel #2
0
  private void testMove(int i, int j) {
    setUp();

    ArrayList<Integer> expected = new ArrayList<>();
    for (int k = 0; k < i; k++) {
      expected.add(k);
    }
    expected.add(j);
    for (int k = i + 1; k < j; k++) {
      expected.add(k);
    }
    expected.add(i);
    for (int k = j + 1; k < dim; k++) {
      expected.add(k);
    }

    mover.move(i, j, solution);

    assertArrayEquals(expected.toArray(), solution.getSolution().toArray());
  }