Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 
 package rinde.sim.pdptw.central.arrays;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
 
Adapter for SingleVehicleArraysSolver to conform to the rinde.sim.pdptw.central.Solver interface.

Author(s):
Rinde van Lon <rinde.vanlon@cs.kuleuven.be>
public class SingleVehicleSolverAdapter implements Solver {
  private final SingleVehicleArraysSolver solver;
  private final Unit<DurationoutputTimeUnit;

  

Parameters:
solver The solver to use.
outputTimeUnit The time unit which is expected by the specified solver.
      Unit<DurationoutputTimeUnit) {
    this. = solver;
    this. = outputTimeUnit;
  }
        state.vehicles.size() == 1,
        "This solver can only deal with the single vehicle problem, found %s vehicles.",
        state.vehicles.size());
    final VehicleStateObject v = state.vehicles.iterator().next();
        v.remainingServiceTime == 0,
        "This solver can not deal with remaining service time, it should be 0, it was %s.",
        v.remainingServiceTime);
    final Collection<ParcelDTOinCargo = v.contents;
    // there are always two locations: the current vehicle location and
    // the depot
    final int numLocations = 2 + (state.availableParcels.size() * 2)
        + inCargo.size();
    if (numLocations == 2) {
      // there are no orders
      final ImmutableList<ParcelDTOempty = ImmutableList.of();
      return ImmutableList.of(empty);
    } else if (state.availableParcels.size() + inCargo.size() == 1) {
      // if there is only one order, the solution is trivial
      if (!state.availableParcels.isEmpty()) {
        // parcels on the map require two visits (one for pickup, one
        // for delivery)
        final ParcelDTO dto = state.availableParcels.iterator().next();
        return ImmutableList.of(ImmutableList.of(dtodto));
      } // else
      return ImmutableList.of(ImmutableList.copyOf(inCargo));
    }
    // else, we are going to look for the optimal solution
    final ArraysObject ao = ArraysSolvers.toSingleVehicleArrays(state,
        );
    final SolutionObject[] curSols = ao.currentSolutions;
    final SolutionObject sol = .solve(ao.travelTimeao.releaseDates,
        ao.dueDatesao.servicePairsao.serviceTimescurSols == null ? null
            : curSols[0]);
    return ImmutableList.of(ArraysSolvers.convertSolutionObject(sol,
        ao.index2parcel));
  }
New to GrepCode? Check out our FAQ X