/** * Calls the {@link Solver} to solve the problem as defined by the current * simulation state. * @param args {@link SolveArgs} specifying what information to include. * @return A list containing routes for each vehicle known to this solver. */ public ImmutableList<ImmutableList<Parcel>> solve(SolveArgs args) { return solve(convert(args)); }
@Override public void solve(GlobalStateObject state) { currentState = state; currentSchedule = delegate.solve(state); isUpdated = true; eventDispatcher.dispatchEvent(new SolverEvent( RtSimSolver.EventType.NEW_SCHEDULE, Optional.of(currentSchedule), Optional.of(currentState))); eventDispatcher.dispatchEvent(new SolverEvent( RtSimSolver.EventType.DONE, Optional.of(currentSchedule), Optional.of(currentState))); }
@Override public void tick(TimeLapse timeLapse) { if (hasChanged) { hasChanged = false; // TODO check to see that this is called the first possible moment after // the add parcel event was dispatched // TODO it must be checked whether the calculated routes end up in the // correct vehicles final Set<RouteFollowingVehicle> vehicles = roadModel .getObjectsOfType(RouteFollowingVehicle.class); // gather current routes final ImmutableList.Builder<ImmutableList<Parcel>> currentRouteBuilder = ImmutableList .builder(); for (final RouteFollowingVehicle vehicle : vehicles) { final ImmutableList<Parcel> l = ImmutableList.copyOf(vehicle .getRoute()); currentRouteBuilder.add(l); } final Iterator<ImmutableList<Parcel>> routes = solverAdapter .solve( SolveArgs.create() .useAllParcels() .useCurrentRoutes(currentRouteBuilder.build())) .iterator(); for (final RouteFollowingVehicle vehicle : vehicles) { vehicle.setRoute(routes.next()); } } }
route = newLinkedList(solverHandle.get().solve(args).get(0));
.setVehicles(new LinkedHashSet<>(trucks)) .build(negotiationSolver); final List<ImmutableList<Parcel>> routes = sol.solve(SolveArgs.create() .useCurrentRoutes(currentRoutes.build()) .useParcels(availableParcels));
solverHandle.get().solve(args).get(0); final double newCost = objectiveFunction.computeCost(Solvers.computeStats( state, ImmutableList.of(ImmutableList.copyOf(newRoute))));
@Override protected void preTick(TimeLapse time) { if (getRoute().isEmpty() && !getRoadModel().getObjectsOfType(Parcel.class).isEmpty()) { setRoute(solver.get().solve(SolveArgs.create() .useAllParcels()).get(0)); } } }
.with(clock) .build() .solve(state);