Package jsprit.core.problem.job

Examples of jsprit.core.problem.job.Shipment


     * 2: (5,13)->(6,11)
     * 3: (15,7)->(14,9)
     * 4: (15,13)->(14,11)
     */
   
    Shipment shipment1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 1).setPickupCoord(Coordinate.newInstance(5, 7)).setDeliveryCoord(Coordinate.newInstance(6, 9)).build();
    Shipment shipment2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 1).setPickupCoord(Coordinate.newInstance(5, 13)).setDeliveryCoord(Coordinate.newInstance(6, 11)).build();
   
    Shipment shipment3 = Shipment.Builder.newInstance("3").addSizeDimension(0, 1).setPickupCoord(Coordinate.newInstance(15, 7)).setDeliveryCoord(Coordinate.newInstance(14, 9)).build();
    Shipment shipment4 = Shipment.Builder.newInstance("4").addSizeDimension(0, 1).setPickupCoord(Coordinate.newInstance(15, 13)).setDeliveryCoord(Coordinate.newInstance(14, 11)).build();
   
    /*
     * build deliveries, (implicitly picked up in the depot)
     * 1: (4,8)
     * 2: (4,12)
View Full Code Here


  }
 
  @Test
  public void distanceOfTwoEqualShipmentsShouldBeSmallerThanAnyOtherDistance(){
    Shipment s1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("10,10").build();
    Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("10,10").build();
   
    double dist = new AvgServiceAndShipmentDistance(routingCosts).getDistance(s1, s2);
   
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
        Shipment other1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId(i + "," + j).build();
        Shipment other2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("10,10").build();
        double dist2 = new AvgServiceAndShipmentDistance(routingCosts).getDistance(other1, other2);
        System.out.println("("+i+","+j+"), dist=" + dist + ", dist2=" + dist2);
        assertTrue(dist<=dist2+dist2*0.001);
      }
    }
 
View Full Code Here

  private void writeShipments(XMLConf xmlConfig, List<Job> jobs) {
    String shipmentPathString = "shipments.shipment";
    int counter = 0;
    for(Job j : jobs){
      if(!(j instanceof Shipment)) continue;
      Shipment shipment = (Shipment) j;
      xmlConfig.setProperty(shipmentPathString + "("+counter+")[@id]", shipment.getId());
//      xmlConfig.setProperty(shipmentPathString + "("+counter+")[@type]", service.getType());
      if(shipment.getPickupLocationId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.locationId", shipment.getPickupLocationId());
      if(shipment.getPickupCoord() != null) {
        xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.coord[@x]", shipment.getPickupCoord().getX());
        xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.coord[@y]", shipment.getPickupCoord().getY());
      }
     
      xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.duration", shipment.getPickupServiceTime());
      xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.timeWindows.timeWindow(0).start", shipment.getPickupTimeWindow().getStart());
      xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.timeWindows.timeWindow(0).end", shipment.getPickupTimeWindow().getEnd());
     
     
      if(shipment.getDeliveryLocationId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.locationId", shipment.getDeliveryLocationId());
      if(shipment.getDeliveryCoord() != null) {
        xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.coord[@x]", shipment.getDeliveryCoord().getX());
        xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.coord[@y]", shipment.getDeliveryCoord().getY());
      }
     
      xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.duration", shipment.getDeliveryServiceTime());
      xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).start", shipment.getDeliveryTimeWindow().getStart());
      xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).end", shipment.getDeliveryTimeWindow().getEnd());
     
      for(int i=0;i<shipment.getSize().getNuOfDimensions();i++){
        xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
        xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", shipment.getSize().get(i));
      }

            //skills
            String skillString = getSkillString(shipment);
            xmlConfig.setProperty(shipmentPathString + "("+counter+").requiredSkills", skillString);

            //name
            if(shipment.getName() != null){
                if(!shipment.getName().equals("no-name")){
                    xmlConfig.setProperty(shipmentPathString + "("+counter+").name", shipment.getName());
                }
            }
      counter++;
    }
  }
View Full Code Here

    VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build();
   
    Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLatestArrival(11.)
        .setType(type).setReturnToDepot(false).setStartLocationCoordinate(Coordinate.newInstance(0, 0)).build();
   
    Shipment shipment = Shipment.Builder.newInstance("s").setPickupCoord(Coordinate.newInstance(5, 0))
        .setDeliveryCoord(Coordinate.newInstance(10, 0)).build();
   
    VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(shipment).addVehicle(vehicle).build();
   
    VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
View Full Code Here

  public void whenDealingWithOpenRouteAndShipments_algorithmShouldCalculateCorrectCosts(){
    VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build();
    Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLatestArrival(20.)
        .setType(type).setReturnToDepot(false).setStartLocationCoordinate(Coordinate.newInstance(0, 0)).build();
   
    Shipment shipment = Shipment.Builder.newInstance("s").setPickupCoord(Coordinate.newInstance(5, 0))
        .setDeliveryCoord(Coordinate.newInstance(10, 0)).build();
   
    VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(shipment).addVehicle(vehicle).build();
   
    VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
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

        return acts;
    }

    @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);
    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(),shipmentToInsert.getDeliveryLocationId());
  }
View Full Code Here

    assertEquals(route.getEnd().getLocationId(),shipmentToInsert.getDeliveryLocationId());
  }
 
  @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);
View Full Code Here

    assertEquals(route.getEnd().getLocationId(),newVehicle.getEndLocationId());
  }
 
  @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();

        InsertionData iData = mock(InsertionData.class);
    when(iData.getPickupInsertionIndex()).thenReturn(2);
    when(iData.getDeliveryInsertionIndex()).thenReturn(2);
    when(iData.getSelectedVehicle()).thenReturn(newVehicle);
View Full Code Here

    assertEquals("delLoc",route.getEnd().getLocationId());
  }
 
  @Test
  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();

        InsertionData iData = mock(InsertionData.class);
    when(iData.getPickupInsertionIndex()).thenReturn(0);
    when(iData.getDeliveryInsertionIndex()).thenReturn(0);
    when(iData.getSelectedVehicle()).thenReturn(newVehicle);
View Full Code Here

TOP

Related Classes of jsprit.core.problem.job.Shipment

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.