/** * A vehicle can have a dest and have remaining service time. */ public void validateInputsValidDestinations1() { validateInputs(new int[6][6], new int[6], new int[6], new int[][] {new int[] {4, 2}}, // servicePairs new int[6], // serviceTimes new int[][] {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}}, // vehicleTravelTimes new int[][] {{1, 3}, {1, 1}}, // inventories new int[] {300, 0}, // remainingServiceTimes new int[] {4, 0}// current destinations , null); }
@Override public SolutionObject solve(int[][] travelTime, int[] releaseDates, int[] dueDates, int[][] servicePairs, int[] serviceTimes, @Nullable SolutionObject currentSolution) { // first check inputs validateInputs(travelTime, releaseDates, dueDates, servicePairs, serviceTimes); // execute solver final SolutionObject output = delegateSolver.solve(travelTime, releaseDates, dueDates, servicePairs, serviceTimes, currentSolution); // check outputs return validateOutputs(output, travelTime, releaseDates, dueDates, servicePairs, serviceTimes, currentSolution); } }
@Nullable SolutionObject[] currentSolutions) { validateInputs(travelTime, releaseDates, dueDates, servicePairs, serviceTimes); currentDestinations.length); validateVehicleTravelTimes(v, n, vehicleTravelTimes, currentDestinations); validateCurrentSolutions(v, n, currentSolutions, currentDestinations, inventoriesMap, servicePairsMap);
/** * The last location visited must always be the depot (n-1). */ @Test(expected = IllegalArgumentException.class) public void validateInvalidRouteDepot() { validateOutputs( new SolutionObject(new int[] {0, 1, 3, 2}, new int[1], 0), new int[4][4], new int[4], new int[4], new int[][] {}, new int[4], null); }
/** * Create a new instance using the specified time unit and seed. * @param arrSolver The {@link MultiVehicleArraysSolver} that is used for * solving. * @param timeUnit The time unit to use for the underlying * {@link RandomMVArraysSolver}. */ public DebugSolverCreator(MultiVehicleArraysSolver arrSolver, Unit<Duration> timeUnit) { arraysSolver = ArraysSolverDebugger.wrap( ArraysSolverValidator.wrap(arrSolver), false); solver = SolverDebugger.wrap(SolverValidator .wrap(new MultiVehicleSolverAdapter(arraysSolver, timeUnit)), false); }
int visitedLocations = 0; for (final SolutionObject sol : sols) { routeSetBuilder.addAll(toSet(sol.route)); visitedLocations += sol.route.length - 2;
@Test(expected = IllegalArgumentException.class) public void validateInvalidArrivalTimesFirst() { validateOutputs(new SolutionObject(new int[] {0, 1, 2, 3}, new int[] {1, -1, 0, 1}, 0), new int[4][4], new int[4], new int[4], new int[][] {}, new int[4], null); }
@Test public void testWrapSingle() { final SingleVehicleArraysSolver s = wrap(new FakeSingleSolver( new SolutionObject(new int[] {0, 1, 2, 3}, new int[] {0, 10, 100, 108}, 238))); s.solve(travelTimes, new int[4], new int[4], new int[][] {}, new int[4], null); }
@Test(expected = IllegalArgumentException.class) public void validateInputsInvalidTravelTimeMatrix2() { validateInputs(new int[][] {new int[3], new int[3], new int[4]}, new int[] {}, new int[] {}, new int[][] {}, new int[] {}); }
@Test(expected = IllegalArgumentException.class) public void validateInvalidArrivalTimes1() { validateOutputs(new SolutionObject(new int[] {0, 1, 2, 3}, new int[] {0, -1, 0, 1}, 0), new int[4][4], new int[4], new int[4], new int[][] {}, new int[4], null); }
@Override public SolutionObject[] solve(int[][] travelTime, int[] releaseDates, int[] dueDates, int[][] servicePairs, int[] serviceTimes, int[][] vehicleTravelTimes, int[][] inventories, int[] remainingServiceTimes, int[] currentDestinations, @Nullable SolutionObject[] currentSolutions) { validateInputs(travelTime, releaseDates, dueDates, servicePairs, serviceTimes, vehicleTravelTimes, inventories, remainingServiceTimes, currentDestinations, currentSolutions); final SolutionObject[] output = delegateSolver.solve(travelTime, releaseDates, dueDates, servicePairs, serviceTimes, vehicleTravelTimes, inventories, remainingServiceTimes, currentDestinations, currentSolutions); return validateOutputs(output, travelTime, releaseDates, dueDates, servicePairs, serviceTimes, vehicleTravelTimes, inventories, remainingServiceTimes, currentDestinations); } }
@Test public void testWrapMulti() { TestUtil.testPrivateConstructor(ArraysSolverValidator.class); final MultiVehicleArraysSolver s = wrap(new FakeMultiSolver( new SolutionObject[] {new SolutionObject(new int[] {0, 1, 2, 3}, new int[] {0, 10, 100, 108}, 228)})); s.solve(travelTimes, new int[4], new int[4], new int[][] {}, new int[4], new int[2][4], new int[][] {{0, 1}, {0, 2}}, new int[2], new int[2], null); }
@Test(expected = IllegalArgumentException.class) public void validateInputsInvalidPairLocation2() { validateInputs(new int[6][6], new int[6], new int[6], new int[][] { new int[] {1, 2}, new int[] {3, 913}}, new int[6]); }
/** * The first location visited must always be the vehicle start location (0). */ @Test(expected = IllegalArgumentException.class) public void validateInvalidRouteDuplicates() { validateOutputs( new SolutionObject(new int[] {1, 2, 0, 3}, new int[1], 0), new int[4][4], new int[4], new int[4], new int[][] {}, new int[4], null); }
validateInputs(travelTime, releaseDates, dueDates, servicePairs, serviceTimes, vehicleTravelTimes, inventories, remainingServiceTimes, currentDestinations, currentSolutions); validateOutputs(sols, travelTime, releaseDates, dueDates, servicePairs, serviceTimes, vehicleTravelTimes, inventories, remainingServiceTimes, currentDestinations);
.wrap(new FakeMultiSolver(new SolutionObject[] {sol1, sol2}));
@Test(expected = IllegalArgumentException.class) public void validateInputsDuplicatePairLocation() { validateInputs(new int[6][6], new int[6], new int[6], new int[][] { new int[] {1, 2}, new int[] {2, 0}}, new int[6]); }
@Test(expected = IllegalArgumentException.class) public void validateInvalidArrivalTimesLength() { validateOutputs( new SolutionObject(new int[] {0, 1, 2, 3}, new int[1], 0), new int[4][4], new int[4], new int[4], new int[][] {}, new int[4], null); }
@Override public Solver get(long seed) { return SolverValidator.wrap(new MultiVehicleSolverAdapter( ArraysSolverValidator.wrap(new RandomMVArraysSolver( new MersenneTwister(seed))), SI.MILLI(SI.SECOND))); } };
@Test(expected = IllegalArgumentException.class) public void validateInputsInvalidTWstart2() { validateInputs(new int[3][3], new int[] {0, 2, 3}, new int[] {1, 3, 6}, new int[][] {}, new int[3]); }