Package rinde.sim.pdptw.common

Examples of rinde.sim.pdptw.common.DefaultParcel


  @Override
  protected void tickImpl(TimeLapse time) {
    final RoadModel rm = roadModel.get();
    final PDPModel pm = pdpModel.get();
    // we always go to the closest available parcel
    final DefaultParcel closest = (DefaultParcel) RoadModels
        .findClosestObject(rm.getPosition(this), rm, new Predicate<RoadUser>() {
          @Override
          public boolean apply(RoadUser input) {
            return input instanceof DefaultParcel
                && pm.getParcelState(((DefaultParcel) input)) == ParcelState.AVAILABLE;
          }
        });

    if (closest != null) {
      rm.moveTo(this, closest, time);
      if (rm.equalPosition(closest, this)
          && pm
              .getTimeWindowPolicy()
              .canPickup(closest.getPickupTimeWindow(), time.getTime(),
                  closest.getPickupDuration())) {
        pm.pickup(this, closest, time);
      }
    }
  }
View Full Code Here


      }
      return;
    }

    // Otherwise, Check if we can pickup nearby
    final DefaultParcel closest = (DefaultParcel) RoadModels.findClosestObject(
        rm.getPosition(this), rm, new Predicate<RoadUser>() {
          @Override
          public boolean apply(RoadUser input) {
            return input instanceof DefaultParcel
                && pm.getParcelState(((DefaultParcel) input)) == ParcelState.AVAILABLE;
          }
        });

    if (closest != null
        && Point.distance(rm.getPosition(closest), getPosition()) < 10) {
      if (rm.equalPosition(closest, this)
          && pm.getTimeWindowPolicy().canPickup(closest.getPickupTimeWindow(),
              time.getTime(), closest.getPickupDuration())) {
        final double newSize = getPDPModel().getContentsSize(this)
            + closest.getMagnitude();

        if (newSize <= getCapacity()) {
          pm.pickup(this, closest, time);
        }
      } else {
View Full Code Here

  @Override
  protected void tickImpl(TimeLapse time) {
    final RoadModel rm = roadModel.get();
    final PDPModel pm = pdpModel.get();
    // we always go to the closest available parcel
    final DefaultParcel closest = (DefaultParcel) RoadModels.findClosestObject(
        rm.getPosition(this), rm, new Predicate<RoadUser>() {
          @Override
          public boolean apply(RoadUser input) {
            return input instanceof DefaultParcel
                && pm.getParcelState(((DefaultParcel) input)) == ParcelState.AVAILABLE;
          }
        });

    if (closest != null) {
      rm.moveTo(this, closest, time);
      if (rm.equalPosition(closest, this)
          && pm.getTimeWindowPolicy().canPickup(closest.getPickupTimeWindow(),
              time.getTime(), closest.getPickupDuration())) {
        pm.pickup(this, closest, time);
      }
    }
  }
View Full Code Here

  @Test
  public void convertWithAbsentDestination() {
    PDPTWTestUtil.register(rm, pm, v1, p1);
    final TestSimAPI simAPI = new TestSimAPI(0, 1, NonSI.MINUTE);

    final DefaultParcel destination = rm.getObjectsOfType(DefaultParcel.class)
        .iterator().next();
    rm.moveTo(v1, destination, TimeLapseFactory.create(0, 1000));
    assertEquals(destination, rm.getDestinationToParcel(v1));
    assertEquals(ParcelState.AVAILABLE, pm.getParcelState(p1));
View Full Code Here

   * Tests whether a mismatch in arguments supplied to convertRoutes is handled
   * correctly.
   */
  @Test
  public void convertRoutesFail() {
    final DefaultParcel a = new DefaultParcel(ParcelDTO.builder(
        new Point(0, 0), new Point(1, 1)).build());
    final DefaultParcel b = new DefaultParcel(ParcelDTO.builder(
        new Point(0, 1), new Point(1, 1)).build());

    final DefaultVehicle vehicle = new TestVehicle(new Point(1, 1));
    final GlobalStateObject gso = mock(GlobalStateObject.class);

View Full Code Here

      assertEquals(dto.speed, vs.speed, 0);
      assertEquals(dto.startPosition, vs.startPosition);

      assertEquals(rm.getPosition(expected.get(i)), vs.location);

      final DefaultParcel dest = rm.getDestinationToParcel(vehicle);
      if (dest == null) {
        assertNull(vs.destination);
      } else {
        assertEquals(dest.dto, vs.destination);
      }
View Full Code Here

  }

  static final TimeWindow TW = new TimeWindow(0, 1000);

  static DefaultParcel createParcel(Point origin, Point dest) {
    return new DefaultParcel(ParcelDTO.builder(origin, dest)
        .pickupTimeWindow(TW)
        .deliveryTimeWindow(TW)
        .serviceDuration(30)
        .build());
  }
View Full Code Here

    assertSame(p1.dto, res.state.vehicles.get(0).destination);
    assertEquals(v1.getServiceState(), v1.getState());
  }

  static DefaultParcel createParcel(Point origin, Point dest) {
    return new DefaultParcel(new ParcelDTO(origin, dest, new TimeWindow(380001,
        380002), new TimeWindow(0, 1000), 0, 0, 3000, 3000));
  }
View Full Code Here

      @Nullable ImmutableList<DefaultParcel> route,
      ImmutableMap.Builder<ParcelDTO, DefaultParcel> availableDestBuilder) {
    final boolean isIdle = pm.getVehicleState(vehicle) == PDPModel.VehicleState.IDLE;

    long remainingServiceTime = 0;
    @Nullable
    DefaultParcel destination = null;
    if (!isIdle) {
      final VehicleParcelActionInfo vpai = pm.getVehicleActionInfo(vehicle);
      destination = ((DefaultParcel) vpai.getParcel());
      remainingServiceTime = vpai.timeNeeded();
View Full Code Here

    final RouteFollowingVehicle rfv = new RouteFollowingVehicle(new VehicleDTO(
        new Point(1, 1), 50, 10, new TimeWindow(0, 1000000)), false);
    final Depot depot = new DefaultDepot(new Point(5, 5));

    final DefaultParcel dp1 = new DefaultParcel(new ParcelDTO(new Point(2, 2),
        new Point(3, 3), new TimeWindow(0, 1000), new TimeWindow(0, 1000), 0,
        0L, 5L, 5L));
    final DefaultParcel dp2 = new DefaultParcel(new ParcelDTO(new Point(2, 2),
        new Point(3, 3), new TimeWindow(0, 1000), new TimeWindow(0, 1000), 0,
        0L, 5L, 5L));

    sim.register(depot);
    sim.register(rfv);
View Full Code Here

TOP

Related Classes of rinde.sim.pdptw.common.DefaultParcel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.