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

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


    @Test
    public void shipmentViolationOnSolution_shouldWorkWhenRemovingPickup(){
        buildAnotherScenarioWithOnlyOneVehicleAndWithoutAnyConstraintsBefore();
        VehicleRoute route = solution.getRoutes().iterator().next();
        SolutionPrinter.print(vrp,solution, SolutionPrinter.Print.VERBOSE);
        TourActivity pickupShipment = route.getActivities().get(1);
        route.getTourActivities().removeActivity(pickupShipment);
        assertFalse(route.getTourActivities().hasActivity(pickupShipment));
        SolutionPrinter.print(vrp,solution, SolutionPrinter.Print.VERBOSE);

        SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
View Full Code Here


    }

    private boolean secondActIsPickup(Collection<VehicleRoutingProblemSolution> solutions) {
        VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
        TourActivity secondAct = solution.getRoutes().iterator().next().getActivities().get(1);
        return secondAct instanceof PickupShipment;
    }
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

    assertEquals(4.0,costs,0.01);
  }

  @Test
  public void whenInsertingActBetweenTwoRouteActsAndRouteIsOpen_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(false);
   
    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 whenInsertingActBetweenLastActAndEndAndRouteIsOpen_itCalculatesTpCostsFromPrevToNewAct(){
    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(false);
   
    double costs = calc.getCosts(jic, prevAct, nextAct, newAct, 0.0);
    assertEquals(3.0,costs,0.01);
View Full Code Here

    if(visitors.isEmpty()) return;
    if(route.isEmpty()) return;
    begin(route);
    Iterator<TourActivity> revIterator = route.getTourActivities().reverseActivityIterator();
    while(revIterator.hasNext()){
      TourActivity act = revIterator.next();
      visit(act);
    }
    finish(route);
  }
View Full Code Here

 

 
  @Test
  public void whenActivityStateIsSetWithGenericMethodAndBoolean_itMustBeSetCorrectly(){
    TourActivity activity = mock(TourActivity.class);
        when(activity.getIndex()).thenReturn(1);
    StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
    StateId id = stateManager.createStateId("myState");
    stateManager.putActivityState(activity, id, true);
    assertTrue(stateManager.getActivityState(activity, id, Boolean.class));
  }
View Full Code Here

    assertTrue(stateManager.getActivityState(activity, id, Boolean.class));
  }
 
  @Test
  public void whenActivityStateIsSetWithGenericMethodAndInteger_itMustBeSetCorrectly(){
    TourActivity activity = mock(TourActivity.class);
        when(activity.getIndex()).thenReturn(1);
    StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
    StateId id = stateManager.createStateId("myState");
    int load = 3;
    stateManager.putActivityState(activity, id, load);
    int getLoad = stateManager.getActivityState(activity, id, Integer.class);
View Full Code Here

    assertEquals(3, getLoad);
  }
 
  @Test
  public void whenActivityStateIsSetWithGenericMethodAndCapacity_itMustBeSetCorrectly(){
    TourActivity activity = mock(TourActivity.class);
        when(activity.getIndex()).thenReturn(1);
    StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
    StateId id = stateManager.createStateId("myState");
    Capacity capacity = Capacity.Builder.newInstance().addDimension(0, 500).build();
    stateManager.putActivityState(activity, id, capacity);
    Capacity getCap = stateManager.getActivityState(activity, id, Capacity.class);
View Full Code Here

        //noinspection UnusedDeclaration
        VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
        StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
        StateId id = stateManager.createStateId("myState");
        Capacity capacity = Capacity.Builder.newInstance().addDimension(0, 500).build();
        TourActivity act = mock(TourActivity.class);
        when(act.getIndex()).thenReturn(1);
        stateManager.putActivityState(act, vehicle, id, capacity);
        Capacity getCap = stateManager.getActivityState(act, vehicle, id, Capacity.class);
        assertEquals(500, getCap.get(0));
    }
View Full Code Here

TOP

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

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.