static ImmutableList<Double> decomposedCost(GlobalStateObject state, ImmutableList<ImmutableList<Parcel>> schedule, ObjectiveFunction objFunc) { final ImmutableList.Builder<Double> builder = ImmutableList.builder(); for (int i = 0; i < schedule.size(); i++) { builder.add(objFunc.computeCost(Solvers.computeStats( state.withSingleVehicle(i), ImmutableList.of(schedule.get(i))))); } return builder.build(); }
currentFuture = Optional.of( scheduler.get().getSharedExecutor().submit( Solvers.createSolverCallable(solver, snapshot)));
CentralModel(Clock c, PDPRoadModel rm, PDPModel pm, Solver solver) { roadModel = rm; solverAdapter = Solvers.solverBuilder(solver) .with(rm) .with(pm) .with(c) .build(); }
final VehicleStateObject vehicleState = convertToVehicleState(rm, pm, v, contentsMap, route, availableDestParcels); vbuilder.put(vehicleState, v); gso = fixRoutes(gso);
when(clock.getTimeUnit()).thenReturn(NonSI.MINUTE); final SimulationConverter handle = Solvers.converterBuilder() .with(mp) .with(clock) final Solver solver = SolverValidator.wrap(new MultiVehicleSolverAdapter( new RandomMVArraysSolver(new MersenneTwister(123)), NonSI.MINUTE)); Solvers.solverBuilder(solver) .with(mp) .with(clock)
RtSimSolverSchedulerBridge(RealtimeClockController c, RealtimeSolver s, PDPRoadModel rm, PDPModel pm, Set<Vehicle> vehicles, ListeningExecutorService ex, SimSolversManager manager) { solver = s; clock = c; converter = Solvers.converterBuilder() .with(clock) .with(rm) .with(pm) .with(vehicles) .build(); currentSchedule = Optional.absent(); isUpdated = false; reference = this; eventDispatcher = new EventDispatcher(EventType.values()); simSolverEventDispatcher = new EventDispatcher(RtSimSolver.EventType.values()); executor = ex; rtSimSolver = new InternalRtSimSolver(); scheduler = new InternalScheduler(); simSolversManager = manager; solver.init(scheduler); simSolversManager.register(this); solveCount = new AtomicInteger(); }
@Override public GlobalStateObject convert(SolveArgs args) { final Collection<Vehicle> vs = vehicles.isEmpty() ? roadModel .getObjectsOfType(Vehicle.class) : vehicles; final Set<Parcel> ps = args.parcels.isPresent() ? args.parcels.get() : ImmutableSet.copyOf(pdpModel.getParcels(ANNOUNCED, AVAILABLE, PICKING_UP)); return Solvers.convert(roadModel, pdpModel, vs, ps, time(), args.currentRoutes, args.fixRoutes); }
calculateStatsForVehicle(stats, state, i, r, heuristic);
when(clock.getTickLength()).thenReturn(1L); when(clock.getTimeUnit()).thenReturn(NonSI.MINUTE); final SimulationConverter handle = Solvers.converterBuilder() .with(mp) .with(clock)
/** * Computes a {@link StatisticsDTO} instance for the given * {@link GlobalStateObject} and routes. For each vehicle in the state the * specified route is used and its arrival times, tardiness and travel times * are computed. The resulting {@link StatisticsDTO} has the same properties * as performing a simulation with the same state. However, since the current * state may be half-way a simulation, it is possible that the returned * statistics describe only a partial simulation. As a result * {@link StatisticsDTO#totalDeliveries} does not necessarily equal * {@link StatisticsDTO#totalPickups}. The travel times and distance are * computed using {@link GeomHeuristics#euclidean()}. * @param state The state which represents a simulation. * @param routes Specifies the route the vehicles are currently following, * must be of same size as the number of vehicles (one route per * vehicle). If this is <code>null</code> the * {@link VehicleStateObject#getRoute()} field must be set instead * for <b>each</b> vehicle. * @return The statistics that will be generated when executing this * simulation. */ public static ExtendedStats computeStats(GlobalStateObject state, @Nullable ImmutableList<ImmutableList<Parcel>> routes) { return computeStats(state, routes, GeomHeuristics.euclidean()); }
PDPTWTestUtil.register(sim, p1, p2, p3, v1, v2); final SimulationConverter s = Solvers.converterBuilder().with(sim).build();
currentFuture = Optional.of( scheduler.get().getSharedExecutor().submit( Solvers.createSolverCallable(solver, snapshot)));
@Override public double computeCost(GlobalStateObject context, int routeIndex, ImmutableList<Parcel> newRoute) { return objectiveFunction.computeCost(Solvers.computeStats( context.withSingleVehicle(routeIndex), ImmutableList.of(newRoute))); } }
final SimulationConverter simConv = Solvers.converterBuilder().with(sim) .build(); final GlobalStateObject state = simConv.convert(SolveArgs.create()
final GlobalStateObject state = solverHandle.get().convert( SolveArgs.create().noCurrentRoutes().useParcels(parcels)); final double baseline = objectiveFunction.computeCost(Solvers.computeStats( state, ImmutableList.of(currentRoute))); final double newCost = objectiveFunction.computeCost(Solvers.computeStats( state, ImmutableList.of(ImmutableList.copyOf(newRoute))));
solverHandle.get().getCurrentSchedule(); final double newCost = objectiveFunction.computeCost( Solvers.computeStats(state, schedule));
static double decomposedCost(GlobalStateObject gso, ImmutableList<ImmutableList<Parcel>> routes, ObjectiveFunction objFunc) { double sum = 0d; for (int i = 0; i < gso.getVehicles().size(); i++) { sum += objFunc.computeCost(Solvers.computeStats(gso.withSingleVehicle(i), ImmutableList.of(routes.get(i)))); } return sum; }
SolveArgs.create().noCurrentRoutes().useParcels(assignedParcels)); final StatisticsDTO stats = Solvers.computeStats(state, ImmutableList.of(currentRoute)); newRoute.removeAll(Collections.singleton(sp)); final double cost = objectiveFunction.computeCost( Solvers.computeStats(state, ImmutableList.of(ImmutableList.copyOf(newRoute)))); if (cost < lowestCost) {
.computeStats(state.withSingleVehicle(i), ImmutableList.of(r)));
.useParcels(parcels)); final double baseline = objectiveFunction.computeCost( Solvers.computeStats(state, ImmutableList.of(currentRoute)));