/** * Retrieves all {@link Parcel}s. * @param state The {@link GlobalStateObject} that is used for retrieving the * parcels. * @return All parcels. */ public static ImmutableSet<Parcel> allParcels(GlobalStateObject state) { return ImmutableSet.<Parcel>builder() .addAll(state.getAvailableParcels()) .addAll(assignedParcels(state)) .build(); }
ImmutableList<Double> costs = decomposedCost(state, schedule, objFunc); final ImmutableSet<Parcel> newParcels = GlobalStateObjects.unassignedParcels(state);
@Override public ImmutableList<ImmutableList<Parcel>> solve(GlobalStateObject state) throws InterruptedException { final List<List<Parcel>> mutSchedule = new ArrayList<>(state.getVehicles().size()); for (final VehicleStateObject vso : state.getVehicles()) { mutSchedule.add(new ArrayList<>(vso.getRoute().get())); } final Set<Parcel> unscheduled = GlobalStateObjects.unassignedParcels(state); for (final Parcel p : unscheduled) { int index = 0; int minJobs = mutSchedule.get(0).size(); for (int i = 1; i < mutSchedule.size(); i++) { final int jobs = mutSchedule.get(i).size(); if (jobs < minJobs) { index = i; minJobs = jobs; } } mutSchedule.get(index).add(0, p); mutSchedule.get(index).add(0, p); } final ImmutableList.Builder<ImmutableList<Parcel>> schedule = ImmutableList.builder(); for (final List<Parcel> row : mutSchedule) { schedule.add(ImmutableList.copyOf(row)); } return schedule.build(); }
GlobalStateObjects.unassignedParcels(state); route.addAll(unassigned); route.addAll(unassigned);
/** * Retrieves all {@link Parcel}s that are not assigned to any vehicle. * @param state The {@link GlobalStateObject} that is used for retrieving the * unassigned parcels. * @return All unassigned parcels. */ public static ImmutableSet<Parcel> unassignedParcels( GlobalStateObject state) { final Set<Parcel> set = newLinkedHashSet(state.getAvailableParcels()); set.removeAll(assignedParcels(state)); return ImmutableSet.copyOf(set); }