diff --git a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/GraphStreamViewer.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/GraphStreamViewer.java index 303837b1..83252ce6 100644 --- a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/GraphStreamViewer.java +++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/GraphStreamViewer.java @@ -1,35 +1,21 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.analysis.toolbox; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; - import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.job.Job; import jsprit.core.problem.job.Service; @@ -42,7 +28,6 @@ import jsprit.core.problem.solution.route.activity.TourActivity; import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity; import jsprit.core.problem.vehicle.PenaltyVehicleType; import jsprit.core.problem.vehicle.Vehicle; - import org.graphstream.graph.Edge; import org.graphstream.graph.Graph; import org.graphstream.graph.Node; @@ -50,6 +35,9 @@ import org.graphstream.graph.implementations.MultiGraph; import org.graphstream.ui.swingViewer.View; import org.graphstream.ui.swingViewer.Viewer; +import javax.swing.*; +import java.awt.*; + public class GraphStreamViewer { @@ -359,21 +347,21 @@ public class GraphStreamViewer { private void renderShipment(Graph g, Shipment shipment, Label label, boolean renderShipments) { - Node n1 = g.addNode(makeId(shipment.getId(),shipment.getPickupLocation())); + Node n1 = g.addNode(makeId(shipment.getId(),shipment.getPickupLocationId())); if(label.equals(Label.ID)) n1.addAttribute("ui.label", shipment.getId()); n1.addAttribute("x", shipment.getPickupCoord().getX()); n1.addAttribute("y", shipment.getPickupCoord().getY()); n1.setAttribute("ui.class", "pickup"); - Node n2 = g.addNode(makeId(shipment.getId(),shipment.getDeliveryLocation())); + Node n2 = g.addNode(makeId(shipment.getId(),shipment.getDeliveryLocationId())); if(label.equals(Label.ID)) n2.addAttribute("ui.label", shipment.getId()); n2.addAttribute("x", shipment.getDeliveryCoord().getX()); n2.addAttribute("y", shipment.getDeliveryCoord().getY()); n2.setAttribute("ui.class", "delivery"); if(renderShipments){ - Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(),shipment.getPickupLocation()), - makeId(shipment.getId(),shipment.getDeliveryLocation()), true); + Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(),shipment.getPickupLocationId()), + makeId(shipment.getId(),shipment.getDeliveryLocationId()), true); s.addAttribute("ui.class", "shipment"); } diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java index 6862fc2b..6b7b597b 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (C) 2013 Stefan Schroeder - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . ******************************************************************************/ @@ -121,7 +121,7 @@ class Inserter { } private void setEndLocation(VehicleRoute route, Shipment shipment) { - route.getEnd().setLocationId(shipment.getDeliveryLocation()); + route.getEnd().setLocationId(shipment.getDeliveryLocationId()); } public void setNextHandler(JobInsertionHandler jobInsertionHandler){ diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceAndShipmentDistance.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceAndShipmentDistance.java index ee65215d..6d535b1b 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceAndShipmentDistance.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceAndShipmentDistance.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (C) 2013 Stefan Schroeder - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . ******************************************************************************/ @@ -74,16 +74,16 @@ public class AvgServiceAndShipmentDistance implements JobDistance { } private double calcDist(Service i, Shipment j) { - double c_ij1 = calcDist(i.getLocationId(),i.getCoord(),j.getPickupLocation(),j.getPickupCoord()); - double c_ij2 = calcDist(i.getLocationId(),i.getCoord(),j.getDeliveryLocation(),j.getDeliveryCoord()); + double c_ij1 = calcDist(i.getLocationId(),i.getCoord(),j.getPickupLocationId(),j.getPickupCoord()); + double c_ij2 = calcDist(i.getLocationId(),i.getCoord(),j.getDeliveryLocationId(),j.getDeliveryCoord()); return (c_ij1 + c_ij2)/2.0; } private double calcDist(Shipment i, Shipment j) { - double c_i1j1 = calcDist(i.getPickupLocation(),i.getPickupCoord(),j.getPickupLocation(),j.getPickupCoord()); - double c_i1j2 = calcDist(i.getPickupLocation(),i.getPickupCoord(),j.getDeliveryLocation(),j.getDeliveryCoord()); - double c_i2j1 = calcDist(i.getDeliveryLocation(),i.getDeliveryCoord(),j.getPickupLocation(),j.getPickupCoord()); - double c_i2j2 = calcDist(i.getDeliveryLocation(),i.getDeliveryCoord(),j.getDeliveryLocation(),j.getDeliveryCoord()); + double c_i1j1 = calcDist(i.getPickupLocationId(),i.getPickupCoord(),j.getPickupLocationId(),j.getPickupCoord()); + double c_i1j2 = calcDist(i.getPickupLocationId(),i.getPickupCoord(),j.getDeliveryLocationId(),j.getDeliveryCoord()); + double c_i2j1 = calcDist(i.getDeliveryLocationId(),i.getDeliveryCoord(),j.getPickupLocationId(),j.getPickupCoord()); + double c_i2j2 = calcDist(i.getDeliveryLocationId(),i.getDeliveryCoord(),j.getDeliveryLocationId(),j.getDeliveryCoord()); return (c_i1j1 + c_i1j2 + c_i2j1 + c_i2j2)/4.0; } diff --git a/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java b/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java index ee48759b..1c4f4fdc 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (C) 2013 Stefan Schroeder - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . ******************************************************************************/ @@ -265,8 +265,8 @@ public class VehicleRoutingProblem { } else if(job instanceof Shipment){ Shipment shipment = (Shipment)job; - tentative_coordinates.put(shipment.getPickupLocation(), shipment.getPickupCoord()); - tentative_coordinates.put(shipment.getDeliveryLocation(), shipment.getDeliveryCoord()); + tentative_coordinates.put(shipment.getPickupLocationId(), shipment.getPickupCoord()); + tentative_coordinates.put(shipment.getDeliveryLocationId(), shipment.getDeliveryCoord()); } } @@ -310,8 +310,8 @@ public class VehicleRoutingProblem { if (job instanceof Service) tentative_coordinates.put(((Service) job).getLocationId(), ((Service) job).getCoord()); if (job instanceof Shipment) { Shipment shipment = (Shipment) job; - tentative_coordinates.put(shipment.getPickupLocation(), shipment.getPickupCoord()); - tentative_coordinates.put(shipment.getDeliveryLocation(), shipment.getDeliveryCoord()); + tentative_coordinates.put(shipment.getPickupLocationId(), shipment.getPickupCoord()); + tentative_coordinates.put(shipment.getDeliveryLocationId(), shipment.getDeliveryCoord()); } } @@ -333,8 +333,8 @@ public class VehicleRoutingProblem { private void addShipment(Shipment job) { if(jobs.containsKey(job.getId())){ logger.warn("job " + job + " already in job list. overrides existing job."); } - tentative_coordinates.put(job.getPickupLocation(), job.getPickupCoord()); - tentative_coordinates.put(job.getDeliveryLocation(), job.getDeliveryCoord()); + tentative_coordinates.put(job.getPickupLocationId(), job.getPickupCoord()); + tentative_coordinates.put(job.getDeliveryLocationId(), job.getDeliveryCoord()); jobs.put(job.getId(),job); } diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverShipment.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverShipment.java index 4fed69b1..c0f0eefa 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverShipment.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverShipment.java @@ -1,20 +1,18 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.problem.solution.route.activity; @@ -60,7 +58,7 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA @Override public String getLocationId() { - return shipment.getDeliveryLocation(); + return shipment.getDeliveryLocationId(); } @Override diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupShipment.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupShipment.java index 21d67107..e7f33db4 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupShipment.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupShipment.java @@ -1,20 +1,18 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.problem.solution.route.activity; @@ -56,7 +54,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi @Override public String getLocationId() { - return shipment.getPickupLocation(); + return shipment.getPickupLocationId(); } @Override diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/InitialRoutesTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/InitialRoutesTest.java index d213d397..913d09da 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/InitialRoutesTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/InitialRoutesTest.java @@ -1,3 +1,20 @@ +/******************************************************************************* + * Copyright (C) 2014 Stefan Schroeder + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + ******************************************************************************/ + package jsprit.core.algorithm; @@ -252,10 +269,10 @@ public class InitialRoutesTest { VehicleType type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0, 100).build(); VehicleImpl vehicle = VehicleImpl.Builder.newInstance("veh").setStartLocationCoordinate(Coordinate.newInstance(0, 0)).setType(type).setStartLocationId("start").build(); - Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation("pick").setDeliveryLocation("del").setPickupCoord(Coordinate.newInstance(10, 0)) + Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocationId("pick").setDeliveryLocationId("del").setPickupCoord(Coordinate.newInstance(10, 0)) .setDeliveryCoord(Coordinate.newInstance(0, 10)).addSizeDimension(0, 100).build(); - Shipment another_shipment = Shipment.Builder.newInstance("another_s").setPickupLocation("pick").setDeliveryLocation("del").setPickupCoord(Coordinate.newInstance(10, 0)) + Shipment another_shipment = Shipment.Builder.newInstance("another_s").setPickupLocationId("pick").setDeliveryLocationId("del").setPickupCoord(Coordinate.newInstance(10, 0)) .setDeliveryCoord(Coordinate.newInstance(0, 10)).addSizeDimension(0, 50).build(); VehicleRoute iniRoute = VehicleRoute.Builder.newInstance(vehicle).addPickup(shipment).addDelivery(shipment).build(); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java index bd72b90b..4b74efe6 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java @@ -1,20 +1,18 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.algorithm.recreate; @@ -113,7 +111,7 @@ public class ShipmentInsertionCalculatorTest { @Test public void whenCalculatingInsertionCostsOfShipment_itShouldReturnCorrectCostValue(){ - Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("0,10").setDeliveryLocation("10,0").build(); + Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build(); VehicleRoute route = VehicleRoute.emptyRoute(); JobActivityFactory activityFactory = mock(JobActivityFactory.class); List activities = new ArrayList(); @@ -127,8 +125,8 @@ public class ShipmentInsertionCalculatorTest { @Test public void whenCalculatingInsertionIntoExistingRoute_itShouldReturnCorrectCosts(){ - Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("0,10").setDeliveryLocation("10,0").build(); - Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); + Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build(); VehicleRoute route = VehicleRoute.emptyRoute(); when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment)); new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route); @@ -157,8 +155,8 @@ public class ShipmentInsertionCalculatorTest { @Test public void whenInsertingShipmentInRouteWithNotEnoughCapacity_itShouldReturnNoInsertion(){ - Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("0,10").setDeliveryLocation("10,0").build(); - Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); + Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build(); VehicleRoute route = VehicleRoute.emptyRoute(); when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment)); new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route); @@ -186,9 +184,9 @@ public class ShipmentInsertionCalculatorTest { @Test public void whenInsertingThirdShipment_itShouldCalcCorrectVal(){ - Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("0,10").setDeliveryLocation("10,0").build(); - Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); - Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation("0,0").setDeliveryLocation("9,10").build(); + Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build(); + Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("9,10").build(); VehicleRoute route = VehicleRoute.emptyRoute(); when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment)); @@ -212,9 +210,9 @@ public class ShipmentInsertionCalculatorTest { @Test public void whenInsertingThirdShipment_itShouldCalcCorrectVal2(){ - Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("0,10").setDeliveryLocation("10,0").build(); - Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); - Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation("0,0").setDeliveryLocation("9,9").build(); + Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build(); + Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("9,9").build(); when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment)); when(vehicleRoutingProblem.copyAndGetActivities(shipment2)).thenReturn(getTourActivities(shipment2)); VehicleRoute route = VehicleRoute.emptyRoute(); @@ -238,9 +236,9 @@ public class ShipmentInsertionCalculatorTest { @Test public void whenInstertingShipmentWithLoadConstraintWhereCapIsNotSufficient_capConstraintsAreFulfilled(){ - Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("0,10").setDeliveryLocation("10,0").build(); - Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); - Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation("0,0").setDeliveryLocation("9,9").build(); + Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build(); + Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("9,9").build(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem vrp = vrpBuilder.addJob(shipment).addJob(shipment2).addJob(shipment3).build(); @@ -271,8 +269,8 @@ public class ShipmentInsertionCalculatorTest { @Test public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnNoInsertionData(){ - Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("0,10").setDeliveryLocation("0,0").build(); - Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); + Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("0,0").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem vrp = vrpBuilder.addJob(shipment).addJob(shipment2).build(); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java index 8f84a887..bbdbbcb8 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java @@ -1,20 +1,18 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.algorithm.recreate; @@ -125,7 +123,7 @@ public class TestInserter { 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").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build(); InsertionData iData = mock(InsertionData.class); when(iData.getPickupInsertionIndex()).thenReturn(2); @@ -138,8 +136,8 @@ public class TestInserter { inserter.insertJob(shipmentToInsert, iData, route); assertEquals(4,route.getTourActivities().getActivities().size()); - assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocation()); - assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocation()); + assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocationId()); + assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocationId()); assertEquals(route.getEnd().getLocationId(),vehicle.getEndLocationId()); } @@ -161,7 +159,7 @@ public class TestInserter { 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").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + 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); @@ -173,9 +171,9 @@ public class TestInserter { inserter.insertJob(shipmentToInsert, iData, route); assertEquals(4,route.getTourActivities().getActivities().size()); - assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocation()); - assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocation()); - assertEquals(route.getEnd().getLocationId(),shipmentToInsert.getDeliveryLocation()); + assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocationId()); + assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocationId()); + assertEquals(route.getEnd().getLocationId(),shipmentToInsert.getDeliveryLocationId()); } @Test @@ -188,7 +186,7 @@ public class TestInserter { 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").setPickupLocation("pickLoc").setDeliveryLocation("delLoc").build(); + Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build(); InsertionData iData = mock(InsertionData.class); when(iData.getPickupInsertionIndex()).thenReturn(2); @@ -213,7 +211,7 @@ public class TestInserter { 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").setPickupLocation("pickLoc").setDeliveryLocation("delLoc").build(); + Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build(); InsertionData iData = mock(InsertionData.class); when(iData.getPickupInsertionIndex()).thenReturn(2); @@ -233,13 +231,13 @@ public class TestInserter { Shipment shipment = mock(Shipment.class); Capacity capacity = Capacity.Builder.newInstance().build(); when(shipment.getSize()).thenReturn(capacity); - when(shipment.getDeliveryLocation()).thenReturn("oldShipmentDelLoc"); + 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").setPickupLocation("pickLoc").setDeliveryLocation("delLoc").build(); + Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build(); InsertionData iData = mock(InsertionData.class); when(iData.getPickupInsertionIndex()).thenReturn(0); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/ruin/distance/AverageJobDistanceTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/ruin/distance/AverageJobDistanceTest.java index 79047815..5fd0cbcd 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/ruin/distance/AverageJobDistanceTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/ruin/distance/AverageJobDistanceTest.java @@ -1,35 +1,32 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.algorithm.ruin.distance; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import jsprit.core.algorithm.ruin.distance.AvgServiceAndShipmentDistance; import jsprit.core.problem.job.Service; import jsprit.core.problem.job.Shipment; import jsprit.core.util.Coordinate; import jsprit.core.util.CrowFlyCosts; import jsprit.core.util.Locations; - import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class AverageJobDistanceTest { @@ -55,15 +52,15 @@ public class AverageJobDistanceTest { @Test public void distanceOfTwoEqualShipmentsShouldBeSmallerThanAnyOtherDistance(){ - Shipment s1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 1).setPickupLocation("0,0").setDeliveryLocation("10,10").build(); - Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("0,0").setDeliveryLocation("10,10").build(); + 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).setPickupLocation("0,0").setDeliveryLocation(i+","+j).build(); - Shipment other2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("0,0").setDeliveryLocation("10,10").build(); + 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); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/HardPickupAndDeliveryShipmentActivityConstraintTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/state/HardPickupAndDeliveryShipmentActivityConstraintTest.java index 771f0615..d3730540 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/HardPickupAndDeliveryShipmentActivityConstraintTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/state/HardPickupAndDeliveryShipmentActivityConstraintTest.java @@ -1,20 +1,18 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.algorithm.state; @@ -60,7 +58,7 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest { public void doBefore(){ s1 = Service.Builder.newInstance("s1").setLocationId("loc").build(); s2 = Service.Builder.newInstance("s2").setLocationId("loc").build(); - shipment = Shipment.Builder.newInstance("shipment").setPickupLocation("pickLoc").setDeliveryLocation("delLoc").addSizeDimension(0,1).build(); + shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").addSizeDimension(0,1).build(); // when(vehicle.getCapacity()).thenReturn(2); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/LoadStateTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/state/LoadStateTest.java index b2893994..61de41b9 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/LoadStateTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/state/LoadStateTest.java @@ -1,3 +1,20 @@ +/******************************************************************************* + * Copyright (C) 2014 Stefan Schroeder + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + ******************************************************************************/ + package jsprit.core.algorithm.state; import jsprit.core.problem.AbstractActivity; @@ -52,8 +69,8 @@ public class LoadStateTest { final VehicleRoutingProblem pdProblem = pdProblemBuilder.build(); final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance(); - Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).setPickupLocation("pick").setDeliveryLocation("del").build(); - Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocation("pick").setDeliveryLocation("del").build(); + Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).setPickupLocationId("pick").setDeliveryLocationId("del").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocationId("pick").setDeliveryLocationId("del").build(); shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build(); final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build(); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java b/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java index 386d989c..5ef0072b 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java @@ -111,8 +111,8 @@ public class VehicleRoutingProblemTest { @Test public void whenShipmentsAreAdded_vrpShouldContainThem(){ - Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foofoo").setDeliveryLocation("foo").build(); - Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 100).setPickupLocation("foofoo").setDeliveryLocation("foo").build(); + Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foofoo").setDeliveryLocationId("foo").build(); + Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 100).setPickupLocationId("foofoo").setDeliveryLocationId("foo").build(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); vrpBuilder.addJob(s); vrpBuilder.addJob(s2); @@ -534,7 +534,7 @@ public class VehicleRoutingProblemTest { @Test public void whenAddingTwoJobs_theyShouldHaveProperIndeces(){ Service service = Service.Builder.newInstance("myService").setLocationId("loc").build(); - Shipment shipment = Shipment.Builder.newInstance("shipment").setPickupLocation("pick").setDeliveryLocation("del").build(); + Shipment shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pick").setDeliveryLocationId("del").build(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); vrpBuilder.addJob(service); vrpBuilder.addJob(shipment); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/constraint/LoadConstraintTest.java b/jsprit-core/src/test/java/jsprit/core/problem/constraint/LoadConstraintTest.java index e5979e20..8cff796d 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/constraint/LoadConstraintTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/constraint/LoadConstraintTest.java @@ -1,3 +1,20 @@ +/******************************************************************************* + * Copyright (C) 2014 Stefan Schroeder + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + ******************************************************************************/ + package jsprit.core.problem.constraint; import jsprit.core.algorithm.state.StateManager; @@ -55,8 +72,8 @@ public class LoadConstraintTest { final VehicleRoutingProblem pdProblem = pdProblemBuilder.build(); final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance(); - Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).setPickupLocation("pick").setDeliveryLocation("del").build(); - Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocation("pick").setDeliveryLocation("del").build(); + Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).setPickupLocationId("pick").setDeliveryLocationId("del").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocationId("pick").setDeliveryLocationId("del").build(); shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build(); final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build(); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java index 362b8812..31d2db6e 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java @@ -1,20 +1,18 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.problem.solution.route; @@ -115,7 +113,7 @@ public class VehicleRouteBuilderTest { Capacity capacity = Capacity.Builder.newInstance().build(); when(s.getSize()).thenReturn(capacity); when(s2.getSize()).thenReturn(capacity); - when(s2.getDeliveryLocation()).thenReturn("delLoc"); + when(s2.getDeliveryLocationId()).thenReturn("delLoc"); Vehicle vehicle = mock(Vehicle.class); when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.getStartLocationId()).thenReturn("vehLoc"); @@ -125,7 +123,7 @@ public class VehicleRouteBuilderTest { builder.addDelivery(s); builder.addDelivery(s2); VehicleRoute route = builder.build(); - assertEquals(route.getEnd().getLocationId(), s2.getDeliveryLocation()); + assertEquals(route.getEnd().getLocationId(), s2.getDeliveryLocationId()); } @Test @@ -135,7 +133,7 @@ public class VehicleRouteBuilderTest { Capacity capacity = Capacity.Builder.newInstance().build(); when(s.getSize()).thenReturn(capacity); when(s2.getSize()).thenReturn(capacity); - when(s2.getDeliveryLocation()).thenReturn("delLoc"); + when(s2.getDeliveryLocationId()).thenReturn("delLoc"); Vehicle vehicle = mock(Vehicle.class); when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.getStartLocationId()).thenReturn("vehLoc"); @@ -158,7 +156,7 @@ public class VehicleRouteBuilderTest { Capacity capacity = Capacity.Builder.newInstance().build(); when(s.getSize()).thenReturn(capacity); when(s2.getSize()).thenReturn(capacity); - when(s2.getDeliveryLocation()).thenReturn("delLoc"); + when(s2.getDeliveryLocationId()).thenReturn("delLoc"); Vehicle vehicle = mock(Vehicle.class); when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.getStartLocationId()).thenReturn("vehLoc"); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DefaultShipmentActivityFactoryTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DefaultShipmentActivityFactoryTest.java index c03571dd..5e1a26db 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DefaultShipmentActivityFactoryTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DefaultShipmentActivityFactoryTest.java @@ -1,28 +1,26 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.problem.solution.route.activity; +import jsprit.core.problem.job.Shipment; +import org.junit.Test; + import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import jsprit.core.problem.job.Shipment; - -import org.junit.Test; public class DefaultShipmentActivityFactoryTest { @@ -30,7 +28,7 @@ public class DefaultShipmentActivityFactoryTest { public void whenCreatingPickupActivityWithShipment_itShouldReturnPickupShipment(){ DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory(); Shipment shipment = Shipment.Builder.newInstance("s") - .setPickupLocation("pLoc").setDeliveryLocation("dLoc").build(); + .setPickupLocationId("pLoc").setDeliveryLocationId("dLoc").build(); TourActivity act = factory.createPickup(shipment); assertNotNull(act); assertTrue(act instanceof PickupShipment); @@ -40,7 +38,7 @@ public class DefaultShipmentActivityFactoryTest { public void whenCreatingDeliverActivityWithShipment_itShouldReturnDeliverShipment(){ DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory(); Shipment shipment = Shipment.Builder.newInstance("s") - .setPickupLocation("pLoc").setDeliveryLocation("dLoc").build(); + .setPickupLocationId("pLoc").setDeliveryLocationId("dLoc").build(); TourActivity act = factory.createDelivery(shipment); assertNotNull(act); assertTrue(act instanceof DeliverShipment); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverShipmentTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverShipmentTest.java index d0721ed4..d0b58f81 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverShipmentTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverShipmentTest.java @@ -1,30 +1,28 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.problem.solution.route.activity; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import jsprit.core.problem.job.Shipment; - import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class DeliverShipmentTest { private Shipment shipment; @@ -33,8 +31,8 @@ public class DeliverShipmentTest { @Before public void doBefore(){ - shipment = Shipment.Builder.newInstance("shipment").setPickupLocation("pickupLoc") - .setDeliveryLocation("deliveryLoc") + shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pickupLoc") + .setDeliveryLocationId("deliveryLoc") .setPickupTimeWindow(TimeWindow.newInstance(1., 2.)) .setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.)) .addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build(); @@ -90,7 +88,7 @@ public class DeliverShipmentTest { @Test public void whenGettingCapacity_itShouldReturnItCorrectly(){ - Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").setDeliveryLocation("delLoc") + Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc") .addSizeDimension(0, 10).addSizeDimension(1, 100).build(); PickupShipment pick = new PickupShipment(shipment); assertEquals(10,pick.getSize().get(0)); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupShipmentTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupShipmentTest.java index 74df73f5..318b1eb0 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupShipmentTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupShipmentTest.java @@ -1,30 +1,28 @@ /******************************************************************************* - * Copyright (c) 2014 Stefan Schroeder. - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . - * - * Contributors: - * Stefan Schroeder - initial API and implementation ******************************************************************************/ package jsprit.core.problem.solution.route.activity; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import jsprit.core.problem.job.Shipment; - import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class PickupShipmentTest { private Shipment shipment; @@ -33,8 +31,8 @@ public class PickupShipmentTest { @Before public void doBefore(){ - shipment = Shipment.Builder.newInstance("shipment").setPickupLocation("pickupLoc") - .setDeliveryLocation("deliveryLoc") + shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pickupLoc") + .setDeliveryLocationId("deliveryLoc") .setPickupTimeWindow(TimeWindow.newInstance(1., 2.)) .setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.)) .addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build(); @@ -90,7 +88,7 @@ public class PickupShipmentTest { @Test public void whenGettingCapacity_itShouldReturnItCorrectly(){ - Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").setDeliveryLocation("delLoc") + Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc") .addSizeDimension(0, 10).addSizeDimension(1, 100).build(); PickupShipment pick = new PickupShipment(shipment); assertEquals(10,pick.getSize().get(0)); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestTour.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestTour.java index bd2d7c64..d3aa8a17 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestTour.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestTour.java @@ -1,35 +1,28 @@ /******************************************************************************* - * Copyright (C) 2013 Stefan Schroeder - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . ******************************************************************************/ package jsprit.core.problem.solution.route.activity; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import jsprit.core.problem.job.Service; import jsprit.core.problem.job.Shipment; -import jsprit.core.problem.solution.route.activity.DefaultShipmentActivityFactory; -import jsprit.core.problem.solution.route.activity.ServiceActivity; -import jsprit.core.problem.solution.route.activity.TourActivities; -import jsprit.core.problem.solution.route.activity.TourActivity; -import jsprit.core.problem.solution.route.activity.TourShipmentActivityFactory; - import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.*; + public class TestTour { @@ -82,7 +75,7 @@ public class TestTour { @Test public void whenAddingAShipmentActivity_tourShouldServeShipment(){ - Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build(); TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory(); TourActivity pickupShipment = fac.createPickup(s); TourActivity deliverShipment = fac.createDelivery(s); @@ -96,7 +89,7 @@ public class TestTour { @Test public void whenRemovingShipment_tourShouldNotServiceItAnymore(){ - Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build(); TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory(); TourActivity pickupShipment = fac.createPickup(s); TourActivity deliverShipment = fac.createDelivery(s); @@ -110,7 +103,7 @@ public class TestTour { @Test public void whenRemovingShipment_theirCorrespondingActivitiesShouldBeRemoved(){ - Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build(); TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory(); TourActivity pickupShipment = fac.createPickup(s); TourActivity deliverShipment = fac.createDelivery(s); diff --git a/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java b/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java index ca70fc32..2340897a 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java +++ b/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java @@ -340,8 +340,8 @@ public class BicycleMessenger { static double getTimeOfDirectRoute(Job job, Vehicle v, VehicleRoutingTransportCosts routingCosts) { Shipment envelope = (Shipment) job; - return routingCosts.getTransportTime(v.getStartLocationId(), envelope.getPickupLocation(), 0.0, DriverImpl.noDriver(), v) + - routingCosts.getTransportTime(envelope.getPickupLocation(), envelope.getDeliveryLocation(), 0.0, DriverImpl.noDriver(), v); + return routingCosts.getTransportTime(v.getStartLocationId(), envelope.getPickupLocationId(), 0.0, DriverImpl.noDriver(), v) + + routingCosts.getTransportTime(envelope.getPickupLocationId(), envelope.getDeliveryLocationId(), 0.0, DriverImpl.noDriver(), v); } private static void readEnvelopes(Builder problemBuilder) throws IOException { diff --git a/jsprit-examples/src/main/java/jsprit/examples/RefuseCollectionExample.java b/jsprit-examples/src/main/java/jsprit/examples/RefuseCollectionExample.java index a5d70d82..0794a330 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/RefuseCollectionExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/RefuseCollectionExample.java @@ -50,18 +50,7 @@ import java.util.Collection; public class RefuseCollectionExample { static class RelationKey { - -// static RelationKey newKey(String from, String to){ -// int fromInt = Integer.parseInt(from); -// int toInt = Integer.parseInt(to); -// if(fromInt < toInt){ -// return new RelationKey(from, to); -// } -// else { -// return new RelationKey(to, from); -// } -// } - + final String from; final String to; @@ -108,39 +97,6 @@ public class RefuseCollectionExample { return true; } } - -// static class RoutingCosts implements VehicleRoutingTransportCosts { -// -// private Map distances; -// -// public RoutingCosts(Map distances) { -// super(); -// this.distances = distances; -// } -// -// @Override -// public double getTransportTime(String fromId, String toId, double departureTime, Driver driver, Vehicle vehicle) { -// return getTransportCost(fromId, toId, departureTime, driver, vehicle); -// } -// -// @Override -// public double getBackwardTransportTime(String fromId, String toId, double arrivalTime, Driver driver, Vehicle vehicle) { -// return getTransportCost(fromId, toId, arrivalTime, driver, vehicle); -// } -// -// @Override -// public double getTransportCost(String fromId, String toId,double departureTime, Driver driver, Vehicle vehicle) { -// if(fromId.equals(toId)) return 0.0; -// RelationKey key = RelationKey.newKey(fromId, toId); -// return distances.get(key); -// } -// -// @Override -// public double getBackwardTransportCost(String fromId, String toId,double arrivalTime, Driver driver, Vehicle vehicle) { -// return getTransportCost(fromId, toId, arrivalTime, driver, vehicle); -// } -// -// } public static void main(String[] args) throws IOException { /* diff --git a/jsprit-examples/src/main/java/jsprit/examples/SolomonR101Example.java b/jsprit-examples/src/main/java/jsprit/examples/SolomonR101Example.java index 5cf7f7d1..3edd8fed 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/SolomonR101Example.java +++ b/jsprit-examples/src/main/java/jsprit/examples/SolomonR101Example.java @@ -16,77 +16,80 @@ ******************************************************************************/ package jsprit.examples; -import jsprit.analysis.toolbox.Plotter; +import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener; +import jsprit.analysis.toolbox.GraphStreamViewer; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.selector.SelectBest; import jsprit.core.problem.VehicleRoutingProblem; +import jsprit.core.problem.io.VrpXMLReader; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.reporting.SolutionPrinter; -import jsprit.instance.reader.SolomonReader; import jsprit.util.Examples; import java.util.Collection; public class SolomonR101Example { - + public static void main(String[] args) { /* * some preparation - create output folder */ Examples.createOutputFolder(); - + /* * Build the problem. - * + * * But define a problem-builder first. */ VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); - + /* * A solomonReader reads solomon-instance files, and stores the required information in the builder. */ - new SolomonReader(vrpBuilder).read("input/R101.txt"); - +// new SolomonReader(vrpBuilder).read("/Users/schroeder/IdeaProjects/jsprit/jsprit-instances/instances/solomon/R211.txt"); + new VrpXMLReader(vrpBuilder).read("output/R211.xml"); /* * Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances). */ VehicleRoutingProblem vrp = vrpBuilder.build(); - - new Plotter(vrp).plot("output/solomon_R101.png", "R101"); - + +// new VrpXMLWriter(vrp).write("output/R211.xml"); +// new Plotter(vrp).plot("output/solomon_R101.png", "R101"); + /* * Define the required vehicle-routing algorithms to solve the above problem. - * + * * The algorithm can be defined and configured in an xml-file. */ // VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml"); - vra.setMaxIterations(100); + vra.setMaxIterations(20000); // vra.setPrematureBreak(100); -// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png")); + vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png")); /* * Solve the problem. - * + * * */ Collection solutions = vra.searchSolutions(); - + /* * Retrieve best solution. */ VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions); - + /* * print solution */ - SolutionPrinter.print(solution); - + SolutionPrinter.print(vrp,solution, SolutionPrinter.Print.VERBOSE); + + new GraphStreamViewer(vrp,solution).display(); /* - * Plot solution. + * Plot solution. */ - new Plotter(vrp,solution).plot( "output/solomon_R101_solution.png","R101"); +// new Plotter(vrp,solution).plot( "output/solomon_R101_solution.png","R101"); }