Package jsprit.core.problem.solution.route.activity

Examples of jsprit.core.problem.solution.route.activity.TourActivity


    routeBuilder.addService(Service.Builder.newInstance("2").addSizeDimension(0, 30).setLocationId("1").build());
    VehicleRoute route = routeBuilder.build();
    Iterator<TourActivity> iter = route.getTourActivities().reverseActivityIterator();
    int count = 0;
    while(iter.hasNext()){
      @SuppressWarnings("unused")
      TourActivity act = iter.next();
      count++;
    }
    assertEquals(1,count);
  }
View Full Code Here


    VehicleRoute route = routeBuilder.build();
    {
      Iterator<TourActivity> iter = route.getTourActivities().reverseActivityIterator();
      int count = 0;
      while(iter.hasNext()){
        TourActivity act = iter.next();
        if(count==0) {
          assertEquals("2",act.getLocationId());
        }
        count++;
      }
      assertEquals(2,count);
    }
    {
      Iterator<TourActivity> secondIter = route.getTourActivities().reverseActivityIterator();
      int count = 0;
      while(secondIter.hasNext()){
        TourActivity act = secondIter.next();
        if(count==0) {
          assertEquals("2",act.getLocationId());
        }
        count++;
      }
      assertEquals(2,count);
    }
View Full Code Here

        Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").setLocationId("pickLoc").build();
        VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId("startLoc").build();
        VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle).addService(pickup).build();

        TourActivity act = route.getActivities().get(0);
        assertTrue(act.getName().equals("pickup"));
        assertTrue(act instanceof PickupService);
        assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Pickup);

    }
View Full Code Here

        Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").setLocationId("pickLoc").build();
        VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId("startLoc").build();
        VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle).addPickup(pickup).build();

        TourActivity act = route.getActivities().get(0);
        assertTrue(act.getName().equals("pickup"));
        assertTrue(act instanceof PickupService);
        assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Pickup);

    }
View Full Code Here

        Delivery delivery = (Delivery) Delivery.Builder.newInstance("delivery").setLocationId("deliveryLoc").build();
        VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId("startLoc").build();
        VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle).addService(delivery).build();

        TourActivity act = route.getActivities().get(0);
        assertTrue(act.getName().equals("delivery"));
        assertTrue(act instanceof DeliverService);
        assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Delivery);

    }
View Full Code Here

        Delivery delivery = (Delivery) Delivery.Builder.newInstance("delivery").setLocationId("deliveryLoc").build();
        VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId("startLoc").build();
        VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle).addDelivery(delivery).build();

        TourActivity act = route.getActivities().get(0);
        assertTrue(act.getName().equals("delivery"));
        assertTrue(act instanceof DeliverService);
        assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Delivery);

    }
View Full Code Here

    int routeNu = 1;
    for(VehicleRoute route : solution.getRoutes()){
      System.out.format("+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+%n");
      double costs = 0;
      System.out.format(leftAlgin, routeNu, getVehicleString(route), route.getStart().getName(), "-", "undef", Math.round(route.getStart().getEndTime()),Math.round(costs));
      TourActivity prevAct = route.getStart();
      for(TourActivity act : route.getActivities()){
        String jobId;
        if(act instanceof JobActivity) jobId = ((JobActivity)act).getJob().getId();
        else jobId = "-";
        double c = problem.getTransportCosts().getTransportCost(prevAct.getLocationId(), act.getLocationId(), prevAct.getEndTime(), route.getDriver(), route.getVehicle());
        c+= problem.getActivityCosts().getActivityCost(act, act.getArrTime(), route.getDriver(), route.getVehicle());
        costs+=c;
        System.out.format(leftAlgin, routeNu, getVehicleString(route), act.getName(), jobId, Math.round(act.getArrTime()), Math.round(act.getEndTime()),Math.round(costs));
        prevAct=act;
      }
      double c = problem.getTransportCosts().getTransportCost(prevAct.getLocationId(), route.getEnd().getLocationId(), prevAct.getEndTime(), route.getDriver(), route.getVehicle());
      c+= problem.getActivityCosts().getActivityCost(route.getEnd(), route.getEnd().getArrTime(), route.getDriver(), route.getVehicle());
      costs+=c;
      System.out.format(leftAlgin, routeNu, getVehicleString(route), route.getEnd().getName(), "-", Math.round(route.getEnd().getArrTime()), "undef", Math.round(costs));
      routeNu++;
    }
View Full Code Here

    calc = new LocalActivityInsertionCostsCalculator(tpCosts, actCosts);
  }
 
  @Test
  public void whenInsertingActBetweenTwoRouteActs_itCalcsMarginalTpCosts(){
    TourActivity prevAct = mock(TourActivity.class);
    when(prevAct.getLocationId()).thenReturn("i");
    TourActivity nextAct = mock(TourActivity.class);
    when(nextAct.getLocationId()).thenReturn("j");
    TourActivity newAct = mock(TourActivity.class);
    when(newAct.getLocationId()).thenReturn("k");
   
    when(vehicle.isReturnToDepot()).thenReturn(true);
   
    double costs = calc.getCosts(jic, prevAct, nextAct, newAct, 0.0);
    assertEquals(4.0,costs,0.01);
View Full Code Here

    assertEquals(4.0,costs,0.01);
  }
 
  @Test
  public void whenInsertingActBetweenLastActAndEnd_itCalcsMarginalTpCosts(){
    TourActivity prevAct = mock(TourActivity.class);
    when(prevAct.getLocationId()).thenReturn("i");
    End nextAct = End.newInstance("j", 0.0, 0.0);
    TourActivity newAct = mock(TourActivity.class);
    when(newAct.getLocationId()).thenReturn("k");
   
    when(vehicle.isReturnToDepot()).thenReturn(true);
   
    double costs = calc.getCosts(jic, prevAct, nextAct, newAct, 0.0);
    assertEquals(4.0,costs,0.01);
View Full Code Here

            public double getDistance(String fromLocationId, String toLocationId) {
                return vrp.getTransportCosts().getTransportCost(fromLocationId,toLocationId,0.,null,null);
            }
        });
        VehicleRoute route = solution.getRoutes().iterator().next();
        TourActivity act = route.getStart();
        Capacity cap = analyser.getCapacityViolationAfterActivity(act,route);
        for(int i=0;i<cap.getNuOfDimensions();i++){
            assertTrue(cap.get(i) == 0);
        }
    }
View Full Code Here

TOP

Related Classes of jsprit.core.problem.solution.route.activity.TourActivity

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.