Package jsprit.core.problem.vehicle

Examples of jsprit.core.problem.vehicle.Vehicle


   
    Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").setLocationId("0,20").setTimeWindow(TimeWindow.newInstance(0, 30)).build();
    Delivery delivery = (Delivery) Delivery.Builder.newInstance("del").setLocationId("20,20").setTimeWindow(TimeWindow.newInstance(10, 40)).build();
    Pickup pickup2 = (Pickup) Pickup.Builder.newInstance("pick2").setLocationId("20,0").setTimeWindow(TimeWindow.newInstance(20, 50)).build();

    Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(mock(VehicleType.class)).build();

        VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
        final VehicleRoutingProblem vrp = vrpBuilder.addJob(pickup).addJob(pickup2).addJob(delivery).build();

    route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).setJobActivityFactory(new JobActivityFactory() {
View Full Code Here


 
  @Test
  public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_totalCostsShouldBe50(){
    TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
    Service service = Service.Builder.newInstance("s").setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
    Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0))
        .setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
   
    Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
    vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
View Full Code Here

 
  @Test
  public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_depTimeShouldBe0(){
    TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
    Service service = Service.Builder.newInstance("s").setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
    Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0))
        .setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
   
    Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
    vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
View Full Code Here


  @Test
  public void whenInsertingServiceAndRouteIsClosed_itInsertsCorrectly(){
    Service service = mock(Service.class);
    Vehicle vehicle = mock(Vehicle.class);
    when(vehicle.getStartLocationId()).thenReturn("vehLoc");
    when(vehicle.getEndLocationId()).thenReturn("vehLoc");
    when(vehicle.isReturnToDepot()).thenReturn(true);
    when(vehicle.getId()).thenReturn("vehId");
   
    VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addService(service).build();
    //start - pick(shipment) - del(shipment) - end
    Service serviceToInsert = mock(Service.class);
    when(serviceToInsert.getLocationId()).thenReturn("delLoc");
 
    InsertionData iData = mock(InsertionData.class);
    when(iData.getDeliveryInsertionIndex()).thenReturn(1);
    when(iData.getSelectedVehicle()).thenReturn(vehicle);

        VehicleRoutingProblem vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
        List<AbstractActivity> acts = new ArrayList<AbstractActivity>();
        PickupService act = new PickupService(serviceToInsert);
        acts.add(act);
        when(vehicleRoutingProblem.copyAndGetActivities(serviceToInsert)).thenReturn(acts);
    Inserter inserter = new Inserter(mock(InsertionListeners.class), vehicleRoutingProblem);
    inserter.insertJob(serviceToInsert, iData, route);
   
    assertEquals(2,route.getTourActivities().getActivities().size());
    assertEquals(route.getTourActivities().getActivities().get(1).getLocationId(),serviceToInsert.getLocationId());
    assertEquals(route.getEnd().getLocationId(),vehicle.getEndLocationId());
  }
View Full Code Here

  }
 
  @Test
  public void whenInsertingServiceAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){
    Service service = mock(Service.class);
    Vehicle vehicle = mock(Vehicle.class);
    when(vehicle.getStartLocationId()).thenReturn("vehLoc");
    when(vehicle.getEndLocationId()).thenReturn("vehLoc");
    when(vehicle.isReturnToDepot()).thenReturn(false);
    when(vehicle.getId()).thenReturn("vehId");
   
    VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addService(service).build();
    Service serviceToInsert = mock(Service.class);
    when(serviceToInsert.getLocationId()).thenReturn("delLoc");
 
View Full Code Here

    @Test
  public void whenInsertingShipmentAndRouteIsClosed_itInsertsCorrectly(){
    Shipment shipment = mock(Shipment.class);
    Capacity capacity = Capacity.Builder.newInstance().build();
    when(shipment.getSize()).thenReturn(capacity);
    Vehicle vehicle = mock(Vehicle.class);
    when(vehicle.getStartLocationId()).thenReturn("vehLoc");
    when(vehicle.getEndLocationId()).thenReturn("vehLoc");
    when(vehicle.isReturnToDepot()).thenReturn(true);
    when(vehicle.getId()).thenReturn("vehId");
   
    VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
    //start - pick(shipment) - del(shipment) - end
    Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();

    InsertionData iData = mock(InsertionData.class);
    when(iData.getPickupInsertionIndex()).thenReturn(2);
    when(iData.getDeliveryInsertionIndex()).thenReturn(2);
    when(iData.getSelectedVehicle()).thenReturn(vehicle);

        VehicleRoutingProblem vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
        when(vehicleRoutingProblem.copyAndGetActivities(shipmentToInsert)).thenReturn(getTourActivities(shipmentToInsert));
    Inserter inserter = new Inserter(mock(InsertionListeners.class), vehicleRoutingProblem);
    inserter.insertJob(shipmentToInsert, iData, route);
   
    assertEquals(4,route.getTourActivities().getActivities().size());
    assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocationId());
    assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocationId());
    assertEquals(route.getEnd().getLocationId(),vehicle.getEndLocationId());
  }
View Full Code Here

    @Test
  public void whenInsertingShipmentAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){
    Shipment shipment = mock(Shipment.class);
    Capacity capacity = Capacity.Builder.newInstance().build();
    when(shipment.getSize()).thenReturn(capacity);
    Vehicle vehicle = mock(Vehicle.class);
    when(vehicle.isReturnToDepot()).thenReturn(false);
    when(vehicle.getId()).thenReturn("vehId");
   
    VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
    //start - pick(shipment) - del(shipment) - end
    Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
    InsertionData iData = mock(InsertionData.class);
View Full Code Here

  @Test
  public void whenSwitchingVehicleAndRouteIsClosed_newStartAndEndShouldBeTheLocationOfNewVehicle(){
    Shipment shipment = mock(Shipment.class);
    Capacity capacity = Capacity.Builder.newInstance().build();
    when(shipment.getSize()).thenReturn(capacity);
    Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
    Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
   
    VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
    //start - pick(shipment) - del(shipment) - end
    Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build();
   
    InsertionData iData = mock(InsertionData.class);
    when(iData.getPickupInsertionIndex()).thenReturn(2);
    when(iData.getDeliveryInsertionIndex()).thenReturn(2);
    when(iData.getSelectedVehicle()).thenReturn(newVehicle);

        VehicleRoutingProblem vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
        when(vehicleRoutingProblem.copyAndGetActivities(shipmentToInsert)).thenReturn(getTourActivities(shipmentToInsert));
    Inserter inserter = new Inserter(mock(InsertionListeners.class), vehicleRoutingProblem);
    inserter.insertJob(shipmentToInsert, iData, route);
   
    assertEquals(route.getEnd().getLocationId(),newVehicle.getEndLocationId());
  }
View Full Code Here

  @Test
  public void whenSwitchingVehicleAndRouteIsOpen_endLocationShouldBeTheLocationOfTheLastActivity(){
    Shipment shipment = mock(Shipment.class);
    Capacity capacity = Capacity.Builder.newInstance().build();
    when(shipment.getSize()).thenReturn(capacity);
    Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
    Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
   
    VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
    //start - pick(shipment) - del(shipment) - end
        Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build();
View Full Code Here

  public void whenInsertingShipmentAtBeginningAndSwitchingVehicleAndRouteIsOpen_endLocationShouldBeTheLocationOfTheLastActivity(){
    Shipment shipment = mock(Shipment.class);
    Capacity capacity = Capacity.Builder.newInstance().build();
    when(shipment.getSize()).thenReturn(capacity);
    when(shipment.getDeliveryLocationId()).thenReturn("oldShipmentDelLoc");
    Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
    Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
   
    VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
    //start - pick(shipment) - del(shipment) - end
        Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build();
View Full Code Here

TOP

Related Classes of jsprit.core.problem.vehicle.Vehicle

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.