1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

replace get/setDeliveryLocation(...) with get/setDeliveryLocationId(...)

replace get/setPickupLocation(...) with get/setPickupLocationId(...)
This commit is contained in:
oblonski 2014-09-04 14:02:43 +02:00
parent 9971d3d349
commit afe98c1051
22 changed files with 278 additions and 308 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,28 +8,14 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.analysis.toolbox; 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.VehicleRoutingProblem;
import jsprit.core.problem.job.Job; import jsprit.core.problem.job.Job;
import jsprit.core.problem.job.Service; 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.solution.route.activity.TourActivity.JobActivity;
import jsprit.core.problem.vehicle.PenaltyVehicleType; import jsprit.core.problem.vehicle.PenaltyVehicleType;
import jsprit.core.problem.vehicle.Vehicle; import jsprit.core.problem.vehicle.Vehicle;
import org.graphstream.graph.Edge; import org.graphstream.graph.Edge;
import org.graphstream.graph.Graph; import org.graphstream.graph.Graph;
import org.graphstream.graph.Node; 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.View;
import org.graphstream.ui.swingViewer.Viewer; import org.graphstream.ui.swingViewer.Viewer;
import javax.swing.*;
import java.awt.*;
public class GraphStreamViewer { public class GraphStreamViewer {
@ -359,21 +347,21 @@ public class GraphStreamViewer {
private void renderShipment(Graph g, Shipment shipment, Label label, boolean renderShipments) { 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()); if(label.equals(Label.ID)) n1.addAttribute("ui.label", shipment.getId());
n1.addAttribute("x", shipment.getPickupCoord().getX()); n1.addAttribute("x", shipment.getPickupCoord().getX());
n1.addAttribute("y", shipment.getPickupCoord().getY()); n1.addAttribute("y", shipment.getPickupCoord().getY());
n1.setAttribute("ui.class", "pickup"); 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()); if(label.equals(Label.ID)) n2.addAttribute("ui.label", shipment.getId());
n2.addAttribute("x", shipment.getDeliveryCoord().getX()); n2.addAttribute("x", shipment.getDeliveryCoord().getX());
n2.addAttribute("y", shipment.getDeliveryCoord().getY()); n2.addAttribute("y", shipment.getDeliveryCoord().getY());
n2.setAttribute("ui.class", "delivery"); n2.setAttribute("ui.class", "delivery");
if(renderShipments){ if(renderShipments){
Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(),shipment.getPickupLocation()), Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(),shipment.getPickupLocationId()),
makeId(shipment.getId(),shipment.getDeliveryLocation()), true); makeId(shipment.getId(),shipment.getDeliveryLocationId()), true);
s.addAttribute("ui.class", "shipment"); s.addAttribute("ui.class", "shipment");
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -121,7 +121,7 @@ class Inserter {
} }
private void setEndLocation(VehicleRoute route, Shipment shipment) { private void setEndLocation(VehicleRoute route, Shipment shipment) {
route.getEnd().setLocationId(shipment.getDeliveryLocation()); route.getEnd().setLocationId(shipment.getDeliveryLocationId());
} }
public void setNextHandler(JobInsertionHandler jobInsertionHandler){ public void setNextHandler(JobInsertionHandler jobInsertionHandler){

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -74,16 +74,16 @@ public class AvgServiceAndShipmentDistance implements JobDistance {
} }
private double calcDist(Service i, Shipment j) { private double calcDist(Service i, Shipment j) {
double c_ij1 = calcDist(i.getLocationId(),i.getCoord(),j.getPickupLocation(),j.getPickupCoord()); double c_ij1 = calcDist(i.getLocationId(),i.getCoord(),j.getPickupLocationId(),j.getPickupCoord());
double c_ij2 = calcDist(i.getLocationId(),i.getCoord(),j.getDeliveryLocation(),j.getDeliveryCoord()); double c_ij2 = calcDist(i.getLocationId(),i.getCoord(),j.getDeliveryLocationId(),j.getDeliveryCoord());
return (c_ij1 + c_ij2)/2.0; return (c_ij1 + c_ij2)/2.0;
} }
private double calcDist(Shipment i, Shipment j) { private double calcDist(Shipment i, Shipment j) {
double c_i1j1 = calcDist(i.getPickupLocation(),i.getPickupCoord(),j.getPickupLocation(),j.getPickupCoord()); double c_i1j1 = calcDist(i.getPickupLocationId(),i.getPickupCoord(),j.getPickupLocationId(),j.getPickupCoord());
double c_i1j2 = calcDist(i.getPickupLocation(),i.getPickupCoord(),j.getDeliveryLocation(),j.getDeliveryCoord()); double c_i1j2 = calcDist(i.getPickupLocationId(),i.getPickupCoord(),j.getDeliveryLocationId(),j.getDeliveryCoord());
double c_i2j1 = calcDist(i.getDeliveryLocation(),i.getDeliveryCoord(),j.getPickupLocation(),j.getPickupCoord()); double c_i2j1 = calcDist(i.getDeliveryLocationId(),i.getDeliveryCoord(),j.getPickupLocationId(),j.getPickupCoord());
double c_i2j2 = calcDist(i.getDeliveryLocation(),i.getDeliveryCoord(),j.getDeliveryLocation(),j.getDeliveryCoord()); double c_i2j2 = calcDist(i.getDeliveryLocationId(),i.getDeliveryCoord(),j.getDeliveryLocationId(),j.getDeliveryCoord());
return (c_i1j1 + c_i1j2 + c_i2j1 + c_i2j2)/4.0; return (c_i1j1 + c_i1j2 + c_i2j1 + c_i2j2)/4.0;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -265,8 +265,8 @@ public class VehicleRoutingProblem {
} }
else if(job instanceof Shipment){ else if(job instanceof Shipment){
Shipment shipment = (Shipment)job; Shipment shipment = (Shipment)job;
tentative_coordinates.put(shipment.getPickupLocation(), shipment.getPickupCoord()); tentative_coordinates.put(shipment.getPickupLocationId(), shipment.getPickupCoord());
tentative_coordinates.put(shipment.getDeliveryLocation(), shipment.getDeliveryCoord()); 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 Service) tentative_coordinates.put(((Service) job).getLocationId(), ((Service) job).getCoord());
if (job instanceof Shipment) { if (job instanceof Shipment) {
Shipment shipment = (Shipment) job; Shipment shipment = (Shipment) job;
tentative_coordinates.put(shipment.getPickupLocation(), shipment.getPickupCoord()); tentative_coordinates.put(shipment.getPickupLocationId(), shipment.getPickupCoord());
tentative_coordinates.put(shipment.getDeliveryLocation(), shipment.getDeliveryCoord()); tentative_coordinates.put(shipment.getDeliveryLocationId(), shipment.getDeliveryCoord());
} }
} }
@ -333,8 +333,8 @@ public class VehicleRoutingProblem {
private void addShipment(Shipment job) { private void addShipment(Shipment job) {
if(jobs.containsKey(job.getId())){ logger.warn("job " + job + " already in job list. overrides existing 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.getPickupLocationId(), job.getPickupCoord());
tentative_coordinates.put(job.getDeliveryLocation(), job.getDeliveryCoord()); tentative_coordinates.put(job.getDeliveryLocationId(), job.getDeliveryCoord());
jobs.put(job.getId(),job); jobs.put(job.getId(),job);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,13 +8,11 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.problem.solution.route.activity; package jsprit.core.problem.solution.route.activity;
@ -60,7 +58,7 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA
@Override @Override
public String getLocationId() { public String getLocationId() {
return shipment.getDeliveryLocation(); return shipment.getDeliveryLocationId();
} }
@Override @Override

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,13 +8,11 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.problem.solution.route.activity; package jsprit.core.problem.solution.route.activity;
@ -56,7 +54,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi
@Override @Override
public String getLocationId() { public String getLocationId() {
return shipment.getPickupLocation(); return shipment.getPickupLocationId();
} }
@Override @Override

View file

@ -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 <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.core.algorithm; package jsprit.core.algorithm;
@ -252,10 +269,10 @@ public class InitialRoutesTest {
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0, 100).build(); 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(); 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(); .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(); .setDeliveryCoord(Coordinate.newInstance(0, 10)).addSizeDimension(0, 50).build();
VehicleRoute iniRoute = VehicleRoute.Builder.newInstance(vehicle).addPickup(shipment).addDelivery(shipment).build(); VehicleRoute iniRoute = VehicleRoute.Builder.newInstance(vehicle).addPickup(shipment).addDelivery(shipment).build();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,13 +8,11 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.algorithm.recreate; package jsprit.core.algorithm.recreate;
@ -113,7 +111,7 @@ public class ShipmentInsertionCalculatorTest {
@Test @Test
public void whenCalculatingInsertionCostsOfShipment_itShouldReturnCorrectCostValue(){ 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(); VehicleRoute route = VehicleRoute.emptyRoute();
JobActivityFactory activityFactory = mock(JobActivityFactory.class); JobActivityFactory activityFactory = mock(JobActivityFactory.class);
List<AbstractActivity> activities = new ArrayList<AbstractActivity>(); List<AbstractActivity> activities = new ArrayList<AbstractActivity>();
@ -127,8 +125,8 @@ public class ShipmentInsertionCalculatorTest {
@Test @Test
public void whenCalculatingInsertionIntoExistingRoute_itShouldReturnCorrectCosts(){ public void whenCalculatingInsertionIntoExistingRoute_itShouldReturnCorrectCosts(){
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();
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build();
VehicleRoute route = VehicleRoute.emptyRoute(); VehicleRoute route = VehicleRoute.emptyRoute();
when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment)); when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment));
new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route); new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route);
@ -157,8 +155,8 @@ public class ShipmentInsertionCalculatorTest {
@Test @Test
public void whenInsertingShipmentInRouteWithNotEnoughCapacity_itShouldReturnNoInsertion(){ public void whenInsertingShipmentInRouteWithNotEnoughCapacity_itShouldReturnNoInsertion(){
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();
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build();
VehicleRoute route = VehicleRoute.emptyRoute(); VehicleRoute route = VehicleRoute.emptyRoute();
when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment)); when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment));
new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route); new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route);
@ -186,9 +184,9 @@ public class ShipmentInsertionCalculatorTest {
@Test @Test
public void whenInsertingThirdShipment_itShouldCalcCorrectVal(){ public void whenInsertingThirdShipment_itShouldCalcCorrectVal(){
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();
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,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).setPickupLocation("0,0").setDeliveryLocation("9,10").build(); Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("9,10").build();
VehicleRoute route = VehicleRoute.emptyRoute(); VehicleRoute route = VehicleRoute.emptyRoute();
when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment)); when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment));
@ -212,9 +210,9 @@ public class ShipmentInsertionCalculatorTest {
@Test @Test
public void whenInsertingThirdShipment_itShouldCalcCorrectVal2(){ public void whenInsertingThirdShipment_itShouldCalcCorrectVal2(){
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();
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,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).setPickupLocation("0,0").setDeliveryLocation("9,9").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(shipment)).thenReturn(getTourActivities(shipment));
when(vehicleRoutingProblem.copyAndGetActivities(shipment2)).thenReturn(getTourActivities(shipment2)); when(vehicleRoutingProblem.copyAndGetActivities(shipment2)).thenReturn(getTourActivities(shipment2));
VehicleRoute route = VehicleRoute.emptyRoute(); VehicleRoute route = VehicleRoute.emptyRoute();
@ -238,9 +236,9 @@ public class ShipmentInsertionCalculatorTest {
@Test @Test
public void whenInstertingShipmentWithLoadConstraintWhereCapIsNotSufficient_capConstraintsAreFulfilled(){ public void whenInstertingShipmentWithLoadConstraintWhereCapIsNotSufficient_capConstraintsAreFulfilled(){
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();
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation("10,10").setDeliveryLocation("0,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).setPickupLocation("0,0").setDeliveryLocation("9,9").build(); Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("9,9").build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
VehicleRoutingProblem vrp = vrpBuilder.addJob(shipment).addJob(shipment2).addJob(shipment3).build(); VehicleRoutingProblem vrp = vrpBuilder.addJob(shipment).addJob(shipment2).addJob(shipment3).build();
@ -271,8 +269,8 @@ public class ShipmentInsertionCalculatorTest {
@Test @Test
public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnNoInsertionData(){ public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnNoInsertionData(){
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("0,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).setPickupLocation("10,10").setDeliveryLocation("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.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
VehicleRoutingProblem vrp = vrpBuilder.addJob(shipment).addJob(shipment2).build(); VehicleRoutingProblem vrp = vrpBuilder.addJob(shipment).addJob(shipment2).build();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,13 +8,11 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.algorithm.recreate; 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(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end //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); InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(2); when(iData.getPickupInsertionIndex()).thenReturn(2);
@ -138,8 +136,8 @@ public class TestInserter {
inserter.insertJob(shipmentToInsert, iData, route); inserter.insertJob(shipmentToInsert, iData, route);
assertEquals(4,route.getTourActivities().getActivities().size()); assertEquals(4,route.getTourActivities().getActivities().size());
assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocation()); assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocationId());
assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocation()); assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocationId());
assertEquals(route.getEnd().getLocationId(),vehicle.getEndLocationId()); 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(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end //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); InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(2); when(iData.getPickupInsertionIndex()).thenReturn(2);
when(iData.getDeliveryInsertionIndex()).thenReturn(2); when(iData.getDeliveryInsertionIndex()).thenReturn(2);
@ -173,9 +171,9 @@ public class TestInserter {
inserter.insertJob(shipmentToInsert, iData, route); inserter.insertJob(shipmentToInsert, iData, route);
assertEquals(4,route.getTourActivities().getActivities().size()); assertEquals(4,route.getTourActivities().getActivities().size());
assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocation()); assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocationId());
assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocation()); assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocationId());
assertEquals(route.getEnd().getLocationId(),shipmentToInsert.getDeliveryLocation()); assertEquals(route.getEnd().getLocationId(),shipmentToInsert.getDeliveryLocationId());
} }
@Test @Test
@ -188,7 +186,7 @@ public class TestInserter {
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end //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); InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(2); 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(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end //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); InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(2); when(iData.getPickupInsertionIndex()).thenReturn(2);
@ -233,13 +231,13 @@ public class TestInserter {
Shipment shipment = mock(Shipment.class); Shipment shipment = mock(Shipment.class);
Capacity capacity = Capacity.Builder.newInstance().build(); Capacity capacity = Capacity.Builder.newInstance().build();
when(shipment.getSize()).thenReturn(capacity); 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 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(); 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(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end //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); InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(0); when(iData.getPickupInsertionIndex()).thenReturn(0);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,28 +8,25 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.algorithm.ruin.distance; 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.Service;
import jsprit.core.problem.job.Shipment; import jsprit.core.problem.job.Shipment;
import jsprit.core.util.Coordinate; import jsprit.core.util.Coordinate;
import jsprit.core.util.CrowFlyCosts; import jsprit.core.util.CrowFlyCosts;
import jsprit.core.util.Locations; import jsprit.core.util.Locations;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class AverageJobDistanceTest { public class AverageJobDistanceTest {
@ -55,15 +52,15 @@ public class AverageJobDistanceTest {
@Test @Test
public void distanceOfTwoEqualShipmentsShouldBeSmallerThanAnyOtherDistance(){ public void distanceOfTwoEqualShipmentsShouldBeSmallerThanAnyOtherDistance(){
Shipment s1 = Shipment.Builder.newInstance("s1").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).setPickupLocation("0,0").setDeliveryLocation("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); double dist = new AvgServiceAndShipmentDistance(routingCosts).getDistance(s1, s2);
for(int i=0;i<10;i++){ for(int i=0;i<10;i++){
for(int j=0;j<10;j++){ for(int j=0;j<10;j++){
Shipment other1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 1).setPickupLocation("0,0").setDeliveryLocation(i+","+j).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).setPickupLocation("0,0").setDeliveryLocation("10,10").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); double dist2 = new AvgServiceAndShipmentDistance(routingCosts).getDistance(other1, other2);
System.out.println("("+i+","+j+"), dist=" + dist + ", dist2=" + dist2); System.out.println("("+i+","+j+"), dist=" + dist + ", dist2=" + dist2);
assertTrue(dist<=dist2+dist2*0.001); assertTrue(dist<=dist2+dist2*0.001);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,13 +8,11 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.algorithm.state; package jsprit.core.algorithm.state;
@ -60,7 +58,7 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest {
public void doBefore(){ public void doBefore(){
s1 = Service.Builder.newInstance("s1").setLocationId("loc").build(); s1 = Service.Builder.newInstance("s1").setLocationId("loc").build();
s2 = Service.Builder.newInstance("s2").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); // when(vehicle.getCapacity()).thenReturn(2);

View file

@ -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 <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.core.algorithm.state; package jsprit.core.algorithm.state;
import jsprit.core.problem.AbstractActivity; import jsprit.core.problem.AbstractActivity;
@ -52,8 +69,8 @@ public class LoadStateTest {
final VehicleRoutingProblem pdProblem = pdProblemBuilder.build(); final VehicleRoutingProblem pdProblem = pdProblemBuilder.build();
final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance(); final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance();
Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).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).setPickupLocation("pick").setDeliveryLocation("del").build(); Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocationId("pick").setDeliveryLocationId("del").build();
shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build(); shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build();
final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build(); final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build();

View file

@ -111,8 +111,8 @@ public class VehicleRoutingProblemTest {
@Test @Test
public void whenShipmentsAreAdded_vrpShouldContainThem(){ public void whenShipmentsAreAdded_vrpShouldContainThem(){
Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).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).setPickupLocation("foofoo").setDeliveryLocation("foo").build(); Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 100).setPickupLocationId("foofoo").setDeliveryLocationId("foo").build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addJob(s); vrpBuilder.addJob(s);
vrpBuilder.addJob(s2); vrpBuilder.addJob(s2);
@ -534,7 +534,7 @@ public class VehicleRoutingProblemTest {
@Test @Test
public void whenAddingTwoJobs_theyShouldHaveProperIndeces(){ public void whenAddingTwoJobs_theyShouldHaveProperIndeces(){
Service service = Service.Builder.newInstance("myService").setLocationId("loc").build(); 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(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addJob(service); vrpBuilder.addJob(service);
vrpBuilder.addJob(shipment); vrpBuilder.addJob(shipment);

View file

@ -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 <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.core.problem.constraint; package jsprit.core.problem.constraint;
import jsprit.core.algorithm.state.StateManager; import jsprit.core.algorithm.state.StateManager;
@ -55,8 +72,8 @@ public class LoadConstraintTest {
final VehicleRoutingProblem pdProblem = pdProblemBuilder.build(); final VehicleRoutingProblem pdProblem = pdProblemBuilder.build();
final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance(); final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance();
Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).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).setPickupLocation("pick").setDeliveryLocation("del").build(); Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocationId("pick").setDeliveryLocationId("del").build();
shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build(); shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build();
final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build(); final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,13 +8,11 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.problem.solution.route; package jsprit.core.problem.solution.route;
@ -115,7 +113,7 @@ public class VehicleRouteBuilderTest {
Capacity capacity = Capacity.Builder.newInstance().build(); Capacity capacity = Capacity.Builder.newInstance().build();
when(s.getSize()).thenReturn(capacity); when(s.getSize()).thenReturn(capacity);
when(s2.getSize()).thenReturn(capacity); when(s2.getSize()).thenReturn(capacity);
when(s2.getDeliveryLocation()).thenReturn("delLoc"); when(s2.getDeliveryLocationId()).thenReturn("delLoc");
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.isReturnToDepot()).thenReturn(false);
when(vehicle.getStartLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
@ -125,7 +123,7 @@ public class VehicleRouteBuilderTest {
builder.addDelivery(s); builder.addDelivery(s);
builder.addDelivery(s2); builder.addDelivery(s2);
VehicleRoute route = builder.build(); VehicleRoute route = builder.build();
assertEquals(route.getEnd().getLocationId(), s2.getDeliveryLocation()); assertEquals(route.getEnd().getLocationId(), s2.getDeliveryLocationId());
} }
@Test @Test
@ -135,7 +133,7 @@ public class VehicleRouteBuilderTest {
Capacity capacity = Capacity.Builder.newInstance().build(); Capacity capacity = Capacity.Builder.newInstance().build();
when(s.getSize()).thenReturn(capacity); when(s.getSize()).thenReturn(capacity);
when(s2.getSize()).thenReturn(capacity); when(s2.getSize()).thenReturn(capacity);
when(s2.getDeliveryLocation()).thenReturn("delLoc"); when(s2.getDeliveryLocationId()).thenReturn("delLoc");
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.isReturnToDepot()).thenReturn(false);
when(vehicle.getStartLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
@ -158,7 +156,7 @@ public class VehicleRouteBuilderTest {
Capacity capacity = Capacity.Builder.newInstance().build(); Capacity capacity = Capacity.Builder.newInstance().build();
when(s.getSize()).thenReturn(capacity); when(s.getSize()).thenReturn(capacity);
when(s2.getSize()).thenReturn(capacity); when(s2.getSize()).thenReturn(capacity);
when(s2.getDeliveryLocation()).thenReturn("delLoc"); when(s2.getDeliveryLocationId()).thenReturn("delLoc");
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.isReturnToDepot()).thenReturn(false);
when(vehicle.getStartLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,21 +8,19 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.problem.solution.route.activity; 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.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import jsprit.core.problem.job.Shipment;
import org.junit.Test;
public class DefaultShipmentActivityFactoryTest { public class DefaultShipmentActivityFactoryTest {
@ -30,7 +28,7 @@ public class DefaultShipmentActivityFactoryTest {
public void whenCreatingPickupActivityWithShipment_itShouldReturnPickupShipment(){ public void whenCreatingPickupActivityWithShipment_itShouldReturnPickupShipment(){
DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory(); DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory();
Shipment shipment = Shipment.Builder.newInstance("s") Shipment shipment = Shipment.Builder.newInstance("s")
.setPickupLocation("pLoc").setDeliveryLocation("dLoc").build(); .setPickupLocationId("pLoc").setDeliveryLocationId("dLoc").build();
TourActivity act = factory.createPickup(shipment); TourActivity act = factory.createPickup(shipment);
assertNotNull(act); assertNotNull(act);
assertTrue(act instanceof PickupShipment); assertTrue(act instanceof PickupShipment);
@ -40,7 +38,7 @@ public class DefaultShipmentActivityFactoryTest {
public void whenCreatingDeliverActivityWithShipment_itShouldReturnDeliverShipment(){ public void whenCreatingDeliverActivityWithShipment_itShouldReturnDeliverShipment(){
DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory(); DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory();
Shipment shipment = Shipment.Builder.newInstance("s") Shipment shipment = Shipment.Builder.newInstance("s")
.setPickupLocation("pLoc").setDeliveryLocation("dLoc").build(); .setPickupLocationId("pLoc").setDeliveryLocationId("dLoc").build();
TourActivity act = factory.createDelivery(shipment); TourActivity act = factory.createDelivery(shipment);
assertNotNull(act); assertNotNull(act);
assertTrue(act instanceof DeliverShipment); assertTrue(act instanceof DeliverShipment);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,23 +8,21 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.problem.solution.route.activity; 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 jsprit.core.problem.job.Shipment;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class DeliverShipmentTest { public class DeliverShipmentTest {
private Shipment shipment; private Shipment shipment;
@ -33,8 +31,8 @@ public class DeliverShipmentTest {
@Before @Before
public void doBefore(){ public void doBefore(){
shipment = Shipment.Builder.newInstance("shipment").setPickupLocation("pickupLoc") shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pickupLoc")
.setDeliveryLocation("deliveryLoc") .setDeliveryLocationId("deliveryLoc")
.setPickupTimeWindow(TimeWindow.newInstance(1., 2.)) .setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
.setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.)) .setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
.addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build(); .addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
@ -90,7 +88,7 @@ public class DeliverShipmentTest {
@Test @Test
public void whenGettingCapacity_itShouldReturnItCorrectly(){ 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(); .addSizeDimension(0, 10).addSizeDimension(1, 100).build();
PickupShipment pick = new PickupShipment(shipment); PickupShipment pick = new PickupShipment(shipment);
assertEquals(10,pick.getSize().get(0)); assertEquals(10,pick.getSize().get(0));

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 Stefan Schroeder. * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -8,23 +8,21 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/ ******************************************************************************/
package jsprit.core.problem.solution.route.activity; 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 jsprit.core.problem.job.Shipment;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class PickupShipmentTest { public class PickupShipmentTest {
private Shipment shipment; private Shipment shipment;
@ -33,8 +31,8 @@ public class PickupShipmentTest {
@Before @Before
public void doBefore(){ public void doBefore(){
shipment = Shipment.Builder.newInstance("shipment").setPickupLocation("pickupLoc") shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pickupLoc")
.setDeliveryLocation("deliveryLoc") .setDeliveryLocationId("deliveryLoc")
.setPickupTimeWindow(TimeWindow.newInstance(1., 2.)) .setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
.setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.)) .setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
.addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build(); .addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
@ -90,7 +88,7 @@ public class PickupShipmentTest {
@Test @Test
public void whenGettingCapacity_itShouldReturnItCorrectly(){ 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(); .addSizeDimension(0, 10).addSizeDimension(1, 100).build();
PickupShipment pick = new PickupShipment(shipment); PickupShipment pick = new PickupShipment(shipment);
assertEquals(10,pick.getSize().get(0)); assertEquals(10,pick.getSize().get(0));

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder * Copyright (C) 2014 Stefan Schroeder
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -16,20 +16,13 @@
******************************************************************************/ ******************************************************************************/
package jsprit.core.problem.solution.route.activity; 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.Service;
import jsprit.core.problem.job.Shipment; 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.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*;
public class TestTour { public class TestTour {
@ -82,7 +75,7 @@ public class TestTour {
@Test @Test
public void whenAddingAShipmentActivity_tourShouldServeShipment(){ 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(); TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s); TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s); TourActivity deliverShipment = fac.createDelivery(s);
@ -96,7 +89,7 @@ public class TestTour {
@Test @Test
public void whenRemovingShipment_tourShouldNotServiceItAnymore(){ 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(); TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s); TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s); TourActivity deliverShipment = fac.createDelivery(s);
@ -110,7 +103,7 @@ public class TestTour {
@Test @Test
public void whenRemovingShipment_theirCorrespondingActivitiesShouldBeRemoved(){ 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(); TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s); TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s); TourActivity deliverShipment = fac.createDelivery(s);

View file

@ -340,8 +340,8 @@ public class BicycleMessenger {
static double getTimeOfDirectRoute(Job job, Vehicle v, VehicleRoutingTransportCosts routingCosts) { static double getTimeOfDirectRoute(Job job, Vehicle v, VehicleRoutingTransportCosts routingCosts) {
Shipment envelope = (Shipment) job; Shipment envelope = (Shipment) job;
return routingCosts.getTransportTime(v.getStartLocationId(), envelope.getPickupLocation(), 0.0, DriverImpl.noDriver(), v) + return routingCosts.getTransportTime(v.getStartLocationId(), envelope.getPickupLocationId(), 0.0, DriverImpl.noDriver(), v) +
routingCosts.getTransportTime(envelope.getPickupLocation(), envelope.getDeliveryLocation(), 0.0, DriverImpl.noDriver(), v); routingCosts.getTransportTime(envelope.getPickupLocationId(), envelope.getDeliveryLocationId(), 0.0, DriverImpl.noDriver(), v);
} }
private static void readEnvelopes(Builder problemBuilder) throws IOException { private static void readEnvelopes(Builder problemBuilder) throws IOException {

View file

@ -51,17 +51,6 @@ public class RefuseCollectionExample {
static class RelationKey { 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 from;
final String to; final String to;
@ -109,39 +98,6 @@ public class RefuseCollectionExample {
} }
} }
// static class RoutingCosts implements VehicleRoutingTransportCosts {
//
// private Map<RelationKey,Integer> distances;
//
// public RoutingCosts(Map<RelationKey, Integer> 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 { public static void main(String[] args) throws IOException {
/* /*
* some preparation - create output folder * some preparation - create output folder

View file

@ -16,14 +16,15 @@
******************************************************************************/ ******************************************************************************/
package jsprit.examples; 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.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.algorithm.selector.SelectBest; import jsprit.core.algorithm.selector.SelectBest;
import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.io.VrpXMLReader;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.reporting.SolutionPrinter; import jsprit.core.reporting.SolutionPrinter;
import jsprit.instance.reader.SolomonReader;
import jsprit.util.Examples; import jsprit.util.Examples;
import java.util.Collection; import java.util.Collection;
@ -47,14 +48,15 @@ public class SolomonR101Example {
/* /*
* A solomonReader reads solomon-instance files, and stores the required information in the builder. * 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). * Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/ */
VehicleRoutingProblem vrp = vrpBuilder.build(); 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. * Define the required vehicle-routing algorithms to solve the above problem.
@ -63,9 +65,9 @@ public class SolomonR101Example {
*/ */
// VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); // VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml"); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
vra.setMaxIterations(100); vra.setMaxIterations(20000);
// vra.setPrematureBreak(100); // vra.setPrematureBreak(100);
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png")); vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
/* /*
* Solve the problem. * Solve the problem.
* *
@ -81,12 +83,13 @@ public class SolomonR101Example {
/* /*
* print solution * 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");
} }