src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
ServiceActivity extends AbstractActivity implements TourActivity.JobActivity { @Override public Location getLocation() { return service.getLocation(); } protected ServiceActivity(Service service); protected ServiceActivity(ServiceActivity serviceActivity); double getArrTime(); void setArrTime(double arrTime); double ... | @Test public void whenIniLocationId_itShouldBeSetCorrectly() { assertEquals("loc", serviceActivity.getLocation().getId()); } |
DeliverShipment extends AbstractActivity implements DeliveryActivity { @Override public Capacity getSize() { return capacity; } DeliverShipment(Shipment shipment); private DeliverShipment(DeliverShipment deliveryShipmentActivity); @Override Job getJob(); @Override void setTheoreticalEarliestOperationStartTime(double e... | @Test public void whenCallingCapacity_itShouldReturnCorrectCapacity() { assertEquals(-10, deliver.getSize().get(0)); assertEquals(-100, deliver.getSize().get(1)); assertEquals(-1000, deliver.getSize().get(2)); }
@Test public void whenGettingCapacity_itShouldReturnItCorrectly() { Shipment shipment = Shipment.Builder.new... |
DeliverShipment extends AbstractActivity implements DeliveryActivity { @Override public double getTheoreticalEarliestOperationStartTime() { return earliest; } DeliverShipment(Shipment shipment); private DeliverShipment(DeliverShipment deliveryShipmentActivity); @Override Job getJob(); @Override void setTheoreticalEarl... | @Test public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly() { assertEquals(3., deliver.getTheoreticalEarliestOperationStartTime(), 0.01); } |
DeliverShipment extends AbstractActivity implements DeliveryActivity { @Override public double getTheoreticalLatestOperationStartTime() { return latest; } DeliverShipment(Shipment shipment); private DeliverShipment(DeliverShipment deliveryShipmentActivity); @Override Job getJob(); @Override void setTheoreticalEarliest... | @Test public void whenStartIsIniWithLatestStart_itShouldBeSetCorrectly() { assertEquals(4., deliver.getTheoreticalLatestOperationStartTime(), 0.01); } |
DeliverShipment extends AbstractActivity implements DeliveryActivity { @Override public Location getLocation() { return shipment.getDeliveryLocation(); } DeliverShipment(Shipment shipment); private DeliverShipment(DeliverShipment deliveryShipmentActivity); @Override Job getJob(); @Override void setTheoreticalEarliestO... | @Test public void whenIniLocationId_itShouldBeSetCorrectly() { assertEquals("deliveryLoc", deliver.getLocation().getId()); } |
DefaultShipmentActivityFactory implements TourShipmentActivityFactory { @Override public AbstractActivity createPickup(Shipment shipment) { return new PickupShipment(shipment); } @Override AbstractActivity createPickup(Shipment shipment); @Override AbstractActivity createDelivery(Shipment shipment); } | @Test public void whenCreatingPickupActivityWithShipment_itShouldReturnPickupShipment() { DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory(); Shipment shipment = Shipment.Builder.newInstance("s") .setPickupLocation(Location.Builder.newInstance().setId("pLoc").build()).setDeliveryLocation(Loca... |
DefaultShipmentActivityFactory implements TourShipmentActivityFactory { @Override public AbstractActivity createDelivery(Shipment shipment) { return new DeliverShipment(shipment); } @Override AbstractActivity createPickup(Shipment shipment); @Override AbstractActivity createDelivery(Shipment shipment); } | @Test public void whenCreatingDeliverActivityWithShipment_itShouldReturnDeliverShipment() { DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory(); Shipment shipment = Shipment.Builder.newInstance("s") .setPickupLocation(Location.Builder.newInstance().setId("pLoc").build()).setDeliveryLocation(Lo... |
DefaultTourActivityFactory implements TourActivityFactory { @Override public AbstractActivity createActivity(Service service) { AbstractActivity act; if (service instanceof Pickup) { act = new PickupService((Pickup) service); } else if (service instanceof Delivery) { act = new DeliverService((Delivery) service); } else... | @Test public void whenCreatingActivityWithService_itShouldReturnPickupService() { DefaultTourActivityFactory factory = new DefaultTourActivityFactory(); Service service = Service.Builder.newInstance("service").setLocation(Location.newInstance("loc")).build(); TourActivity act = factory.createActivity(service); assertNo... |
DeliverService extends AbstractActivity implements DeliveryActivity { @Override public Capacity getSize() { return capacity; } DeliverService(Delivery delivery); private DeliverService(DeliverService deliveryActivity); @Override String getName(); @Override Location getLocation(); @Override void setTheoreticalEarliestO... | @Test public void whenCallingCapacity_itShouldReturnCorrectCapacity() { assertEquals(-10, deliver.getSize().get(0)); assertEquals(-100, deliver.getSize().get(1)); assertEquals(-1000, deliver.getSize().get(2)); } |
DeliverService extends AbstractActivity implements DeliveryActivity { @Override public double getTheoreticalEarliestOperationStartTime() { return theoreticalEarliest; } DeliverService(Delivery delivery); private DeliverService(DeliverService deliveryActivity); @Override String getName(); @Override Location getLocation... | @Test public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly() { assertEquals(1., deliver.getTheoreticalEarliestOperationStartTime(), 0.01); } |
DeliverService extends AbstractActivity implements DeliveryActivity { @Override public double getTheoreticalLatestOperationStartTime() { return theoreticalLatest; } DeliverService(Delivery delivery); private DeliverService(DeliverService deliveryActivity); @Override String getName(); @Override Location getLocation(); ... | @Test public void whenStartIsIniWithLatestStart_itShouldBeSetCorrectly() { assertEquals(2., deliver.getTheoreticalLatestOperationStartTime(), 0.01); } |
DeliverService extends AbstractActivity implements DeliveryActivity { @Override public Location getLocation() { return delivery.getLocation(); } DeliverService(Delivery delivery); private DeliverService(DeliverService deliveryActivity); @Override String getName(); @Override Location getLocation(); @Override void setTh... | @Test public void whenIniLocationId_itShouldBeSetCorrectly() { assertEquals("loc", deliver.getLocation().getId()); } |
PickupService extends AbstractActivity implements PickupActivity { @Override public Capacity getSize() { return pickup.getSize(); } PickupService(Pickup pickup); PickupService(Service service); private PickupService(PickupService pickupActivity); @Override String getName(); @Override Location getLocation(); @Override... | @Test public void whenCallingCapacity_itShouldReturnCorrectCapacity() { assertEquals(10, pickup.getSize().get(0)); assertEquals(100, pickup.getSize().get(1)); assertEquals(1000, pickup.getSize().get(2)); } |
PickupService extends AbstractActivity implements PickupActivity { @Override public double getTheoreticalEarliestOperationStartTime() { return theoreticalEarliest; } PickupService(Pickup pickup); PickupService(Service service); private PickupService(PickupService pickupActivity); @Override String getName(); @Override... | @Test public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly() { assertEquals(1., pickup.getTheoreticalEarliestOperationStartTime(), 0.01); } |
PickupService extends AbstractActivity implements PickupActivity { @Override public double getTheoreticalLatestOperationStartTime() { return theoreticalLatest; } PickupService(Pickup pickup); PickupService(Service service); private PickupService(PickupService pickupActivity); @Override String getName(); @Override Loc... | @Test public void whenStartIsIniWithLatestStart_itShouldBeSetCorrectly() { assertEquals(2., pickup.getTheoreticalLatestOperationStartTime(), 0.01); } |
PickupService extends AbstractActivity implements PickupActivity { @Override public Location getLocation() { return pickup.getLocation(); } PickupService(Pickup pickup); PickupService(Service service); private PickupService(PickupService pickupActivity); @Override String getName(); @Override Location getLocation(); @... | @Test public void whenIniLocationId_itShouldBeSetCorrectly() { assertEquals("loc", pickup.getLocation().getId()); } |
BreakActivity extends AbstractActivity implements TourActivity.JobActivity { @Override public Capacity getSize() { return aBreak.getSize(); } protected BreakActivity(Break aBreak); protected BreakActivity(BreakActivity breakActivity); double getArrTime(); void setArrTime(double arrTime); double getEndTime(); void set... | @Test public void whenCallingCapacity_itShouldReturnCorrectCapacity() { assertEquals(0, serviceActivity.getSize().get(0)); } |
BreakActivity extends AbstractActivity implements TourActivity.JobActivity { @Override public Service getJob() { return aBreak; } protected BreakActivity(Break aBreak); protected BreakActivity(BreakActivity breakActivity); double getArrTime(); void setArrTime(double arrTime); double getEndTime(); void setEndTime(doub... | @Test public void hasVariableLocationShouldBeTrue() { Break aBreak = (Break) serviceActivity.getJob(); assertTrue(aBreak.hasVariableLocation()); } |
BreakActivity extends AbstractActivity implements TourActivity.JobActivity { public double getTheoreticalEarliestOperationStartTime() { return earliest; } protected BreakActivity(Break aBreak); protected BreakActivity(BreakActivity breakActivity); double getArrTime(); void setArrTime(double arrTime); double getEndTim... | @Test public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly() { assertEquals(1., serviceActivity.getTheoreticalEarliestOperationStartTime(), 0.01); } |
BreakActivity extends AbstractActivity implements TourActivity.JobActivity { public double getTheoreticalLatestOperationStartTime() { return latest; } protected BreakActivity(Break aBreak); protected BreakActivity(BreakActivity breakActivity); double getArrTime(); void setArrTime(double arrTime); double getEndTime();... | @Test public void whenStartIsIniWithLatestStart_itShouldBeSetCorrectly() { assertEquals(2., serviceActivity.getTheoreticalLatestOperationStartTime(), 0.01); } |
PickupShipment extends AbstractActivity implements PickupActivity { @Override public Capacity getSize() { return shipment.getSize(); } PickupShipment(Shipment shipment); private PickupShipment(PickupShipment pickupShipmentActivity); @Override Job getJob(); @Override void setTheoreticalEarliestOperationStartTime(double... | @Test public void whenCallingCapacity_itShouldReturnCorrectCapacity() { assertEquals(10, pickup.getSize().get(0)); assertEquals(100, pickup.getSize().get(1)); assertEquals(1000, pickup.getSize().get(2)); }
@Test public void whenGettingCapacity_itShouldReturnItCorrectly() { Shipment shipment = Shipment.Builder.newInstan... |
PickupShipment extends AbstractActivity implements PickupActivity { @Override public double getTheoreticalEarliestOperationStartTime() { return earliest; } PickupShipment(Shipment shipment); private PickupShipment(PickupShipment pickupShipmentActivity); @Override Job getJob(); @Override void setTheoreticalEarliestOper... | @Test public void whenStartIsIniWithEarliestStart_itShouldBeSetCorrectly() { assertEquals(1., pickup.getTheoreticalEarliestOperationStartTime(), 0.01); } |
PickupShipment extends AbstractActivity implements PickupActivity { @Override public double getTheoreticalLatestOperationStartTime() { return latest; } PickupShipment(Shipment shipment); private PickupShipment(PickupShipment pickupShipmentActivity); @Override Job getJob(); @Override void setTheoreticalEarliestOperatio... | @Test public void whenStartIsIniWithLatestStart_itShouldBeSetCorrectly() { assertEquals(2., pickup.getTheoreticalLatestOperationStartTime(), 0.01); } |
PickupShipment extends AbstractActivity implements PickupActivity { @Override public Location getLocation() { return shipment.getPickupLocation(); } PickupShipment(Shipment shipment); private PickupShipment(PickupShipment pickupShipmentActivity); @Override Job getJob(); @Override void setTheoreticalEarliestOperationSt... | @Test public void whenIniLocationId_itShouldBeSetCorrectly() { assertEquals("pickupLoc", pickup.getLocation().getId()); } |
VehicleRoute { public static VehicleRoute emptyRoute() { return Builder.newInstance(VehicleImpl.createNoVehicle(), DriverImpl.noDriver()).build(); } private VehicleRoute(VehicleRoute route); private VehicleRoute(Builder builder); static VehicleRoute copyOf(VehicleRoute route); static VehicleRoute emptyRoute(); List<T... | @Test public void whenBuildingEmptyRouteCorrectlyV2_go() { VehicleRoute route = VehicleRoute.emptyRoute(); assertTrue(route != null); }
@Test public void whenCreatingEmptyRoute_itMustReturnEmptyRoute() { @SuppressWarnings("unused") VehicleRoute route = VehicleRoute.emptyRoute(); assertTrue(true); } |
VehicleRoute { public TourActivities getTourActivities() { return tourActivities; } private VehicleRoute(VehicleRoute route); private VehicleRoute(Builder builder); static VehicleRoute copyOf(VehicleRoute route); static VehicleRoute emptyRoute(); List<TourActivity> getActivities(); TourActivities getTourActivities();... | @Test public void whenBuildingANonEmptyTour2Times_tourIterIteratesOverActivitiesCorrectly() { VehicleRoute.Builder routeBuilder = VehicleRoute.Builder.newInstance(vehicle, driver); routeBuilder.addService(Service.Builder.newInstance("2").addSizeDimension(0, 30).setLocation(Location.newInstance("1")).build()); VehicleRo... |
VehicleRoute { public Start getStart() { return start; } private VehicleRoute(VehicleRoute route); private VehicleRoute(Builder builder); static VehicleRoute copyOf(VehicleRoute route); static VehicleRoute emptyRoute(); List<TourActivity> getActivities(); TourActivities getTourActivities(); Vehicle getVehicle(); Driv... | @Test public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectStartLocation() { Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setEndLocation(Location.newInstance("end")).build(); VehicleRoute vRoute = VehicleRoute.Builder.n... |
VehicleRoute { public End getEnd() { return end; } private VehicleRoute(VehicleRoute route); private VehicleRoute(Builder builder); static VehicleRoute copyOf(VehicleRoute route); static VehicleRoute emptyRoute(); List<TourActivity> getActivities(); TourActivities getTourActivities(); Vehicle getVehicle(); Driver get... | @Test public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectEndLocation() { Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setEndLocation(Location.newInstance("end")).build(); VehicleRoute vRoute = VehicleRoute.Builder.new... |
VehicleRoute { public List<TourActivity> getActivities() { return tourActivities.getActivities(); } private VehicleRoute(VehicleRoute route); private VehicleRoute(Builder builder); static VehicleRoute copyOf(VehicleRoute route); static VehicleRoute emptyRoute(); List<TourActivity> getActivities(); TourActivities getT... | @Test public void whenAddingPickup_itShouldBeTreatedAsPickup() { Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").setLocation(Location.newInstance("pickLoc")).build(); VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocation(Location.newInstance("startLoc")).build(); VehicleRoute rou... |
VehicleRoutingProblemSolution { public Collection<VehicleRoute> getRoutes() { return routes; } private VehicleRoutingProblemSolution(VehicleRoutingProblemSolution solution); VehicleRoutingProblemSolution(Collection<VehicleRoute> routes, double cost); VehicleRoutingProblemSolution(Collection<VehicleRoute> routes, Col... | @Test public void whenCreatingSolutionWithTwoRoutes_solutionShouldContainTheseRoutes() { VehicleRoute r1 = mock(VehicleRoute.class); VehicleRoute r2 = mock(VehicleRoute.class); VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Arrays.asList(r1, r2), 0.0); assertEquals(2, sol.getRoutes().size()); } |
VehicleRoutingProblemSolution { public double getCost() { return cost; } private VehicleRoutingProblemSolution(VehicleRoutingProblemSolution solution); VehicleRoutingProblemSolution(Collection<VehicleRoute> routes, double cost); VehicleRoutingProblemSolution(Collection<VehicleRoute> routes, Collection<Job> unassigne... | @Test public void whenSettingSolutionCostsTo10_solutionCostsShouldBe10() { VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), 10.0); assertEquals(10.0, sol.getCost(), 0.01); } |
VehicleRoutingProblemSolution { public Collection<Job> getUnassignedJobs() { return unassignedJobs; } private VehicleRoutingProblemSolution(VehicleRoutingProblemSolution solution); VehicleRoutingProblemSolution(Collection<VehicleRoute> routes, double cost); VehicleRoutingProblemSolution(Collection<VehicleRoute> rout... | @Test public void sizeOfBadJobsShouldBeCorrect() { Job badJob = mock(Job.class); List<Job> badJobs = new ArrayList<Job>(); badJobs.add(badJob); VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(Collections.<VehicleRoute>emptyList(), badJobs, 10.0); assertEquals(1, sol.getUnassignedJobs().size()); }
... |
SolutionAnalyser { public Capacity getLoadAtBeginning(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, InternalStates.LOAD_AT_BEGINNING, Capacity.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution ... | @Test public void loadAtBeginningOfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0, analyser.getLoadAtBeginning(route).get(0)); }
@Test public void loadAtBeginningOfRoute2Sho... |
SolutionAnalyser { public Capacity getLoadAtEnd(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, InternalStates.LOAD_AT_END, Capacity.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, Tr... | @Test public void loadAtEnd_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(5, analyser.getLoadAtEnd(route).get(0)); }
@Test public void loadAtEnd_OfRoute2ShouldWork() { Solu... |
SolutionAnalyser { public Capacity getLoadRightAfterActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); if (activity instanceof Start) return getLoadAtBeginning... | @Test public void loadAfterActivity_ofStartActOfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0, analyser.getLoadRightAfterActivity(route.getStart(), route).get(0)); }
@Test ... |
SolutionAnalyser { public Capacity getLoadJustBeforeActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); if (activity instanceof Start) return getLoadAtBeginning... | @Test public void loadBeforeActivity_ofStartActOfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0, analyser.getLoadJustBeforeActivity(route.getStart(), route).get(0)); }
@Test... |
SolutionAnalyser { public Capacity getMaxLoad(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, InternalStates.MAXLOAD, Capacity.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, Transpor... | @Test public void maxLoad_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(12, analyser.getMaxLoad(route).get(0)); } |
SolutionAnalyser { public Integer getNumberOfPickups(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, stateManager.createStateId(PICKUP_COUNT), Integer.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSol... | @Test public void pickupCount_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(3, analyser.getNumberOfPickups(route), 0.01); }
@Test public void pickupCount_OfRoute1OfAnotherS... |
SolutionAnalyser { public Integer getNumberOfPickupsAtBeginning(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, stateManager.createStateId(PICKUP_COUNT_AT_BEGINNING), Integer.class); } SolutionAnalyser(VehicleRoutingProblem vrp, ... | @Test public void pickupCountAtBeginning_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0, analyser.getNumberOfPickupsAtBeginning(route), 0.01); }
@Test public void pickupCo... |
VehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (vehicle == null) return getDistance(from.getId(), to.getId()); VehicleCostParams costParams = vehicle.... | @Test public void whenAddingDistanceToAsymmetricMatrix_itShouldReturnCorrectValues() { VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(false); matrixBuilder.addTransportDistance("1", "2", 2.); VehicleRoutingTransportCostsMatrix matrix = matrixBuilder.bui... |
SolutionAnalyser { public Capacity getLoadPickedUp(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, stateManager.createStateId(LOAD_PICKED), Capacity.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolut... | @Test public void pickupLoad_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(15, analyser.getLoadPickedUp(route).get(0), 0.01); }
@Test public void pickupLoad_OfRoute1OfAnoth... |
SolutionAnalyser { public Integer getNumberOfDeliveries(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, stateManager.createStateId(DELIVERY_COUNT), Integer.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProbl... | @Test public void deliveryCount_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(1, analyser.getNumberOfDeliveries(route), 0.01); }
@Test public void deliveryCount_OfRoute1OfA... |
SolutionAnalyser { public Integer getNumberOfDeliveriesAtEnd() { return noDeliveriesAtEnd; } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDistance distanceCalculator); SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, SolutionCostCalcula... | @Test public void deliveryCountAtEnd_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(2, analyser.getNumberOfDeliveriesAtEnd(route), 0.01); }
@Test public void deliveryCountAt... |
SolutionAnalyser { public Capacity getLoadDelivered(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, stateManager.createStateId(LOAD_DELIVERED), Capacity.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemS... | @Test public void deliveryLoad_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(10, analyser.getLoadDelivered(route).get(0), 0.01); }
@Test public void deliveryLoad_OfRoute1Of... |
SolutionAnalyser { public Double getOperationTime(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return route.getEnd().getArrTime() - route.getStart().getEndTime(); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDistance ... | @Test public void operationTime_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(46. + 40., analyser.getOperationTime(route), 0.01); } |
SolutionAnalyser { public Double getWaitingTime(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, waitingTimeId, Double.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDistance... | @Test public void waitingTime_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(4., analyser.getWaitingTime(route), 0.01); } |
SolutionAnalyser { public Double getTransportTime(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, transportTimeId, Double.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDist... | @Test public void transportTime_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(42., analyser.getTransportTime(route), 0.01); } |
SolutionAnalyser { public Double getServiceTime(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, serviceTimeId, Double.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDistance... | @Test public void serviceTime_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(40., analyser.getServiceTime(route), 0.01); } |
SolutionAnalyser { public Double getDistance(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, distanceId, Double.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDistance dista... | @Test public void distance_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(42., analyser.getDistance(route), 0.01); } |
SolutionAnalyser { public Double getWaitingTimeAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); double waitingTime = 0.; if (activityPolicy.equals(Activity... | @Test public void waitingTime_atStartActOfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0, analyser.getWaitingTimeAtActivity(route.getStart(), route), 0.01); }
@Test public v... |
VehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { return getTime(from.getId(), to.getId()); } private VehicleRoutingTransportCostsMatrix(Builder builder); ... | @Test public void whenAddingTimeToSymmetricMatrix_itShouldReturnCorrectValues() { VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true); matrixBuilder.addTransportTime("1", "2", 2.); VehicleRoutingTransportCostsMatrix matrix = matrixBuilder.build(); asse... |
SolutionAnalyser { public Double getDistanceAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); if (activity instanceof Start) return 0.; if (activity instanc... | @Test public void distance_atStartActOfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0, analyser.getDistanceAtActivity(route.getStart(), route), 0.01); }
@Test public void di... |
SolutionAnalyser { public Double getTimeWindowViolationAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); return Math.max(0, activity.getArrTime() - activity... | @Test public void lateArrivalTimes_atStartActOfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0, analyser.getTimeWindowViolationAtActivity(route.getStart(), route), 0.01); }
@... |
SolutionAnalyser { public Double getTimeWindowViolation(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, tooLateId, Double.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDist... | @Test public void lateArrTimes_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0., analyser.getTimeWindowViolation(route), 0.01); }
@Test public void timeWindowViolation_shou... |
SolutionAnalyser { public Double getVariableTransportCosts(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, InternalStates.COSTS, Double.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution,... | @Test public void variableTransportCosts_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(84., analyser.getVariableTransportCosts(route), 0.01); } |
SolutionAnalyser { public Double getFixedCosts(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return route.getVehicle().getType().getVehicleCostParams().fix; } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDistance distanc... | @Test public void fixedCosts_OfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(100., analyser.getFixedCosts(route), 0.01); } |
SolutionAnalyser { public Double getVariableTransportCostsAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); if (activity instanceof Start) return 0.; if (ac... | @Test public void transportCosts_atStartActOfRoute1ShouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Assert.assertEquals(0, analyser.getVariableTransportCostsAtActivity(route.getStart(), route), 0.01); }
... |
SolutionAnalyser { public Capacity getCapacityViolationAtBeginning(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); Capacity atBeginning = getLoadAtBeginning(route); return Capacity.max(Capacity.Builder.newInstance().build(), Capacity.subtract(atBeginning, route.getVehic... | @Test public void capacityViolationAtBeginning_shouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Capacity atBeginning = analyser.getCapacityViolationAtBeginning(route); for (int i = 0; i < atBeginning.get... |
SolutionAnalyser { public Capacity getCapacityViolationAtEnd(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); Capacity atEnd = getLoadAtEnd(route); return Capacity.max(Capacity.Builder.newInstance().build(), Capacity.subtract(atEnd, route.getVehicle().getType().getCapaci... | @Test public void capacityViolationAtEnd_shouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Capacity atEnd = analyser.getCapacityViolationAtEnd(route); for (int i = 0; i < atEnd.getNuOfDimensions(); i++) {... |
SolutionAnalyser { public Capacity getCapacityViolation(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); Capacity maxLoad = getMaxLoad(route); return Capacity.max(Capacity.Builder.newInstance().build(), Capacity.subtract(maxLoad, route.getVehicle().getType().getCapacityD... | @Test public void capacityViolationOnRoute_shouldWorkWhenViolated() { buildAnotherScenarioWithOnlyOneVehicleAndWithoutAnyConstraintsBefore(); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Capacity cap = analyser.get... |
SolutionAnalyser { public Capacity getCapacityViolationAfterActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); Capacity afterAct = getLoadRightAfterActivity(ac... | @Test public void capacityViolationAfterStart_shouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); TourActivity act = route.getStart(); Capacity cap = analyser.getCapacityViolationAfterActivity(act, route); ... |
SolutionAnalyser { public Boolean hasBackhaulConstraintViolation(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, backhaulId, Boolean.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, Tr... | @Test public void backhaulViolation_shouldWorkWhenViolated() { buildAnotherScenarioWithOnlyOneVehicleAndWithoutAnyConstraintsBefore(); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Boolean violation = analyser.hasBa... |
SolutionAnalyser { public Boolean hasBackhaulConstraintViolationAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); if (activity instanceof Start) return fals... | @Test public void backhaulViolationAtStart_shouldWork() { buildAnotherScenarioWithOnlyOneVehicleAndWithoutAnyConstraintsBefore(); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Boolean violation = analyser.hasBackhau... |
SolutionAnalyser { public Boolean hasShipmentConstraintViolationAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); if (activity instanceof Start) return fals... | @Test public void shipmentViolationAtStart_shouldWork() { buildAnotherScenarioWithOnlyOneVehicleAndWithoutAnyConstraintsBefore(); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Boolean violation = analyser.hasShipmen... |
SolutionAnalyser { public Boolean hasShipmentConstraintViolation(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, shipmentId, Boolean.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, Tr... | @Test public void shipmentViolation_shouldWork() { buildAnotherScenarioWithOnlyOneVehicleAndWithoutAnyConstraintsBefore(); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Boolean violation = analyser.hasShipmentConstr... |
SolutionAnalyser { public Boolean hasSkillConstraintViolation(VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); return stateManager.getRouteState(route, skillId, Boolean.class); } SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, Transpor... | @Test public void skillViolationOnRoute_shouldWorkWhenViolated() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Boolean violated = analyser.hasSkillConstraintViolation(route); assertTrue(violated); }
@Test public v... |
SolutionAnalyser { public Boolean hasSkillConstraintViolationAtActivity(TourActivity activity, VehicleRoute route) { if (route == null) throw new IllegalArgumentException("route is missing."); if (activity == null) throw new IllegalArgumentException("activity is missing."); if (activity instanceof Start) return false; ... | @Test public void skillViolationAtStart_shouldWork() { SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts()); VehicleRoute route = solution.getRoutes().iterator().next(); Boolean violated = analyser.hasSkillConstraintViolationAtActivity(route.getStart(), route); assertFalse(violated);... |
SearchStrategy { public void addModule(SearchStrategyModule module) { if (module == null) throw new IllegalStateException("module to be added is null."); searchStrategyModules.add(module); logger.debug("module added [module={}][#modules={}]", module, searchStrategyModules.size()); } SearchStrategy(String id, SolutionSe... | @Test(expected = IllegalStateException.class) public void whenANullModule_IsAdded_throwException() { SolutionSelector select = mock(SolutionSelector.class); SolutionAcceptor accept = mock(SolutionAcceptor.class); SolutionCostCalculator calc = mock(SolutionCostCalculator.class); SearchStrategy strat = new SearchStrategy... |
SelectBest implements SolutionSelector { @Override public VehicleRoutingProblemSolution selectSolution(Collection<VehicleRoutingProblemSolution> solutions) { double minCost = Double.MAX_VALUE; VehicleRoutingProblemSolution bestSolution = null; for (VehicleRoutingProblemSolution sol : solutions) { if (bestSolution == nu... | @Test public void whenHaving2Solutions_selectBest() { VehicleRoutingProblemSolution sol1 = mock(VehicleRoutingProblemSolution.class); VehicleRoutingProblemSolution sol2 = mock(VehicleRoutingProblemSolution.class); when(sol1.getCost()).thenReturn(1.0); when(sol2.getCost()).thenReturn(2.0); assertThat(new SelectBest().se... |
GreedyAcceptance implements SolutionAcceptor { @Override public boolean acceptSolution(Collection<VehicleRoutingProblemSolution> solutions, VehicleRoutingProblemSolution newSolution) { boolean solutionAccepted = false; if (solutions.size() < solutionMemory) { solutions.add(newSolution); solutionAccepted = true; } else ... | @Test public void whenHavingNewSolAndLimitedMemory_removeWorstAndAddNew() { VehicleRoutingProblemSolution sol1 = mock(VehicleRoutingProblemSolution.class); VehicleRoutingProblemSolution sol2 = mock(VehicleRoutingProblemSolution.class); when(sol1.getCost()).thenReturn(1.0); when(sol2.getCost()).thenReturn(2.0); List<Veh... |
SchrimpfAcceptance implements SolutionAcceptor, IterationStartsListener, AlgorithmStartsListener { @Override public boolean acceptSolution(Collection<VehicleRoutingProblemSolution> solutions, VehicleRoutingProblemSolution newSolution) { boolean solutionAccepted = false; if (solutions.size() < solutionMemory) { solution... | @Test public void respectsTheZeroThreshold_usingWorstCostSolution() { assertFalse("Worst cost solution (2.1 > 2.0) should not be accepted", schrimpfAcceptance.acceptSolution(memory, createSolutionWithCost(2.1))); }
@Test public void respectsTheZeroThreshold_usingBetterCostSolution() { assertTrue("Better cost solution (... |
StateManager implements RouteAndActivityStateGetter, IterationStartsListener, RuinListener, InsertionStartsListener, JobInsertedListener, InsertionEndsListener { @Override public <T> T getRouteState(VehicleRoute route, StateId stateId, Class<T> type) { if (route == null) return null; T state = null; if(isIndexedBased){... | @Test public void whenInternalRouteStateIsNotSet_itShouldReturnNull() { VehicleRoute route = getRoute(mock(Vehicle.class)); StateManager stateManager = new StateManager(vrpMock); StateId id = InternalStates.COSTS; Double costs = stateManager.getRouteState(route, id, Double.class); assertTrue(costs == null); }
@Test pub... |
Time { public static double parseTimeToSeconds(String timeString) { if (timeString.substring(0, 1).matches("\\D")) throw new IllegalArgumentException("timeString must start with digit [0-9]"); double dayTime = 0.; if (timeString.toLowerCase().contains("pm")) { dayTime = 12. * 3600.; } String[] tokens = timeString.split... | @Test public void sixAM_shouldBeParsedCorrectly() { double sec = Time.parseTimeToSeconds("6AM"); assertEquals(6. * 3600., sec, 0.01); }
@Test public void sixAMWithWhiteSpace_shouldBeParsedCorrectly() { double sec = Time.parseTimeToSeconds("6 AM"); assertEquals(6. * 3600., sec, 0.01); }
@Test public void sixaMWithWhiteS... |
StateManager implements RouteAndActivityStateGetter, IterationStartsListener, RuinListener, InsertionStartsListener, JobInsertedListener, InsertionEndsListener { public StateId createStateId(String name) { if (createdStateIds.containsKey(name)) return createdStateIds.get(name); if (stateIndexCounter >= activityStates[0... | @Test public void whenCreatingNewState_itShouldHaveAnIndex() { StateManager stateManager = new StateManager(vrpMock); StateId stateId = stateManager.createStateId("foo-state"); Assert.assertEquals(21, stateId.getIndex()); }
@Test public void whenCreatingNewStates_theyShouldHaveAnIndex() { StateManager stateManager = ne... |
Inserter { public void insertJob(Job job, InsertionData insertionData, VehicleRoute vehicleRoute) { insertionListeners.informBeforeJobInsertion(job, insertionData, vehicleRoute); if (insertionData == null || (insertionData instanceof NoInsertionFound)) throw new IllegalStateException("insertionData null. cannot insert ... | @Test public void whenInsertingServiceAndRouteIsClosed_itInsertsCorrectly() { Service service = mock(Service.class); Vehicle vehicle = mock(Vehicle.class); when(vehicle.getStartLocation()).thenReturn(loc("vehLoc")); when(vehicle.getEndLocation()).thenReturn(loc("vehLoc")); when(vehicle.isReturnToDepot()).thenReturn(tru... |
ShipmentInsertionCalculator extends AbstractInsertionCalculator { @Override public InsertionData getInsertionData(final VehicleRoute currentRoute, final Job jobToInsert, final Vehicle newVehicle, double newVehicleDepartureTime, final Driver newDriver, final double bestKnownCosts) { JobInsertionContext insertionContext ... | @Test public void whenCalculatingInsertionCostsOfShipment_itShouldReturnCorrectCostValue() { Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocation(Location.newInstance("10,0")).build(); VehicleRoute route ... |
LocalActivityInsertionCostsCalculator implements ActivityInsertionCostsCalculator { @Override public double getCosts(JobInsertionContext iFacts, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double depTimeAtPrevAct) { Location prevLocation = prevAct.getLocation(); if (prevAct instanceof ActWithoutSta... | @Test public void whenAddingServiceBetweenDiffStartAndEnd_costMustBeCorrect() { VehicleImpl v = VehicleImpl.Builder.newInstance("v") .setStartLocation(Location.newInstance(0, 0)) .setEndLocation(Location.newInstance(20, 0)) .build(); Service s = Service.Builder.newInstance("s") .setLocation(Location.newInstance(10, 0))... |
AuxilliaryCostCalculator { public double costOfPath(final List<TourActivity> path, final double depTime, final Driver driver, final Vehicle vehicle) { if (path.isEmpty()) { return 0.0; } double cost = 0.0; Iterator<TourActivity> actIter = path.iterator(); TourActivity prevAct = actIter.next(); double startCost = 0.0; c... | @Test public void whenRouteIsClosed_itCalculatesCostUpToEnd_v1() { TourActivity prevAct = mock(TourActivity.class); when(prevAct.getLocation()).thenReturn(loc("i")); TourActivity nextAct = mock(TourActivity.class); when(nextAct.getLocation()).thenReturn(loc("j")); TourActivity newAct = mock(TourActivity.class); when(ne... |
RuinWorst extends AbstractRuinStrategy { @Override public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) { List<Job> unassignedJobs = new ArrayList<>(); int nOfJobs2BeRemoved = getRuinShareFactory().createNumberToBeRemoved(); ruin(vehicleRoutes, nOfJobs2BeRemoved, unassignedJobs); return unassignedJ... | @Test public void itShouldRemoveCorrectNumber() { Service s1 = Service.Builder.newInstance("s1") .setLocation(Location.Builder.newInstance().setCoordinate(Coordinate.newInstance(1, 1)).build()).build(); Service s2 = Service.Builder.newInstance("s2") .setLocation(Location.Builder.newInstance().setCoordinate(Coordinate.n... |
StringUtil { static List<Integer> getLowerBoundsOfAllStrings(int length, int seedIndex, int routeLength) { List<Integer> lowerBounds = new ArrayList<>(); for (int i = 1; i <= length; i++) { int lower = seedIndex - (length - i); int upper = seedIndex + (i - 1); if (lower >= 0 && upper < routeLength) { lowerBounds.add(lo... | @Test public void test() { int stringLength = 4; int seedIndex = 4; int noActivities = 10; List<Integer> bounds = StringUtil.getLowerBoundsOfAllStrings(stringLength, seedIndex, noActivities); Assert.assertEquals(4, bounds.size()); Assert.assertEquals(1, (int) bounds.get(0)); Assert.assertEquals(2, (int) bounds.get(1));... |
RuinClusters extends AbstractRuinStrategy implements IterationStartsListener { @Override public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) { List<Job> unassignedJobs = new ArrayList<>(); int nOfJobs2BeRemoved = getRuinShareFactory().createNumberToBeRemoved(); ruin(vehicleRoutes, nOfJobs2BeRemove... | @Test public void itShouldRuinTwoObviousClusters() { Service s0 = Service.Builder.newInstance("s0").setLocation(Location.newInstance(9, 0)).build(); Service s1 = Service.Builder.newInstance("s1").setLocation(Location.newInstance(9, 1)).build(); Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInst... |
RuinRadial extends AbstractRuinStrategy { @Override public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) { if (vehicleRoutes.isEmpty()) { return Collections.emptyList(); } int nOfJobs2BeRemoved = Math.min(ruinShareFactory.createNumberToBeRemoved(), noJobsToMemorize); Collection<Job> jobs = vrp.getJ... | @Test public void whenNoJobHasLocation_itShouldStillWork() { Service s1 = Service.Builder.newInstance("s1").build(); Service s2 = Service.Builder.newInstance("s2").build(); Service s3 = Service.Builder.newInstance("s3").build(); VehicleImpl v = VehicleImpl.Builder.newInstance("v") .setStartLocation(Location.Builder.new... |
Jsprit { public static VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vehicleRoutingProblem) { return Jsprit.Builder.newInstance(vehicleRoutingProblem).buildAlgorithm(); } private Jsprit(Builder builder); static VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vehicleRoutingProblem); } | @Test public void whenRunningJspritWithSingleCustomer_itShouldWork() { Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1, 1)).build(); VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build(); VehicleRoutingProblem vrp = VehicleRoutingProbl... |
RuinAndRecreateModule implements SearchStrategyModule { @Override public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution previousVrpSolution) { Collection<Job> ruinedJobs = ruin.ruin(previousVrpSolution.getRoutes()); Set<Job> ruinedJobSet = new HashSet<>(ruinedJobs); List<Job> stillUnassig... | @Test public void initialNumOfUnassignedShouldWorkCorrectly() { InsertionStrategy insertionStrategy = mock(InsertionStrategy.class); RuinStrategy ruinStrategy = mock(RuinStrategy.class); RuinAndRecreateModule module = new RuinAndRecreateModule("name", insertionStrategy, ruinStrategy); Collection<VehicleRoute> routes = ... |
SearchStrategyManager { public void addStrategy(SearchStrategy strategy, double weight) { if (strategy == null) { throw new IllegalStateException("strategy is null. make sure adding a valid strategy."); } if (id2index.keySet().contains(strategy.getId())) { throw new IllegalStateException("strategyId " + strategy.getId(... | @Test public void StrategyManagerInAction_addingStrategy_IsSuccessful() { SearchStrategyManager manager = new SearchStrategyManager(); SearchStrategy strat1 = mock(SearchStrategy.class); SearchStrategy strat2 = mock(SearchStrategy.class); when(strat1.getId()).thenReturn("strat1"); when(strat2.getId()).thenReturn("strat... |
VrpXMLReader { public void read(String filename) { logger.debug("read vrp: {}", filename); XMLConfiguration xmlConfig = createXMLConfiguration(); try { xmlConfig.load(filename); } catch (ConfigurationException e) { throw new RuntimeException(e); } read(xmlConfig); } VrpXMLReader(VehicleRoutingProblem.Builder vrpBuilder... | @Test public void shouldReadNameOfService() { VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(builder, null).read(inputStream); VehicleRoutingProblem vrp = builder.build(); Service s = (Service) vrp.getJobs().get("1"); assertTrue(s.getName().equals("cleaning")); }
@... |
VrpXMLWriter { public void write(String filename) { if (!filename.endsWith(".xml")) filename += ".xml"; log.info("write vrp: " + filename); XMLConf xmlConfig = createXMLConfiguration(); try { xmlConfig.setFileName(filename); Writer out = new FileWriter(filename); XMLSerializer serializer = new XMLSerializer(out, create... | @Test public void outputStreamAndFileContentsAreEqual() throws IOException { VehicleRoutingProblem.Builder builder = twoVehicleTypesAndImpls(); VehicleRoutingProblem vrp = builder.build(); VrpXMLWriter vrpXMLWriter = new VrpXMLWriter(vrp, null); ByteArrayOutputStream os = (ByteArrayOutputStream) vrpXMLWriter.write(); S... |
UnassignedJobReasonTracker implements JobUnassignedListener { public int getMostLikelyReasonCode(String jobId) { if (!this.failedConstraintNamesFrequencyMapping.containsKey(jobId)) return -1; Frequency reasons = this.failedConstraintNamesFrequencyMapping.get(jobId); String mostLikelyReason = getMostLikelyFailedConstrai... | @Test public void shouldReturnCorrectCapacityReasonCode() { Service service = Service.Builder.newInstance("1").addSizeDimension(0, 5).setLocation(Location.newInstance(5, 7)).build(); VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().setFleetSize(VehicleRoutingProblem.FleetSize.FINITE).addVehicle(v... |
UnassignedJobReasonTracker implements JobUnassignedListener { public static String getMostLikelyFailedConstraintName(Frequency failedConstraintNamesFrequency) { if (failedConstraintNamesFrequency == null || failedConstraintNamesFrequency.getUniqueCount() == 0) return NO_REASON; Iterator<Map.Entry<Comparable<?>, Long>> ... | @Test public void getMostLikelyTest() { Frequency frequency = new Frequency(); frequency.addValue("a"); frequency.addValue("b"); frequency.addValue("a"); frequency.addValue("a"); frequency.addValue("a"); frequency.addValue("a"); frequency.addValue("a"); Assert.assertEquals("a", UnassignedJobReasonTracker.getMostLikelyF... |
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr... | @Test public void whenAddingDistanceToAsymmetricMatrix_itShouldReturnCorrectValues() { FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(3, false); matrixBuilder.addTransportDistance(1, 2, 2.); FastVehicleRoutingTransportCostsMatrix matrix = matrix... |
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr... | @Test public void whenAddingTimeToSymmetricMatrix_itShouldReturnCorrectValues() { FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(3, true); matrixBuilder.addTransportTime(1, 2, 2.); FastVehicleRoutingTransportCostsMatrix matrix = matrixBuilder.bu... |
RandomUtils { public static <T> T nextItem(Collection<T> items, Random random) { int randomIndex = random.nextInt(items.size()); int count = 0; for (T item : items) { if (count == randomIndex) return item; count++; } return null; } static VehicleRoute nextRoute(Collection<VehicleRoute> routes, Random random); static J... | @Test public void shouldReturnSingleJob() { Job job = mock(Job.class); Collection<Job> jobs = Arrays.asList(job); Assert.assertEquals(job, RandomUtils.nextItem(jobs, RandomNumberGeneration.getRandom())); } |
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } static VehicleRoute nextRoute(Collection<VehicleRoute> routes, Random random); static Job nextJob(Collection<Job> jobs, Random random); static Job nextJob(List<Job> jobs, Random random); static T nextItem(Co... | @Test public void shouldReturnSingleJob_() { Job job = mock(Job.class); Collection<Job> jobs = Arrays.asList(job); Assert.assertEquals(job, RandomUtils.nextJob(jobs, RandomNumberGeneration.getRandom())); }
@Test public void shouldReturnJob3() { Job job3 = mock(Job.class); List<Job> jobs = Arrays.asList(mock(Job.class),... |
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =... | @Test public void test() { double lon1 = 8.3858333; double lat1 = 49.0047222; double lon2 = 12.1333333; double lat2 = 54.0833333; double greatCircle = GreatCircleDistanceCalculator.calculateDistance( Coordinate.newInstance(lon1, lat1), Coordinate.newInstance(lon2, lat2), DistanceUnit.Kilometer ); Assert.assertEquals(60... |
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } VehicleFleetMan... | @Test public void testGetVehicles() { Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles(); assertEquals(2, vehicles.size()); }
@Test public void testGetVehiclesWithout() { Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles(v1); assertEquals(v2, vehicles.iterator().next()); assertEquals(1, v... |
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void lock(Vehicle vehicle) { if (vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } if(locked[vehicle.getIndex()]){ throw new IllegalStateException("cannot lock vehicle twice " + vehicle.getId()); } else{ locked[vehicle.g... | @Test public void testLock() { fleetManager.lock(v1); Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles(); assertEquals(1, vehicles.size()); } |
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public boolean isLocked(Vehicle vehicle) { return locked[vehicle.getIndex()]; } VehicleFleetManagerImpl(Collection<Vehicle> vehicles); VehicleFleetManagerImpl newInstance(Collection<Vehicle> vehicles); @Override String toString(); @Override Collection<V... | @Test public void testIsLocked() { fleetManager.lock(v1); assertTrue(fleetManager.isLocked(v1)); } |
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void unlock(Vehicle vehicle) { if (vehicle == null || vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } locked[vehicle.getIndex()] = false; addVehicle(vehicle); } VehicleFleetManagerImpl(Collection<Vehicle> vehicles); Ve... | @Test public void testUnlock() { fleetManager.lock(v1); Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles(); assertEquals(1, vehicles.size()); fleetManager.unlock(v1); Collection<Vehicle> vehicles_ = fleetManager.getAvailableVehicles(); assertEquals(2, vehicles_.size()); } |
VehicleImpl extends AbstractVehicle { @Override public Break getBreak() { return aBreak; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestArrival(); @Overri... | @Test public void whenAddingDriverBreak_itShouldBeAddedCorrectly() { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build(); Break aBreak = Break.Builder.newInstance("break").setTimeWindow(TimeWindow.newInstance(100, 200)).setServiceTime(30).build(); Vehicle v = VehicleImpl.Builder.newInstance("v")... |
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr... | @Test public void whenVehicleIsBuiltToReturnToDepot_itShouldReturnToDepot() { Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(true).setStartLocation(Location.newInstance("loc")).build(); assertTrue(v.isReturnToDepot()); }
@Test public void whenVehicleIsBuiltToNotReturnToDepot_itShouldNotReturnToDepot(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.