mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
replace deprecated methods
This commit is contained in:
parent
db0cdbe310
commit
62e12d5153
23 changed files with 291 additions and 327 deletions
|
|
@ -65,7 +65,6 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
|
||||||
|
|
||||||
public static final int CLEAR_SOLUTION = 3;
|
public static final int CLEAR_SOLUTION = 3;
|
||||||
|
|
||||||
public static final int RENDER_FINAL_SOLUTION = 4;
|
|
||||||
|
|
||||||
private Graph graph;
|
private Graph graph;
|
||||||
|
|
||||||
|
|
@ -104,6 +103,7 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
|
||||||
initialiseGraph(vrp);
|
initialiseGraph(vrp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public AlgorithmEventsRecorder(VehicleRoutingProblem vrp, String dgsFileLocation, boolean renderShipments) {
|
public AlgorithmEventsRecorder(VehicleRoutingProblem vrp, String dgsFileLocation, boolean renderShipments) {
|
||||||
this.renderShipments = renderShipments;
|
this.renderShipments = renderShipments;
|
||||||
new AlgorithmEventsRecorder(vrp, dgsFileLocation);
|
new AlgorithmEventsRecorder(vrp, dgsFileLocation);
|
||||||
|
|
@ -352,15 +352,15 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
|
||||||
private void addVehicle(Vehicle vehicle) {
|
private void addVehicle(Vehicle vehicle) {
|
||||||
String startId = makeStartId(vehicle);
|
String startId = makeStartId(vehicle);
|
||||||
Node node = graph.addNode(startId);
|
Node node = graph.addNode(startId);
|
||||||
node.addAttribute("x",vehicle.getStartLocationCoordinate().getX());
|
node.addAttribute("x",vehicle.getStartLocation().getCoordinate().getX());
|
||||||
node.addAttribute("y",vehicle.getStartLocationCoordinate().getY());
|
node.addAttribute("y", vehicle.getStartLocation().getCoordinate().getY());
|
||||||
node.addAttribute("ui.class","depot");
|
node.addAttribute("ui.class","depot");
|
||||||
|
|
||||||
String endId = makeEndId(vehicle);
|
String endId = makeEndId(vehicle);
|
||||||
if(!startId.equals(endId)){
|
if(!startId.equals(endId)){
|
||||||
Node endNode = graph.addNode(endId);
|
Node endNode = graph.addNode(endId);
|
||||||
endNode.addAttribute("x",vehicle.getEndLocationCoordinate().getX());
|
endNode.addAttribute("x", vehicle.getEndLocation().getCoordinate().getX());
|
||||||
endNode.addAttribute("y",vehicle.getEndLocationCoordinate().getY());
|
endNode.addAttribute("y", vehicle.getEndLocation().getCoordinate().getY());
|
||||||
endNode.addAttribute("ui.class","depot");
|
endNode.addAttribute("ui.class","depot");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -370,7 +370,7 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeEndId(Vehicle vehicle) {
|
private String makeEndId(Vehicle vehicle) {
|
||||||
if(vehicle.getStartLocationId().equals(vehicle.getEndLocationId())) return makeStartId(vehicle);
|
if(vehicle.getStartLocation().getId().equals(vehicle.getEndLocation().getId())) return makeStartId(vehicle);
|
||||||
return vehicle.getId() + "_end";
|
return vehicle.getId() + "_end";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -436,15 +436,14 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
|
||||||
|
|
||||||
String node_i;
|
String node_i;
|
||||||
|
|
||||||
if(isFirst(insertionIndex,route)) {
|
if(isFirst(insertionIndex)) {
|
||||||
node_i = makeStartId(data.getSelectedVehicle());
|
node_i = makeStartId(data.getSelectedVehicle());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TourActivity.JobActivity jobActivity = (TourActivity.JobActivity) route.getActivities().get(insertionIndex - 1);
|
TourActivity.JobActivity jobActivity = (TourActivity.JobActivity) route.getActivities().get(insertionIndex - 1);
|
||||||
node_i = getNodeId(jobActivity);
|
node_i = getNodeId(jobActivity);
|
||||||
}
|
}
|
||||||
String node_k = nodeId;
|
String edgeId_1 = node_i + "_" + nodeId;
|
||||||
String edgeId_1 = node_i + "_" + node_k;
|
|
||||||
String node_j;
|
String node_j;
|
||||||
if(isLast(insertionIndex,route)) {
|
if(isLast(insertionIndex,route)) {
|
||||||
node_j = makeEndId(data.getSelectedVehicle());
|
node_j = makeEndId(data.getSelectedVehicle());
|
||||||
|
|
@ -453,12 +452,12 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
|
||||||
TourActivity.JobActivity jobActivity = (TourActivity.JobActivity) route.getActivities().get(insertionIndex);
|
TourActivity.JobActivity jobActivity = (TourActivity.JobActivity) route.getActivities().get(insertionIndex);
|
||||||
node_j = getNodeId(jobActivity);
|
node_j = getNodeId(jobActivity);
|
||||||
}
|
}
|
||||||
String edgeId_2 = node_k + "_" + node_j;
|
String edgeId_2 = nodeId + "_" + node_j;
|
||||||
|
|
||||||
addEdge(edgeId_1, node_i, node_k);
|
addEdge(edgeId_1, node_i, nodeId);
|
||||||
|
|
||||||
if(!(isLast(insertionIndex,route) && !data.getSelectedVehicle().isReturnToDepot())) {
|
if(!(isLast(insertionIndex,route) && !data.getSelectedVehicle().isReturnToDepot())) {
|
||||||
addEdge(edgeId_2, node_k, node_j);
|
addEdge(edgeId_2, nodeId, node_j);
|
||||||
if (!route.getActivities().isEmpty()) {
|
if (!route.getActivities().isEmpty()) {
|
||||||
removeEdge(node_i + "_" + node_j);
|
removeEdge(node_i + "_" + node_j);
|
||||||
}
|
}
|
||||||
|
|
@ -511,7 +510,7 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
|
||||||
graph.getEdge(edgeId).addAttribute("ui.class","removed");
|
graph.getEdge(edgeId).addAttribute("ui.class","removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFirst(int index, VehicleRoute route) {
|
private boolean isFirst(int index) {
|
||||||
return index == 0;
|
return index == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,8 @@ public class GraphStreamViewer {
|
||||||
"}" ;
|
"}" ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public static String SIMPLE_WHITE =
|
public static String SIMPLE_WHITE =
|
||||||
"node {" +
|
"node {" +
|
||||||
" size: 10px, 10px;" +
|
" size: 10px, 10px;" +
|
||||||
|
|
@ -287,6 +289,7 @@ public class GraphStreamViewer {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public GraphStreamViewer setEnableAutoLayout(boolean enableAutoLayout) {
|
public GraphStreamViewer setEnableAutoLayout(boolean enableAutoLayout) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +328,7 @@ public class GraphStreamViewer {
|
||||||
|
|
||||||
View view = createEmbeddedView(g,scaling);
|
View view = createEmbeddedView(g,scaling);
|
||||||
|
|
||||||
JFrame jframe = createJFrame(view,scaling);
|
createJFrame(view,scaling);
|
||||||
|
|
||||||
render(g, view);
|
render(g, view);
|
||||||
}
|
}
|
||||||
|
|
@ -363,7 +366,7 @@ public class GraphStreamViewer {
|
||||||
//conf jframe
|
//conf jframe
|
||||||
jframe.setSize((int)(800*scaling),(int)(580*scaling));
|
jframe.setSize((int)(800*scaling),(int)(580*scaling));
|
||||||
jframe.setLocationRelativeTo(null);
|
jframe.setLocationRelativeTo(null);
|
||||||
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
jframe.setVisible(true);
|
jframe.setVisible(true);
|
||||||
jframe.pack();
|
jframe.pack();
|
||||||
jframe.setTitle("jsprit - GraphStream");
|
jframe.setTitle("jsprit - GraphStream");
|
||||||
|
|
@ -548,20 +551,19 @@ public class GraphStreamViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderVehicle(Graph g, Vehicle vehicle, Label label) {
|
private void renderVehicle(Graph g, Vehicle vehicle, Label label) {
|
||||||
String nodeId = makeId(vehicle.getId(),vehicle.getStartLocationId());
|
String nodeId = makeId(vehicle.getId(),vehicle.getStartLocation().getId());
|
||||||
Node vehicleStart = g.addNode(nodeId);
|
Node vehicleStart = g.addNode(nodeId);
|
||||||
if(label.equals(Label.ID)) vehicleStart.addAttribute("ui.label", "depot");
|
if(label.equals(Label.ID)) vehicleStart.addAttribute("ui.label", "depot");
|
||||||
// if(label.equals(Label.ACTIVITY)) n.addAttribute("ui.label", "start");
|
// if(label.equals(Label.ACTIVITY)) n.addAttribute("ui.label", "start");
|
||||||
vehicleStart.addAttribute("x", vehicle.getStartLocationCoordinate().getX());
|
vehicleStart.addAttribute("x", vehicle.getStartLocation().getCoordinate().getX());
|
||||||
vehicleStart.addAttribute("y", vehicle.getStartLocationCoordinate().getY());
|
vehicleStart.addAttribute("y", vehicle.getStartLocation().getCoordinate().getY());
|
||||||
vehicleStart.setAttribute("ui.class", "depot");
|
vehicleStart.setAttribute("ui.class", "depot");
|
||||||
|
|
||||||
if(!vehicle.getStartLocationId().equals(vehicle.getEndLocationId())){
|
if(!vehicle.getStartLocation().getId().equals(vehicle.getEndLocation().getId())){
|
||||||
Node vehicleEnd = g.addNode(makeId(vehicle.getId(),vehicle.getEndLocationId()));
|
Node vehicleEnd = g.addNode(makeId(vehicle.getId(),vehicle.getEndLocation().getId()));
|
||||||
if(label.equals(Label.ID)) vehicleEnd.addAttribute("ui.label", "depot");
|
if(label.equals(Label.ID)) vehicleEnd.addAttribute("ui.label", "depot");
|
||||||
// if(label.equals(Label.ACTIVITY)) n.addAttribute("ui.label", "start");
|
vehicleEnd.addAttribute("x", vehicle.getEndLocation().getCoordinate().getX());
|
||||||
vehicleEnd.addAttribute("x", vehicle.getEndLocationCoordinate().getX());
|
vehicleEnd.addAttribute("y", vehicle.getEndLocation().getCoordinate().getY());
|
||||||
vehicleEnd.addAttribute("y", vehicle.getEndLocationCoordinate().getY());
|
|
||||||
vehicleEnd.setAttribute("ui.class", "depot");
|
vehicleEnd.setAttribute("ui.class", "depot");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -569,7 +571,7 @@ public class GraphStreamViewer {
|
||||||
|
|
||||||
private void renderRoute(Graph g, VehicleRoute route, int routeId, long renderDelay_in_ms, Label label) {
|
private void renderRoute(Graph g, VehicleRoute route, int routeId, long renderDelay_in_ms, Label label) {
|
||||||
int vehicle_edgeId = 1;
|
int vehicle_edgeId = 1;
|
||||||
String prevIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getStartLocationId());
|
String prevIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getStartLocation().getId());
|
||||||
if(label.equals(Label.ACTIVITY) || label.equals(Label.JOB_NAME)){
|
if(label.equals(Label.ACTIVITY) || label.equals(Label.JOB_NAME)){
|
||||||
Node n = g.getNode(prevIdentifier);
|
Node n = g.getNode(prevIdentifier);
|
||||||
n.addAttribute("ui.label", "start");
|
n.addAttribute("ui.label", "start");
|
||||||
|
|
@ -601,7 +603,7 @@ public class GraphStreamViewer {
|
||||||
sleep(renderDelay_in_ms);
|
sleep(renderDelay_in_ms);
|
||||||
}
|
}
|
||||||
if(route.getVehicle().isReturnToDepot()){
|
if(route.getVehicle().isReturnToDepot()){
|
||||||
String lastIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getEndLocationId());
|
String lastIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getEndLocation().getId());
|
||||||
g.addEdge(makeEdgeId(routeId,vehicle_edgeId), prevIdentifier, lastIdentifier, true);
|
g.addEdge(makeEdgeId(routeId,vehicle_edgeId), prevIdentifier, lastIdentifier, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ public class Plotter {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static enum Label {
|
public static enum Label {
|
||||||
ID, SIZE, NO_LABEL
|
ID, SIZE, @SuppressWarnings("UnusedDeclaration")NO_LABEL
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label label = Label.SIZE;
|
private Label label = Label.SIZE;
|
||||||
|
|
@ -181,7 +181,7 @@ public class Plotter {
|
||||||
/**
|
/**
|
||||||
* Constructs Plotter with problem. Thus only the problem can be rendered.
|
* Constructs Plotter with problem. Thus only the problem can be rendered.
|
||||||
*
|
*
|
||||||
* @param vrp
|
* @param vrp the routing problem
|
||||||
*/
|
*/
|
||||||
public Plotter(VehicleRoutingProblem vrp) {
|
public Plotter(VehicleRoutingProblem vrp) {
|
||||||
super();
|
super();
|
||||||
|
|
@ -191,8 +191,8 @@ public class Plotter {
|
||||||
/**
|
/**
|
||||||
* Constructs Plotter with problem and solution to render them both.
|
* Constructs Plotter with problem and solution to render them both.
|
||||||
*
|
*
|
||||||
* @param vrp
|
* @param vrp the routing problem
|
||||||
* @param solution
|
* @param solution the solution
|
||||||
*/
|
*/
|
||||||
public Plotter(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) {
|
public Plotter(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) {
|
||||||
super();
|
super();
|
||||||
|
|
@ -204,8 +204,8 @@ public class Plotter {
|
||||||
/**
|
/**
|
||||||
* Constructs Plotter with problem and routes to render individual routes.
|
* Constructs Plotter with problem and routes to render individual routes.
|
||||||
*
|
*
|
||||||
* @param vrp
|
* @param vrp the routing problem
|
||||||
* @param routes
|
* @param routes routes
|
||||||
*/
|
*/
|
||||||
public Plotter(VehicleRoutingProblem vrp, Collection<VehicleRoute> routes) {
|
public Plotter(VehicleRoutingProblem vrp, Collection<VehicleRoute> routes) {
|
||||||
super();
|
super();
|
||||||
|
|
@ -214,17 +214,7 @@ public class Plotter {
|
||||||
plotSolutionAsWell = true;
|
plotSolutionAsWell = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
*
|
|
||||||
* @param show
|
|
||||||
* @return plotter
|
|
||||||
* @deprecated always true
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Plotter setShowFirstActivity(boolean show){
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Plotter setScalingFactor(double scalingFactor){
|
public Plotter setScalingFactor(double scalingFactor){
|
||||||
this.scalingFactor=scalingFactor;
|
this.scalingFactor=scalingFactor;
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -232,8 +222,8 @@ public class Plotter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a label.
|
* Sets a label.
|
||||||
* @param label
|
* @param label of jobs
|
||||||
* @return
|
* @return plotter
|
||||||
*/
|
*/
|
||||||
public Plotter setLabel(Label label){
|
public Plotter setLabel(Label label){
|
||||||
this.label = label;
|
this.label = label;
|
||||||
|
|
@ -243,12 +233,13 @@ public class Plotter {
|
||||||
/**
|
/**
|
||||||
* Sets a bounding box to zoom in to certain areas.
|
* Sets a bounding box to zoom in to certain areas.
|
||||||
*
|
*
|
||||||
* @param minX
|
* @param minX lower left x
|
||||||
* @param minY
|
* @param minY lower left y
|
||||||
* @param maxX
|
* @param maxX upper right x
|
||||||
* @param maxY
|
* @param maxY upper right y
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public Plotter setBoundingBox(double minX, double minY, double maxX, double maxY){
|
public Plotter setBoundingBox(double minX, double minY, double maxX, double maxY){
|
||||||
boundingBox = new BoundingBox(minX,minY,maxX,maxY);
|
boundingBox = new BoundingBox(minX,minY,maxX,maxY);
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -257,8 +248,8 @@ public class Plotter {
|
||||||
/**
|
/**
|
||||||
* Flag that indicates whether shipments should be rendered as well.
|
* Flag that indicates whether shipments should be rendered as well.
|
||||||
*
|
*
|
||||||
* @param plotShipments
|
* @param plotShipments flag to plot shipment
|
||||||
* @return
|
* @return the plotter
|
||||||
*/
|
*/
|
||||||
public Plotter plotShipments(boolean plotShipments) {
|
public Plotter plotShipments(boolean plotShipments) {
|
||||||
this.plotShipments = plotShipments;
|
this.plotShipments = plotShipments;
|
||||||
|
|
@ -287,7 +278,7 @@ public class Plotter {
|
||||||
|
|
||||||
private void plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title){
|
private void plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title){
|
||||||
log.info("plot to " + pngFile);
|
log.info("plot to " + pngFile);
|
||||||
XYSeriesCollection problem = null;
|
XYSeriesCollection problem;
|
||||||
XYSeriesCollection solution = null;
|
XYSeriesCollection solution = null;
|
||||||
final XYSeriesCollection shipments;
|
final XYSeriesCollection shipments;
|
||||||
try {
|
try {
|
||||||
|
|
@ -520,13 +511,13 @@ public class Plotter {
|
||||||
XYDataItem dataItem = new XYDataItem(s.getPickupLocation().getCoordinate().getX()*scalingFactor, s.getPickupLocation().getCoordinate().getY()*scalingFactor);
|
XYDataItem dataItem = new XYDataItem(s.getPickupLocation().getCoordinate().getX()*scalingFactor, s.getPickupLocation().getCoordinate().getY()*scalingFactor);
|
||||||
activities.add(dataItem);
|
activities.add(dataItem);
|
||||||
addLabel(s, dataItem);
|
addLabel(s, dataItem);
|
||||||
markItem(dataItem,Activity.PICKUP, job);
|
markItem(dataItem,Activity.PICKUP);
|
||||||
containsPickupAct = true;
|
containsPickupAct = true;
|
||||||
|
|
||||||
XYDataItem dataItem2 = new XYDataItem(s.getDeliveryLocation().getCoordinate().getX()*scalingFactor, s.getDeliveryLocation().getCoordinate().getY()*scalingFactor);
|
XYDataItem dataItem2 = new XYDataItem(s.getDeliveryLocation().getCoordinate().getX()*scalingFactor, s.getDeliveryLocation().getCoordinate().getY()*scalingFactor);
|
||||||
activities.add(dataItem2);
|
activities.add(dataItem2);
|
||||||
addLabel(s, dataItem2);
|
addLabel(s, dataItem2);
|
||||||
markItem(dataItem2,Activity.DELIVERY, job);
|
markItem(dataItem2,Activity.DELIVERY);
|
||||||
containsDeliveryAct = true;
|
containsDeliveryAct = true;
|
||||||
}
|
}
|
||||||
else if(job instanceof Pickup){
|
else if(job instanceof Pickup){
|
||||||
|
|
@ -535,7 +526,7 @@ public class Plotter {
|
||||||
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
|
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
|
||||||
activities.add(dataItem);
|
activities.add(dataItem);
|
||||||
addLabel(service, dataItem);
|
addLabel(service, dataItem);
|
||||||
markItem(dataItem, Activity.PICKUP, job);
|
markItem(dataItem, Activity.PICKUP);
|
||||||
containsPickupAct = true;
|
containsPickupAct = true;
|
||||||
}
|
}
|
||||||
else if(job instanceof Delivery){
|
else if(job instanceof Delivery){
|
||||||
|
|
@ -544,7 +535,7 @@ public class Plotter {
|
||||||
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
|
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
|
||||||
activities.add(dataItem);
|
activities.add(dataItem);
|
||||||
addLabel(service, dataItem);
|
addLabel(service, dataItem);
|
||||||
markItem(dataItem, Activity.DELIVERY, job);
|
markItem(dataItem, Activity.DELIVERY);
|
||||||
containsDeliveryAct = true;
|
containsDeliveryAct = true;
|
||||||
}
|
}
|
||||||
else if(job instanceof Service){
|
else if(job instanceof Service){
|
||||||
|
|
@ -553,7 +544,7 @@ public class Plotter {
|
||||||
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
|
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
|
||||||
activities.add(dataItem);
|
activities.add(dataItem);
|
||||||
addLabel(service, dataItem);
|
addLabel(service, dataItem);
|
||||||
markItem(dataItem, Activity.SERVICE, job);
|
markItem(dataItem, Activity.SERVICE);
|
||||||
containsServiceAct = true;
|
containsServiceAct = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -591,18 +582,18 @@ public class Plotter {
|
||||||
private void retrieveActivities(VehicleRoutingProblem vrp) throws NoLocationFoundException{
|
private void retrieveActivities(VehicleRoutingProblem vrp) throws NoLocationFoundException{
|
||||||
activities = new XYSeries("activities", false, true);
|
activities = new XYSeries("activities", false, true);
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
Coordinate startCoord = v.getStartLocationCoordinate();
|
Coordinate start_coordinate = v.getStartLocation().getCoordinate();
|
||||||
if(startCoord == null) throw new NoLocationFoundException();
|
if(start_coordinate == null) throw new NoLocationFoundException();
|
||||||
XYDataItem item = new XYDataItem(startCoord.getX()*scalingFactor, startCoord.getY()*scalingFactor);
|
XYDataItem item = new XYDataItem(start_coordinate.getX()*scalingFactor, start_coordinate.getY()*scalingFactor);
|
||||||
markItem(item,Activity.START, null);
|
markItem(item,Activity.START);
|
||||||
activities.add(item);
|
activities.add(item);
|
||||||
|
|
||||||
if(!v.getStartLocationId().equals(v.getEndLocationId())){
|
if(!v.getStartLocation().getId().equals(v.getEndLocation().getId())){
|
||||||
Coordinate endCoord = v.getEndLocationCoordinate();
|
Coordinate end_coordinate = v.getEndLocation().getCoordinate();
|
||||||
if(endCoord == null) throw new NoLocationFoundException();
|
if(end_coordinate == null) throw new NoLocationFoundException();
|
||||||
XYDataItem enditem = new XYDataItem(endCoord.getX()*scalingFactor,endCoord.getY()*scalingFactor);
|
XYDataItem end_item = new XYDataItem(end_coordinate.getX()*scalingFactor,end_coordinate.getY()*scalingFactor);
|
||||||
markItem(enditem,Activity.END, null);
|
markItem(end_item,Activity.END);
|
||||||
activities.add(enditem);
|
activities.add(end_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Job job : vrp.getJobs().values()){
|
for(Job job : vrp.getJobs().values()){
|
||||||
|
|
@ -615,7 +606,7 @@ public class Plotter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markItem(XYDataItem item, Activity activity, Job job) {
|
private void markItem(XYDataItem item, Activity activity) {
|
||||||
activitiesByDataItem.put(item,activity);
|
activitiesByDataItem.put(item,activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package jsprit.core.algorithm.recreate;
|
||||||
|
|
||||||
import jsprit.core.algorithm.state.InternalStates;
|
import jsprit.core.algorithm.state.InternalStates;
|
||||||
import jsprit.core.problem.JobActivityFactory;
|
import jsprit.core.problem.JobActivityFactory;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.constraint.HardActivityConstraint;
|
import jsprit.core.problem.constraint.HardActivityConstraint;
|
||||||
import jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
import jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
|
||||||
import jsprit.core.problem.constraint.HardRouteConstraint;
|
import jsprit.core.problem.constraint.HardRouteConstraint;
|
||||||
|
|
@ -38,7 +39,10 @@ import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.PriorityQueue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -127,7 +131,7 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
|
||||||
/**
|
/**
|
||||||
* map that memorizes the costs with newVehicle, which is a cost-snapshot at tour-activities.
|
* map that memorizes the costs with newVehicle, which is a cost-snapshot at tour-activities.
|
||||||
*/
|
*/
|
||||||
Map<TourActivity,Double> activity2costWithNewVehicle = new HashMap<TourActivity,Double>();
|
// Map<TourActivity,Double> activity2costWithNewVehicle = new HashMap<TourActivity,Double>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* priority queue that stores insertion-data by insertion-costs in ascending order.
|
* priority queue that stores insertion-data by insertion-costs in ascending order.
|
||||||
|
|
@ -197,7 +201,7 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
|
||||||
* memorize transport and activity costs with new vehicle without inserting k
|
* memorize transport and activity costs with new vehicle without inserting k
|
||||||
*/
|
*/
|
||||||
sumOf_prevCosts_newVehicle += transportCost_prevAct_nextAct_newVehicle + activityCost_nextAct;
|
sumOf_prevCosts_newVehicle += transportCost_prevAct_nextAct_newVehicle + activityCost_nextAct;
|
||||||
activity2costWithNewVehicle.put(nextAct, sumOf_prevCosts_newVehicle);
|
// activity2costWithNewVehicle.put(nextAct, sumOf_prevCosts_newVehicle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* departure time at nextAct with new vehicle
|
* departure time at nextAct with new vehicle
|
||||||
|
|
@ -284,20 +288,14 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
|
||||||
insertionData.setVehicleDepartureTime(start.getEndTime());
|
insertionData.setVehicleDepartureTime(start.getEndTime());
|
||||||
return insertionData;
|
return insertionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* initialize start and end of tour.
|
|
||||||
*
|
|
||||||
* @param newVehicle
|
|
||||||
* @param newVehicleDepartureTime
|
|
||||||
*/
|
|
||||||
private void initialiseStartAndEnd(final Vehicle newVehicle, double newVehicleDepartureTime) {
|
private void initialiseStartAndEnd(final Vehicle newVehicle, double newVehicleDepartureTime) {
|
||||||
if(start == null){
|
if(start == null){
|
||||||
start = new Start(newVehicle.getStartLocation(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
start = new Start(newVehicle.getStartLocation(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
||||||
start.setEndTime(newVehicleDepartureTime);
|
start.setEndTime(newVehicleDepartureTime);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
start.setLocationId(newVehicle.getStartLocationId());
|
start.setLocation(Location.newInstance(newVehicle.getStartLocation().getId()));
|
||||||
start.setTheoreticalEarliestOperationStartTime(newVehicle.getEarliestDeparture());
|
start.setTheoreticalEarliestOperationStartTime(newVehicle.getEarliestDeparture());
|
||||||
start.setTheoreticalLatestOperationStartTime(Double.MAX_VALUE);
|
start.setTheoreticalLatestOperationStartTime(Double.MAX_VALUE);
|
||||||
start.setEndTime(newVehicleDepartureTime);
|
start.setEndTime(newVehicleDepartureTime);
|
||||||
|
|
@ -307,7 +305,7 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
|
||||||
end = new End(newVehicle.getEndLocation(), 0.0, newVehicle.getLatestArrival());
|
end = new End(newVehicle.getEndLocation(), 0.0, newVehicle.getLatestArrival());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
end.setLocationId(newVehicle.getEndLocationId());
|
end.setLocation(Location.newInstance(newVehicle.getEndLocation().getId()));
|
||||||
end.setTheoreticalEarliestOperationStartTime(0.0);
|
end.setTheoreticalEarliestOperationStartTime(0.0);
|
||||||
end.setTheoreticalLatestOperationStartTime(newVehicle.getLatestArrival());
|
end.setTheoreticalLatestOperationStartTime(newVehicle.getLatestArrival());
|
||||||
}
|
}
|
||||||
|
|
@ -323,10 +321,6 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
|
||||||
return prevCost;
|
return prevCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* creates a comparator to sort insertion-data in insertionQueue in ascending order according insertion costs.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Comparator<InsertionData> getComparator() {
|
private Comparator<InsertionData> getComparator() {
|
||||||
return new Comparator<InsertionData>() {
|
return new Comparator<InsertionData>() {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -365,10 +365,10 @@ public class VehicleRoutingProblem {
|
||||||
if(!vehicleTypes.contains(vehicle.getType())){
|
if(!vehicleTypes.contains(vehicle.getType())){
|
||||||
vehicleTypes.add(vehicle.getType());
|
vehicleTypes.add(vehicle.getType());
|
||||||
}
|
}
|
||||||
String startLocationId = vehicle.getStartLocationId();
|
String startLocationId = vehicle.getStartLocation().getId();
|
||||||
tentative_coordinates.put(startLocationId, vehicle.getStartLocationCoordinate());
|
tentative_coordinates.put(startLocationId, vehicle.getStartLocation().getCoordinate());
|
||||||
if(!vehicle.getEndLocationId().equals(startLocationId)){
|
if(!vehicle.getEndLocation().getId().equals(startLocationId)){
|
||||||
tentative_coordinates.put(vehicle.getEndLocationId(), vehicle.getEndLocationCoordinate());
|
tentative_coordinates.put(vehicle.getEndLocation().getId(), vehicle.getEndLocation().getCoordinate());
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,6 @@ public class Delivery extends Service{
|
||||||
public Delivery build(){
|
public Delivery build(){
|
||||||
if(location == null) {
|
if(location == null) {
|
||||||
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
|
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
|
||||||
// if(coord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not.");
|
|
||||||
// locationId = coord.toString();
|
|
||||||
}
|
}
|
||||||
this.setType("delivery");
|
this.setType("delivery");
|
||||||
super.capacity = super.capacityBuilder.build();
|
super.capacity = super.capacityBuilder.build();
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,6 @@ public class Pickup extends Service {
|
||||||
public Pickup build(){
|
public Pickup build(){
|
||||||
if(location == null) {
|
if(location == null) {
|
||||||
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
|
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
|
||||||
// if(coord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not.");
|
|
||||||
// locationId = coord.toString();
|
|
||||||
}
|
}
|
||||||
this.setType("pickup");
|
this.setType("pickup");
|
||||||
super.capacity = super.capacityBuilder.build();
|
super.capacity = super.capacityBuilder.build();
|
||||||
|
|
|
||||||
|
|
@ -191,11 +191,6 @@ public class Service extends AbstractJob {
|
||||||
public Service build(){
|
public Service build(){
|
||||||
if(location == null) {
|
if(location == null) {
|
||||||
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
|
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
|
||||||
// if (locationId == null) {
|
|
||||||
// if (coord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not.");
|
|
||||||
// locationId = coord.toString();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
this.setType("service");
|
this.setType("service");
|
||||||
capacity = capacityBuilder.build();
|
capacity = capacityBuilder.build();
|
||||||
|
|
|
||||||
|
|
@ -299,13 +299,9 @@ public class Shipment extends AbstractJob{
|
||||||
public Shipment build(){
|
public Shipment build(){
|
||||||
if(pickupLocation_ == null) {
|
if(pickupLocation_ == null) {
|
||||||
this.pickupLocation_ = Location.Builder.newInstance().setCoordinate(pickupCoord).setId(pickupLocation).build();
|
this.pickupLocation_ = Location.Builder.newInstance().setCoordinate(pickupCoord).setId(pickupLocation).build();
|
||||||
// if(pickupCoord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not.");
|
|
||||||
// pickupLocation = pickupCoord.toString();
|
|
||||||
}
|
}
|
||||||
if(deliveryLocation_ == null) {
|
if(deliveryLocation_ == null) {
|
||||||
this.deliveryLocation_ = Location.Builder.newInstance().setCoordinate(deliveryCoord).setId(deliveryLocation).build();
|
this.deliveryLocation_ = Location.Builder.newInstance().setCoordinate(deliveryCoord).setId(deliveryLocation).build();
|
||||||
// if(deliveryCoord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not.");
|
|
||||||
// deliveryLocation = deliveryCoord.toString();
|
|
||||||
}
|
}
|
||||||
capacity = capacityBuilder.build();
|
capacity = capacityBuilder.build();
|
||||||
skills = skillBuilder.build();
|
skills = skillBuilder.build();
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,10 @@ package jsprit.core.problem.vehicle;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,7 +33,7 @@ class InfiniteVehicles implements VehicleFleetManager{
|
||||||
|
|
||||||
private Map<VehicleTypeKey,Vehicle> types = new HashMap<VehicleTypeKey, Vehicle>();
|
private Map<VehicleTypeKey,Vehicle> types = new HashMap<VehicleTypeKey, Vehicle>();
|
||||||
|
|
||||||
private List<VehicleTypeKey> sortedTypes = new ArrayList<VehicleTypeKey>();
|
// private List<VehicleTypeKey> sortedTypes = new ArrayList<VehicleTypeKey>();
|
||||||
|
|
||||||
public InfiniteVehicles(Collection<Vehicle> vehicles){
|
public InfiniteVehicles(Collection<Vehicle> vehicles){
|
||||||
extractTypes(vehicles);
|
extractTypes(vehicles);
|
||||||
|
|
@ -44,10 +47,9 @@ class InfiniteVehicles implements VehicleFleetManager{
|
||||||
|
|
||||||
private void extractTypes(Collection<Vehicle> vehicles) {
|
private void extractTypes(Collection<Vehicle> vehicles) {
|
||||||
for(Vehicle v : vehicles){
|
for(Vehicle v : vehicles){
|
||||||
VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocationId(),v.getEndLocationId(), v.getEarliestDeparture(), v.getLatestArrival(), v.getSkills());
|
VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocation().getId(),v.getEndLocation().getId(), v.getEarliestDeparture(), v.getLatestArrival(), v.getSkills());
|
||||||
types.put(typeKey,v);
|
types.put(typeKey,v);
|
||||||
sortedTypes.add(typeKey);
|
// sortedTypes.add(typeKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +83,7 @@ class InfiniteVehicles implements VehicleFleetManager{
|
||||||
@Override
|
@Override
|
||||||
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType) {
|
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType) {
|
||||||
Collection<Vehicle> vehicles = new ArrayList<Vehicle>();
|
Collection<Vehicle> vehicles = new ArrayList<Vehicle>();
|
||||||
VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType.getType().getTypeId(), withoutThisType.getStartLocationId(), withoutThisType.getEndLocationId(), withoutThisType.getEarliestDeparture(), withoutThisType.getLatestArrival(), withoutThisType.getSkills());
|
VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType.getType().getTypeId(), withoutThisType.getStartLocation().getId(), withoutThisType.getEndLocation().getId(), withoutThisType.getEarliestDeparture(), withoutThisType.getLatestArrival(), withoutThisType.getSkills());
|
||||||
for(VehicleTypeKey key : types.keySet()){
|
for(VehicleTypeKey key : types.keySet()){
|
||||||
if(!key.equals(thisKey)){
|
if(!key.equals(thisKey)){
|
||||||
vehicles.add(types.get(key));
|
vehicles.add(types.get(key));
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,6 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
public VehicleFleetManagerImpl newInstance(Collection<Vehicle> vehicles){
|
public VehicleFleetManagerImpl newInstance(Collection<Vehicle> vehicles){
|
||||||
return new VehicleFleetManagerImpl(vehicles);
|
return new VehicleFleetManagerImpl(vehicles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static VehicleFleetManager createDefaultFleetManager() {
|
|
||||||
return new DefaultFleetManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DefaultFleetManager extends VehicleFleetManagerImpl {
|
|
||||||
|
|
||||||
public DefaultFleetManager() {
|
|
||||||
super(Collections.<Vehicle> emptyList());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static class TypeContainer {
|
static class TypeContainer {
|
||||||
|
|
||||||
|
|
@ -92,17 +78,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
makeMap();
|
makeMap();
|
||||||
logger.info("initialise " + this);
|
logger.info("initialise " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VehicleFleetManagerImpl(Collection<Vehicle> vehicles, Collection<Vehicle> lockedVehicles) {
|
|
||||||
this.vehicles = vehicles;
|
|
||||||
makeMap();
|
|
||||||
this.lockedVehicles = new HashSet<Vehicle>();
|
|
||||||
for(Vehicle v : lockedVehicles){
|
|
||||||
lock(v);
|
|
||||||
}
|
|
||||||
logger.info("initialise " + this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[name=finiteVehicles]";
|
return "[name=finiteVehicles]";
|
||||||
|
|
@ -120,7 +96,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
if(v.getType() == null){
|
if(v.getType() == null){
|
||||||
throw new IllegalStateException("vehicle needs type");
|
throw new IllegalStateException("vehicle needs type");
|
||||||
}
|
}
|
||||||
VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocationId(), v.getEndLocationId(), v.getEarliestDeparture(), v.getLatestArrival(), v.getSkills());
|
VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocation().getId(), v.getEndLocation().getId(), v.getEarliestDeparture(), v.getLatestArrival(), v.getSkills());
|
||||||
if(!typeMapOfAvailableVehicles.containsKey(typeKey)){
|
if(!typeMapOfAvailableVehicles.containsKey(typeKey)){
|
||||||
typeMapOfAvailableVehicles.put(typeKey, new TypeContainer());
|
typeMapOfAvailableVehicles.put(typeKey, new TypeContainer());
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +105,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeVehicle(Vehicle v){
|
private void removeVehicle(Vehicle v){
|
||||||
VehicleTypeKey key = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocationId(), v.getEndLocationId(), v.getEarliestDeparture(), v.getLatestArrival(), v.getSkills());
|
VehicleTypeKey key = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocation().getId(), v.getEndLocation().getId(), v.getEarliestDeparture(), v.getLatestArrival(), v.getSkills());
|
||||||
if(typeMapOfAvailableVehicles.containsKey(key)){
|
if(typeMapOfAvailableVehicles.containsKey(key)){
|
||||||
typeMapOfAvailableVehicles.get(key).remove(v);
|
typeMapOfAvailableVehicles.get(key).remove(v);
|
||||||
}
|
}
|
||||||
|
|
@ -161,7 +137,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
@Override
|
@Override
|
||||||
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType) {
|
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType) {
|
||||||
List<Vehicle> vehicles = new ArrayList<Vehicle>();
|
List<Vehicle> vehicles = new ArrayList<Vehicle>();
|
||||||
VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType.getType().getTypeId(), withoutThisType.getStartLocationId(), withoutThisType.getEndLocationId(), withoutThisType.getEarliestDeparture(), withoutThisType.getLatestArrival(), withoutThisType.getSkills());
|
VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType.getType().getTypeId(), withoutThisType.getStartLocation().getId(), withoutThisType.getEndLocation().getId(), withoutThisType.getEarliestDeparture(), withoutThisType.getLatestArrival(), withoutThisType.getSkills());
|
||||||
for(VehicleTypeKey key : typeMapOfAvailableVehicles.keySet()){
|
for(VehicleTypeKey key : typeMapOfAvailableVehicles.keySet()){
|
||||||
if(key.equals(thisKey)) continue;
|
if(key.equals(thisKey)) continue;
|
||||||
if(!typeMapOfAvailableVehicles.get(key).isEmpty()){
|
if(!typeMapOfAvailableVehicles.get(key).isEmpty()){
|
||||||
|
|
@ -225,12 +201,10 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
throw new IllegalStateException("no vehicle must be locked");
|
throw new IllegalStateException("no vehicle must be locked");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public int sizeOfLockedVehicles(){
|
public int sizeOfLockedVehicles(){
|
||||||
return lockedVehicles.size();
|
return lockedVehicles.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package jsprit.core.algorithm.recreate;
|
package jsprit.core.algorithm.recreate;
|
||||||
|
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.job.Service;
|
import jsprit.core.problem.job.Service;
|
||||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||||
|
|
@ -48,8 +49,8 @@ public class CalcVehicleTypeDependentServiceInsertionTest {
|
||||||
veh2 = mock(Vehicle.class);
|
veh2 = mock(Vehicle.class);
|
||||||
when(veh1.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type1").build());
|
when(veh1.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type1").build());
|
||||||
when(veh2.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type2").build());
|
when(veh2.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type2").build());
|
||||||
when(veh1.getStartLocationId()).thenReturn("loc1");
|
when(veh1.getStartLocation()).thenReturn(Location.newInstance("loc1"));
|
||||||
when(veh2.getStartLocationId()).thenReturn("loc2");
|
when(veh2.getStartLocation()).thenReturn(Location.newInstance("loc2"));
|
||||||
fleetManager = mock(VehicleFleetManager.class);
|
fleetManager = mock(VehicleFleetManager.class);
|
||||||
service = mock(Service.class);
|
service = mock(Service.class);
|
||||||
vehicleRoute = mock(VehicleRoute.class);
|
vehicleRoute = mock(VehicleRoute.class);
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,11 @@ import jsprit.core.problem.AbstractActivity;
|
||||||
import jsprit.core.problem.JobActivityFactory;
|
import jsprit.core.problem.JobActivityFactory;
|
||||||
import jsprit.core.problem.Location;
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.constraint.*;
|
import jsprit.core.problem.constraint.ConstraintManager;
|
||||||
import jsprit.core.problem.constraint.ConstraintManager.Priority;
|
import jsprit.core.problem.constraint.ConstraintManager.Priority;
|
||||||
|
import jsprit.core.problem.constraint.HardRouteConstraint;
|
||||||
|
import jsprit.core.problem.constraint.PickupAndDeliverShipmentLoadActivityLevelConstraint;
|
||||||
|
import jsprit.core.problem.constraint.ShipmentPickupsFirstConstraint;
|
||||||
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import jsprit.core.problem.driver.Driver;
|
import jsprit.core.problem.driver.Driver;
|
||||||
|
|
@ -71,14 +74,6 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
HardActivityConstraint hardActivityLevelConstraint = new HardActivityConstraint() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct,TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
|
||||||
return ConstraintsStatus.FULFILLED;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HardRouteConstraint hardRouteLevelConstraint = new HardRouteConstraint(){
|
HardRouteConstraint hardRouteLevelConstraint = new HardRouteConstraint(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -98,7 +93,7 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
routingCosts = CostFactory.createManhattanCosts();
|
routingCosts = CostFactory.createManhattanCosts();
|
||||||
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").addCapacityDimension(0, 2).setCostPerDistance(1).build();
|
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").addCapacityDimension(0, 2).setCostPerDistance(1).build();
|
||||||
vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(type).build();
|
vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("0,0")).setType(type).build();
|
||||||
activityInsertionCostsCalculator = new LocalActivityInsertionCostsCalculator(routingCosts, activityCosts);
|
activityInsertionCostsCalculator = new LocalActivityInsertionCostsCalculator(routingCosts, activityCosts);
|
||||||
createInsertionCalculator(hardRouteLevelConstraint);
|
createInsertionCalculator(hardRouteLevelConstraint);
|
||||||
vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
|
vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
|
||||||
|
|
@ -112,7 +107,7 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCalculatingInsertionCostsOfShipment_itShouldReturnCorrectCostValue(){
|
public void whenCalculatingInsertionCostsOfShipment_itShouldReturnCorrectCostValue(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
|
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocation(Location.newInstance("10,0")).build();
|
||||||
VehicleRoute route = 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>();
|
||||||
|
|
@ -126,8 +121,8 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCalculatingInsertionIntoExistingRoute_itShouldReturnCorrectCosts(){
|
public void whenCalculatingInsertionIntoExistingRoute_itShouldReturnCorrectCosts(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
|
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocation(Location.newInstance("10,0")).build();
|
||||||
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
|
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocation(Location.newInstance("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);
|
||||||
|
|
@ -156,8 +151,8 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenInsertingShipmentInRouteWithNotEnoughCapacity_itShouldReturnNoInsertion(){
|
public void whenInsertingShipmentInRouteWithNotEnoughCapacity_itShouldReturnNoInsertion(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
|
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocation(Location.newInstance("10,0")).build();
|
||||||
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
|
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocation(Location.newInstance("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);
|
||||||
|
|
@ -185,9 +180,9 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenInsertingThirdShipment_itShouldCalcCorrectVal(){
|
public void whenInsertingThirdShipment_itShouldCalcCorrectVal(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
|
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocation(Location.newInstance("10,0")).build();
|
||||||
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
|
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocation(Location.newInstance("0,0")).build();
|
||||||
Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("9,10").build();
|
Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocation(Location.newInstance("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));
|
||||||
|
|
@ -211,9 +206,9 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenInsertingThirdShipment_itShouldCalcCorrectVal2(){
|
public void whenInsertingThirdShipment_itShouldCalcCorrectVal2(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
|
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocation(Location.newInstance("10,0")).build();
|
||||||
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
|
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocation(Location.newInstance("0,0")).build();
|
||||||
Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("9,9").build();
|
Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocation(Location.newInstance("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();
|
||||||
|
|
@ -237,9 +232,9 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenInstertingShipmentWithLoadConstraintWhereCapIsNotSufficient_capConstraintsAreFulfilled(){
|
public void whenInstertingShipmentWithLoadConstraintWhereCapIsNotSufficient_capConstraintsAreFulfilled(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
|
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocation(Location.newInstance("10,0")).build();
|
||||||
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
|
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocation(Location.newInstance("0,0")).build();
|
||||||
Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("9,9").build();
|
Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocation(Location.newInstance("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();
|
||||||
|
|
@ -270,8 +265,8 @@ public class ShipmentInsertionCalculatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnNoInsertionData(){
|
public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnNoInsertionData(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("0,0").build();
|
Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocation(Location.newInstance("0,0")).build();
|
||||||
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
|
Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocation(Location.newInstance("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();
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,8 @@ public class TestInserter {
|
||||||
public void whenInsertingServiceAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){
|
public void whenInsertingServiceAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){
|
||||||
Service service = mock(Service.class);
|
Service service = mock(Service.class);
|
||||||
Vehicle vehicle = mock(Vehicle.class);
|
Vehicle vehicle = mock(Vehicle.class);
|
||||||
when(vehicle.getStartLocationId()).thenReturn("vehLoc");
|
when(vehicle.getStartLocation()).thenReturn(Location.newInstance("vehLoc"));
|
||||||
when(vehicle.getEndLocationId()).thenReturn("vehLoc");
|
when(vehicle.getEndLocation()).thenReturn(Location.newInstance("vehLoc"));
|
||||||
when(vehicle.isReturnToDepot()).thenReturn(false);
|
when(vehicle.isReturnToDepot()).thenReturn(false);
|
||||||
when(vehicle.getId()).thenReturn("vehId");
|
when(vehicle.getId()).thenReturn("vehId");
|
||||||
|
|
||||||
|
|
@ -128,7 +128,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").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
|
Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocation(Location.newInstance("delLoc")).setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
|
||||||
|
|
||||||
InsertionData iData = mock(InsertionData.class);
|
InsertionData iData = mock(InsertionData.class);
|
||||||
when(iData.getPickupInsertionIndex()).thenReturn(2);
|
when(iData.getPickupInsertionIndex()).thenReturn(2);
|
||||||
|
|
@ -164,7 +164,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").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
|
Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocation(Location.newInstance("delLoc")).setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).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);
|
||||||
|
|
@ -186,12 +186,12 @@ 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);
|
||||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setStartLocation(Location.newInstance("vehLoc")).setType(mock(VehicleType.class)).build();
|
||||||
Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setStartLocation(Location.newInstance("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(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").build();
|
Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocation(Location.newInstance("delLoc")).build();
|
||||||
|
|
||||||
InsertionData iData = mock(InsertionData.class);
|
InsertionData iData = mock(InsertionData.class);
|
||||||
when(iData.getPickupInsertionIndex()).thenReturn(2);
|
when(iData.getPickupInsertionIndex()).thenReturn(2);
|
||||||
|
|
@ -203,7 +203,7 @@ public class TestInserter {
|
||||||
Inserter inserter = new Inserter(mock(InsertionListeners.class), vehicleRoutingProblem);
|
Inserter inserter = new Inserter(mock(InsertionListeners.class), vehicleRoutingProblem);
|
||||||
inserter.insertJob(shipmentToInsert, iData, route);
|
inserter.insertJob(shipmentToInsert, iData, route);
|
||||||
|
|
||||||
assertEquals(route.getEnd().getLocation().getId(),newVehicle.getEndLocationId());
|
assertEquals(route.getEnd().getLocation().getId(),newVehicle.getEndLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -211,12 +211,12 @@ 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);
|
||||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocation(Location.newInstance("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).setStartLocation(Location.newInstance("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(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").build();
|
Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocation(Location.newInstance("delLoc")).build();
|
||||||
|
|
||||||
InsertionData iData = mock(InsertionData.class);
|
InsertionData iData = mock(InsertionData.class);
|
||||||
when(iData.getPickupInsertionIndex()).thenReturn(2);
|
when(iData.getPickupInsertionIndex()).thenReturn(2);
|
||||||
|
|
@ -242,7 +242,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(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").build();
|
Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocation(Location.newInstance("delLoc")).build();
|
||||||
|
|
||||||
InsertionData iData = mock(InsertionData.class);
|
InsertionData iData = mock(InsertionData.class);
|
||||||
when(iData.getPickupInsertionIndex()).thenReturn(0);
|
when(iData.getPickupInsertionIndex()).thenReturn(0);
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,9 @@ public class VrpXMLReaderTest {
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v1 = getVehicle("v1",vrp.getVehicles());
|
Vehicle v1 = getVehicle("v1",vrp.getVehicles());
|
||||||
assertEquals(20,v1.getType().getCapacityDimensions().get(0));
|
assertEquals(20,v1.getType().getCapacityDimensions().get(0));
|
||||||
assertEquals(100.0,v1.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(100.0,v1.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(0.0,v1.getEarliestDeparture(),0.01);
|
assertEquals(0.0,v1.getEarliestDeparture(),0.01);
|
||||||
assertEquals("depotLoc2",v1.getStartLocationId());
|
assertEquals("depotLoc2",v1.getStartLocation().getId());
|
||||||
assertNotNull(v1.getType());
|
assertNotNull(v1.getType());
|
||||||
assertEquals("vehType", v1.getType().getTypeId());
|
assertEquals("vehType", v1.getType().getTypeId());
|
||||||
assertNotNull(v1.getStartLocation());
|
assertNotNull(v1.getStartLocation());
|
||||||
|
|
@ -321,7 +321,7 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
||||||
assertEquals("startLoc",v3.getStartLocationId());
|
assertEquals("startLoc",v3.getStartLocation().getId());
|
||||||
assertNotNull(v3.getEndLocation());
|
assertNotNull(v3.getEndLocation());
|
||||||
assertEquals(4,v3.getEndLocation().getIndex());
|
assertEquals(4,v3.getEndLocation().getIndex());
|
||||||
}
|
}
|
||||||
|
|
@ -332,7 +332,7 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
||||||
assertEquals("endLoc",v3.getEndLocationId());
|
assertEquals("endLoc",v3.getEndLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -341,8 +341,8 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
||||||
assertEquals(1000.0,v3.getEndLocationCoordinate().getX(),0.01);
|
assertEquals(1000.0,v3.getEndLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(2000.0,v3.getEndLocationCoordinate().getY(),0.01);
|
assertEquals(2000.0,v3.getEndLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -351,8 +351,8 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
||||||
assertEquals(10.0,v3.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(10.0,v3.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(100.0,v3.getStartLocationCoordinate().getY(),0.01);
|
assertEquals(100.0,v3.getStartLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -361,8 +361,8 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
||||||
assertEquals(10.0,v3.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(10.0,v3.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(100.0,v3.getStartLocationCoordinate().getY(),0.01);
|
assertEquals(100.0,v3.getStartLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -371,7 +371,7 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
||||||
assertEquals("startLoc",v3.getStartLocationId());
|
assertEquals("startLoc",v3.getStartLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -380,7 +380,7 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
||||||
assertEquals("startLoc",v.getStartLocationId());
|
assertEquals("startLoc",v.getStartLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -389,7 +389,7 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
||||||
assertEquals("endLoc",v.getEndLocationId());
|
assertEquals("endLoc",v.getEndLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -398,8 +398,8 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
||||||
assertEquals(1000.0,v.getEndLocationCoordinate().getX(),0.01);
|
assertEquals(1000.0,v.getEndLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(2000.0,v.getEndLocationCoordinate().getY(),0.01);
|
assertEquals(2000.0,v.getEndLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -408,8 +408,8 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
||||||
assertEquals(10.0,v.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(10.0,v.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(100.0,v.getStartLocationCoordinate().getY(),0.01);
|
assertEquals(100.0,v.getStartLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -418,8 +418,8 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
||||||
assertEquals(10.0,v.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(10.0,v.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(100.0,v.getStartLocationCoordinate().getY(),0.01);
|
assertEquals(100.0,v.getStartLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -428,7 +428,7 @@ public class VrpXMLReaderTest {
|
||||||
new VrpXMLReader(builder, null).read(inFileName);
|
new VrpXMLReader(builder, null).read(inFileName);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
Vehicle v = getVehicle("v4",vrp.getVehicles());
|
||||||
assertEquals("startLoc",v.getStartLocationId());
|
assertEquals("startLoc",v.getStartLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,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(Location.Builder.newInstance().setId("pLoc").build()).setDeliveryLocationId("dLoc").build();
|
.setPickupLocation(Location.Builder.newInstance().setId("pLoc").build()).setDeliveryLocation(Location.newInstance("dLoc")).build();
|
||||||
TourActivity act = factory.createPickup(shipment);
|
TourActivity act = factory.createPickup(shipment);
|
||||||
assertNotNull(act);
|
assertNotNull(act);
|
||||||
assertTrue(act instanceof PickupShipment);
|
assertTrue(act instanceof PickupShipment);
|
||||||
|
|
@ -39,7 +39,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(Location.Builder.newInstance().setId("pLoc").build()).setDeliveryLocationId("dLoc").build();
|
.setPickupLocation(Location.Builder.newInstance().setId("pLoc").build()).setDeliveryLocation(Location.newInstance("dLoc")).build();
|
||||||
TourActivity act = factory.createDelivery(shipment);
|
TourActivity act = factory.createDelivery(shipment);
|
||||||
assertNotNull(act);
|
assertNotNull(act);
|
||||||
assertTrue(act instanceof DeliverShipment);
|
assertTrue(act instanceof DeliverShipment);
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,12 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class DeliverShipmentTest {
|
public class DeliverShipmentTest {
|
||||||
|
|
||||||
private Shipment shipment;
|
|
||||||
|
|
||||||
private DeliverShipment deliver;
|
private DeliverShipment deliver;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
shipment = Shipment.Builder.newInstance("shipment").setPickupLocation(Location.Builder.newInstance().setId("pickupLoc").build())
|
Shipment shipment = Shipment.Builder.newInstance("shipment").setPickupLocation(Location.Builder.newInstance().setId("pickupLoc").build())
|
||||||
.setDeliveryLocationId("deliveryLoc")
|
.setDeliveryLocation(Location.newInstance("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();
|
||||||
|
|
@ -89,7 +87,7 @@ public class DeliverShipmentTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc")
|
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocation(Location.newInstance("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));
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,13 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class PickupShipmentTest {
|
public class PickupShipmentTest {
|
||||||
|
|
||||||
private Shipment shipment;
|
|
||||||
|
|
||||||
private PickupShipment pickup;
|
private PickupShipment pickup;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
shipment = Shipment.Builder.newInstance("shipment").setPickupLocation(Location.Builder.newInstance().setId("pickupLoc").build())
|
Shipment shipment = Shipment.Builder.newInstance("shipment").setPickupLocation(Location.Builder.newInstance().setId("pickupLoc").build())
|
||||||
.setDeliveryLocationId("deliveryLoc")
|
.setDeliveryLocation(Location.newInstance("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();
|
||||||
|
|
@ -89,7 +87,7 @@ public class PickupShipmentTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc")
|
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocation(Location.newInstance("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));
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@
|
||||||
package jsprit.core.problem.vehicle;
|
package jsprit.core.problem.vehicle;
|
||||||
|
|
||||||
|
|
||||||
import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.util.Coordinate;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -38,159 +37,158 @@ public class VehicleImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenVehicleIsBuiltToReturnToDepot_itShouldReturnToDepot(){
|
public void whenVehicleIsBuiltToReturnToDepot_itShouldReturnToDepot(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(true).setStartLocationId("loc").build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(true).setStartLocation(Location.newInstance("loc")).build();
|
||||||
assertTrue(v.isReturnToDepot());
|
assertTrue(v.isReturnToDepot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenVehicleIsBuiltToNotReturnToDepot_itShouldNotReturnToDepot(){
|
public void whenVehicleIsBuiltToNotReturnToDepot_itShouldNotReturnToDepot(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(false).setStartLocationId("loc").build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(false).setStartLocation(Location.newInstance("loc")).build();
|
||||||
assertFalse(v.isReturnToDepot());
|
assertFalse(v.isReturnToDepot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenVehicleIsBuiltWithLocation_itShouldHvTheCorrectLocation(){
|
public void whenVehicleIsBuiltWithLocation_itShouldHvTheCorrectLocation(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
|
||||||
assertEquals("loc",v.getStartLocationId());
|
assertEquals("loc",v.getStartLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenVehicleIsBuiltWithCoord_itShouldHvTheCorrectCoord(){
|
public void whenVehicleIsBuiltWithCoord_itShouldHvTheCorrectCoord(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1, 2)).build();
|
||||||
assertEquals(1.0,v.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(1.0,v.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(2.0,v.getStartLocationCoordinate().getY(),0.01);
|
assertEquals(2.0,v.getStartLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenVehicleIsBuiltAndEarliestStartIsNotSet_itShouldSetTheDefaultOfZero(){
|
public void whenVehicleIsBuiltAndEarliestStartIsNotSet_itShouldSetTheDefaultOfZero(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1, 2)).build();
|
||||||
assertEquals(0.0,v.getEarliestDeparture(),0.01);
|
assertEquals(0.0,v.getEarliestDeparture(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenVehicleIsBuiltAndEarliestStartSet_itShouldBeSetCorrectly(){
|
public void whenVehicleIsBuiltAndEarliestStartSet_itShouldBeSetCorrectly(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setEarliestStart(10.0).setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setEarliestStart(10.0).setStartLocation(Location.newInstance(1, 2)).build();
|
||||||
assertEquals(10.0,v.getEarliestDeparture(),0.01);
|
assertEquals(10.0,v.getEarliestDeparture(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenVehicleIsBuiltAndLatestArrivalIsNotSet_itShouldSetDefaultOfDoubleMaxValue(){
|
public void whenVehicleIsBuiltAndLatestArrivalIsNotSet_itShouldSetDefaultOfDoubleMaxValue(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1, 2)).build();
|
||||||
assertEquals(Double.MAX_VALUE,v.getLatestArrival(),0.01);
|
assertEquals(Double.MAX_VALUE,v.getLatestArrival(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenVehicleIsBuiltAndLatestArrivalIsSet_itShouldBeSetCorrectly(){
|
public void whenVehicleIsBuiltAndLatestArrivalIsSet_itShouldBeSetCorrectly(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setLatestArrival(30.0).setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setLatestArrival(30.0).setStartLocation(Location.newInstance(1, 2)).build();
|
||||||
assertEquals(30.0,v.getLatestArrival(),0.01);
|
assertEquals(30.0,v.getLatestArrival(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenNoVehicleIsCreate_itShouldHvTheCorrectId(){
|
public void whenNoVehicleIsCreate_itShouldHvTheCorrectId(){
|
||||||
Vehicle v = VehicleImpl.createNoVehicle();
|
Vehicle v = VehicleImpl.createNoVehicle();
|
||||||
assertTrue(v instanceof NoVehicle);
|
|
||||||
assertEquals("noVehicle",v.getId());
|
assertEquals("noVehicle",v.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenStartLocationIsSet_itIsDoneCorrectly(){
|
public void whenStartLocationIsSet_itIsDoneCorrectly(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("startLoc")).build();
|
||||||
assertEquals("startLoc", v.getStartLocationId());
|
assertEquals("startLoc", v.getStartLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void whenStartLocationIsNull_itThrowsException(){
|
public void whenStartLocationIsNull_itThrowsException(){
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId(null).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(null)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenStartLocationCoordIsSet_itIsDoneCorrectly(){
|
public void whenStartLocationCoordIsSet_itIsDoneCorrectly(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1, 2)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1, 2)).build();
|
||||||
assertEquals(1.0, v.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(1.0, v.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(2.0, v.getStartLocationCoordinate().getY(),0.01);
|
assertEquals(2.0, v.getStartLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenEndLocationIsSet_itIsDoneCorrectly(){
|
public void whenEndLocationIsSet_itIsDoneCorrectly(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").setEndLocationId("endLoc").build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("startLoc")).setEndLocation(Location.newInstance("endLoc")).build();
|
||||||
assertEquals("startLoc", v.getStartLocationId());
|
assertEquals("startLoc", v.getStartLocation().getId());
|
||||||
assertEquals("endLoc", v.getEndLocationId());
|
assertEquals("endLoc", v.getEndLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenEndLocationCoordIsSet_itIsDoneCorrectly(){
|
public void whenEndLocationCoordIsSet_itIsDoneCorrectly(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").setEndLocationCoordinate(Coordinate.newInstance(1, 2)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("startLoc")).setEndLocation(Location.newInstance(1, 2)).build();
|
||||||
assertEquals(1.0, v.getEndLocationCoordinate().getX(),0.01);
|
assertEquals(1.0, v.getEndLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(2.0, v.getEndLocationCoordinate().getY(),0.01);
|
assertEquals(2.0, v.getEndLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenNeitherEndLocationIdNorEndLocationCoordAreSet_endLocationIdMustBeEqualToStartLocationId(){
|
public void whenNeitherEndLocationIdNorEndLocationCoordAreSet_endLocationIdMustBeEqualToStartLocationId(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("startLoc")).build();
|
||||||
assertEquals("startLoc", v.getEndLocationId());
|
assertEquals("startLoc", v.getEndLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenNeitherEndLocationIdNorEndLocationCoordAreSet_endLocationCoordMustBeEqualToStartLocationCoord(){
|
public void whenNeitherEndLocationIdNorEndLocationCoordAreSet_endLocationCoordMustBeEqualToStartLocationCoord(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("startLoc")).build();
|
||||||
assertEquals(v.getEndLocationCoordinate(), v.getStartLocationCoordinate());
|
assertEquals(v.getEndLocation().getCoordinate(), v.getStartLocation().getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenNeitherEndLocationIdNorEndLocationCoordAreSet_endLocationCoordMustBeEqualToStartLocationCoordV2(){
|
public void whenNeitherEndLocationIdNorEndLocationCoordAreSet_endLocationCoordMustBeEqualToStartLocationCoordV2(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1.0, 2.0)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1.0, 2.0)).build();
|
||||||
assertEquals(v.getEndLocationCoordinate(), v.getStartLocationCoordinate());
|
assertEquals(v.getEndLocation().getCoordinate(), v.getStartLocation().getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenEndLocationCoordinateIsSetButNoId_idMustBeCoordToString(){
|
public void whenEndLocationCoordinateIsSetButNoId_idMustBeCoordToString(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1.0, 2.0)).setEndLocationCoordinate(Coordinate.newInstance(3.0, 4.0)).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1.0, 2.0)).setEndLocation(Location.newInstance(3.0, 4.0)).build();
|
||||||
assertEquals(v.getEndLocationCoordinate().toString(), v.getEndLocationId());
|
assertEquals(v.getEndLocation().getCoordinate().toString(), v.getEndLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void whenEndLocationIdIsSpecifiedANDReturnToDepotIsFalse_itShouldThrowException(){
|
public void whenEndLocationIdIsSpecifiedANDReturnToDepotIsFalse_itShouldThrowException(){
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1.0, 2.0)).setEndLocationId("endLoc").setReturnToDepot(false).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1.0, 2.0)).setEndLocation(Location.newInstance("endLoc")).setReturnToDepot(false).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void whenEndLocationCoordIsSpecifiedANDReturnToDepotIsFalse_itShouldThrowException(){
|
public void whenEndLocationCoordIsSpecifiedANDReturnToDepotIsFalse_itShouldThrowException(){
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1.0, 2.0)).setEndLocationCoordinate(Coordinate.newInstance(3, 4)).setReturnToDepot(false).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1.0, 2.0)).setEndLocation(Location.newInstance(3, 4)).setReturnToDepot(false).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenEndLocationCoordIsNotSpecifiedANDReturnToDepotIsFalse_endLocationCoordMustBeStartLocationCoord(){
|
public void whenEndLocationCoordIsNotSpecifiedANDReturnToDepotIsFalse_endLocationCoordMustBeStartLocationCoord(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1.0, 2.0)).setReturnToDepot(false).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1.0, 2.0)).setReturnToDepot(false).build();
|
||||||
assertEquals(v.getStartLocationCoordinate(),v.getEndLocationCoordinate());
|
assertEquals(v.getStartLocation().getCoordinate(),v.getEndLocation().getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenEndLocationIdIsNotSpecifiedANDReturnToDepotIsFalse_endLocationIdMustBeStartLocationId(){
|
public void whenEndLocationIdIsNotSpecifiedANDReturnToDepotIsFalse_endLocationIdMustBeStartLocationId(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(1.0, 2.0)).setReturnToDepot(false).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1.0, 2.0)).setReturnToDepot(false).build();
|
||||||
assertEquals(v.getStartLocationCoordinate().toString(),v.getEndLocationId());
|
assertEquals(v.getStartLocation().getCoordinate().toString(),v.getEndLocation().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void whenStartAndEndAreUnequalANDReturnToDepotIsFalse_itShouldThrowException(){
|
public void whenStartAndEndAreUnequalANDReturnToDepotIsFalse_itShouldThrowException(){
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").setReturnToDepot(false).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setEndLocation(Location.newInstance("end")).setReturnToDepot(false).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenStartAndEndAreEqualANDReturnToDepotIsFalse_itShouldThrowException(){
|
public void whenStartAndEndAreEqualANDReturnToDepotIsFalse_itShouldThrowException(){
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").setReturnToDepot(false).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setEndLocation(Location.newInstance("start")).setReturnToDepot(false).build();
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenTwoVehiclesHaveTheSameId_theyShouldBeEqual(){
|
public void whenTwoVehiclesHaveTheSameId_theyShouldBeEqual(){
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").setReturnToDepot(false).build();
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setEndLocation(Location.newInstance("start")).setReturnToDepot(false).build();
|
||||||
Vehicle v2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").setReturnToDepot(false).build();
|
Vehicle v2 = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setEndLocation(Location.newInstance("start")).setReturnToDepot(false).build();
|
||||||
assertTrue(v.equals(v2));
|
assertTrue(v.equals(v2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,7 +196,7 @@ public class VehicleImplTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenAddingSkills_theyShouldBeAddedCorrectly(){
|
public void whenAddingSkills_theyShouldBeAddedCorrectly(){
|
||||||
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build();
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setType(type1).setEndLocationId("start")
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setType(type1).setEndLocation(Location.newInstance("start"))
|
||||||
.addSkill("drill").addSkill("screwdriver").build();
|
.addSkill("drill").addSkill("screwdriver").build();
|
||||||
assertTrue(v.getSkills().containsSkill("drill"));
|
assertTrue(v.getSkills().containsSkill("drill"));
|
||||||
assertTrue(v.getSkills().containsSkill("drill"));
|
assertTrue(v.getSkills().containsSkill("drill"));
|
||||||
|
|
@ -208,7 +206,7 @@ public class VehicleImplTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenAddingSkillsCaseSens_theyShouldBeAddedCorrectly(){
|
public void whenAddingSkillsCaseSens_theyShouldBeAddedCorrectly(){
|
||||||
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build();
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setType(type1).setEndLocationId("start")
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setType(type1).setEndLocation(Location.newInstance("start"))
|
||||||
.addSkill("drill").addSkill("screwdriver").build();
|
.addSkill("drill").addSkill("screwdriver").build();
|
||||||
assertTrue(v.getSkills().containsSkill("drill"));
|
assertTrue(v.getSkills().containsSkill("drill"));
|
||||||
assertTrue(v.getSkills().containsSkill("dRill"));
|
assertTrue(v.getSkills().containsSkill("dRill"));
|
||||||
|
|
@ -218,7 +216,7 @@ public class VehicleImplTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly(){
|
public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly(){
|
||||||
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build();
|
||||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setType(type1).setEndLocationId("start")
|
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setType(type1).setEndLocation(Location.newInstance("start"))
|
||||||
.addSkill("drill").build();
|
.addSkill("drill").build();
|
||||||
assertFalse(v.getSkills().containsSkill("ScrewDriver"));
|
assertFalse(v.getSkills().containsSkill("ScrewDriver"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,30 +16,37 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.instance.reader;
|
package jsprit.instance.reader;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||||
import jsprit.core.problem.job.Service;
|
import jsprit.core.problem.job.Service;
|
||||||
import jsprit.core.problem.vehicle.Vehicle;
|
import jsprit.core.problem.vehicle.Vehicle;
|
||||||
import jsprit.instance.reader.ChristofidesReader;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class ChristophidesReaderTest {
|
public class ChristophidesReaderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_nuOfCustomersIsCorrect(){
|
public void whenReadingInstance_nuOfCustomersIsCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new ChristofidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(50,vrp.getJobs().values().size());
|
assertEquals(50,vrp.getJobs().values().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPath(String string) {
|
||||||
|
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||||
|
if(resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||||
|
return resource.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_fleetSizeIsInfinite(){
|
public void whenReadingInstance_fleetSizeIsInfinite(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new ChristofidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +54,7 @@ public class ChristophidesReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_vehicleCapacitiesAreCorrect(){
|
public void whenReadingInstance_vehicleCapacitiesAreCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new ChristofidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
assertEquals(160,v.getType().getCapacityDimensions().get(0));
|
assertEquals(160,v.getType().getCapacityDimensions().get(0));
|
||||||
|
|
@ -57,18 +64,18 @@ public class ChristophidesReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation(){
|
public void whenReadingInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new ChristofidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
assertEquals(30.0,v.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(30.0,v.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(40.0,v.getStartLocationCoordinate().getY(),0.01);
|
assertEquals(40.0,v.getStartLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_vehicleDurationsAreCorrect(){
|
public void whenReadingInstance_vehicleDurationsAreCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new ChristofidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc13.txt").getPath());
|
new ChristofidesReader(builder).read(getPath("vrpnc13.txt"));
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
assertEquals(0.0,v.getEarliestDeparture(),0.01);
|
assertEquals(0.0,v.getEarliestDeparture(),0.01);
|
||||||
|
|
@ -79,7 +86,7 @@ public class ChristophidesReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_demandOfCustomerOneIsCorrect(){
|
public void whenReadingInstance_demandOfCustomerOneIsCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new ChristofidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(7,vrp.getJobs().get("1").getSize().get(0));
|
assertEquals(7,vrp.getJobs().get("1").getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +94,7 @@ public class ChristophidesReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_serviceDurationOfCustomerTwoIsCorrect(){
|
public void whenReadingInstance_serviceDurationOfCustomerTwoIsCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new ChristofidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc13.txt").getPath());
|
new ChristofidesReader(builder).read(getPath("vrpnc13.txt"));
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(50.0,((Service)vrp.getJobs().get("2")).getServiceDuration(),0.1);
|
assertEquals(50.0,((Service)vrp.getJobs().get("2")).getServiceDuration(),0.1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ import jsprit.core.problem.job.Service;
|
||||||
import jsprit.core.problem.vehicle.Vehicle;
|
import jsprit.core.problem.vehicle.Vehicle;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
@ -31,15 +33,21 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCordeauReader(){
|
public void testCordeauReader(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
vrpBuilder.build();
|
vrpBuilder.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPath(String string) {
|
||||||
|
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||||
|
if(resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||||
|
return resource.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_fleetSizeIsFinite(){
|
public void whenReadingInstance_fleetSizeIsFinite(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
assertEquals(FleetSize.FINITE, vrp.getFleetSize());
|
assertEquals(FleetSize.FINITE, vrp.getFleetSize());
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +55,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testNuOfVehicles(){
|
public void testNuOfVehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
|
|
||||||
assertEquals(16,vrp.getVehicles().size());
|
assertEquals(16,vrp.getVehicles().size());
|
||||||
|
|
@ -56,7 +64,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectCapacity(){
|
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectCapacity(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
assertEquals(80, v.getType().getCapacityDimensions().get(0));
|
assertEquals(80, v.getType().getCapacityDimensions().get(0));
|
||||||
|
|
@ -66,7 +74,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectDuration(){
|
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectDuration(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p08").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p08"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
assertEquals(0.0,v.getEarliestDeparture(),0.1);
|
assertEquals(0.0,v.getEarliestDeparture(),0.1);
|
||||||
|
|
@ -77,7 +85,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingCustomersCordeauInstance_customerOneShouldHaveCorrectCoordinates(){
|
public void whenReadingCustomersCordeauInstance_customerOneShouldHaveCorrectCoordinates(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Service service = (Service) vrp.getJobs().get("1");
|
Service service = (Service) vrp.getJobs().get("1");
|
||||||
assertEquals(37.0, service.getLocation().getCoordinate().getX(), 0.1);
|
assertEquals(37.0, service.getLocation().getCoordinate().getX(), 0.1);
|
||||||
|
|
@ -87,7 +95,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingCustomersCordeauInstance_customerTwoShouldHaveCorrectServiceDuration(){
|
public void whenReadingCustomersCordeauInstance_customerTwoShouldHaveCorrectServiceDuration(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Service service = (Service) vrp.getJobs().get("2");
|
Service service = (Service) vrp.getJobs().get("2");
|
||||||
assertEquals(0.0, service.getServiceDuration(), 0.1);
|
assertEquals(0.0, service.getServiceDuration(), 0.1);
|
||||||
|
|
@ -96,7 +104,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingCustomersCordeauInstance_customerThreeShouldHaveCorrectDemand(){
|
public void whenReadingCustomersCordeauInstance_customerThreeShouldHaveCorrectDemand(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Service service = (Service) vrp.getJobs().get("3");
|
Service service = (Service) vrp.getJobs().get("3");
|
||||||
assertEquals(16.0, service.getSize().get(0), 0.1);
|
assertEquals(16.0, service.getSize().get(0), 0.1);
|
||||||
|
|
@ -105,7 +113,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingCustomersCordeauInstance_customerFortySevenShouldHaveCorrectDemand(){
|
public void whenReadingCustomersCordeauInstance_customerFortySevenShouldHaveCorrectDemand(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Service service = (Service) vrp.getJobs().get("47");
|
Service service = (Service) vrp.getJobs().get("47");
|
||||||
assertEquals(25.0, service.getSize().get(0), 0.1);
|
assertEquals(25.0, service.getSize().get(0), 0.1);
|
||||||
|
|
@ -114,7 +122,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLocationsAndCapOfVehicles(){
|
public void testLocationsAndCapOfVehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
boolean capacityOk = true;
|
boolean capacityOk = true;
|
||||||
boolean loc1ok = false;
|
boolean loc1ok = false;
|
||||||
|
|
@ -123,10 +131,10 @@ public class CordeauReaderTest {
|
||||||
boolean loc4ok = false;
|
boolean loc4ok = false;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
if(v.getType().getCapacityDimensions().get(0) != 80) capacityOk = false;
|
if(v.getType().getCapacityDimensions().get(0) != 80) capacityOk = false;
|
||||||
if(v.getStartLocationCoordinate().getX() == 20.0 && v.getStartLocationCoordinate().getY() == 20.0) loc1ok = true;
|
if(v.getStartLocation().getCoordinate().getX() == 20.0 && v.getStartLocation().getCoordinate().getY() == 20.0) loc1ok = true;
|
||||||
if(v.getStartLocationCoordinate().getX() == 30.0 && v.getStartLocationCoordinate().getY() == 40.0) loc2ok = true;
|
if(v.getStartLocation().getCoordinate().getX() == 30.0 && v.getStartLocation().getCoordinate().getY() == 40.0) loc2ok = true;
|
||||||
if(v.getStartLocationCoordinate().getX() == 50.0 && v.getStartLocationCoordinate().getY() == 30.0) loc3ok = true;
|
if(v.getStartLocation().getCoordinate().getX() == 50.0 && v.getStartLocation().getCoordinate().getY() == 30.0) loc3ok = true;
|
||||||
if(v.getStartLocationCoordinate().getX() == 60.0 && v.getStartLocationCoordinate().getY() == 50.0) loc4ok = true;
|
if(v.getStartLocation().getCoordinate().getX() == 60.0 && v.getStartLocation().getCoordinate().getY() == 50.0) loc4ok = true;
|
||||||
}
|
}
|
||||||
assertTrue(capacityOk);
|
assertTrue(capacityOk);
|
||||||
assertTrue(loc1ok);
|
assertTrue(loc1ok);
|
||||||
|
|
@ -138,7 +146,7 @@ public class CordeauReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testNuOfCustomers(){
|
public void testNuOfCustomers(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
assertEquals(50,vrp.getJobs().values().size());
|
assertEquals(50,vrp.getJobs().values().size());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ import jsprit.core.util.Coordinate;
|
||||||
import jsprit.instance.reader.VrphGoldenReader.VrphType;
|
import jsprit.instance.reader.VrphGoldenReader.VrphType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class GoldenReaderTest {
|
public class GoldenReaderTest {
|
||||||
|
|
@ -33,21 +35,22 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_itShouldReadCorrectNuOfVehicles(){
|
public void whenReadingInstance_itShouldReadCorrectNuOfVehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int nuOfVehicles = 0;
|
assertEquals(17,vrp.getVehicles().size());
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
}
|
||||||
nuOfVehicles++;
|
|
||||||
|
|
||||||
}
|
private String getPath(String string) {
|
||||||
assertEquals(17,nuOfVehicles);
|
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||||
|
if(resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||||
|
return resource.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingInstance_itShouldReadCorrectNuOfType1Vehicles(){
|
public void whenReadingInstance_itShouldReadCorrectNuOfType1Vehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int nuOfType1Vehicles = 0;
|
int nuOfType1Vehicles = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -62,7 +65,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_theSumOfType1VehicleShouldHvTheCorrectCapacity(){
|
public void whenReadingInstance_theSumOfType1VehicleShouldHvTheCorrectCapacity(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int sumOfType1Cap = 0;
|
int sumOfType1Cap = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -77,7 +80,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_itShouldReadCorrectNuOfType2Vehicles(){
|
public void whenReadingInstance_itShouldReadCorrectNuOfType2Vehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int nuOfType1Vehicles = 0;
|
int nuOfType1Vehicles = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -92,7 +95,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_theSumOfType2VehicleShouldHvTheCorrectCapacity(){
|
public void whenReadingInstance_theSumOfType2VehicleShouldHvTheCorrectCapacity(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int sumOfType1Cap = 0;
|
int sumOfType1Cap = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -107,7 +110,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_itShouldReadCorrectNuOfType3Vehicles(){
|
public void whenReadingInstance_itShouldReadCorrectNuOfType3Vehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int nuOfType1Vehicles = 0;
|
int nuOfType1Vehicles = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -122,7 +125,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_theSumOfType3VehicleShouldHvTheCorrectCapacity(){
|
public void whenReadingInstance_theSumOfType3VehicleShouldHvTheCorrectCapacity(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int sumOfType1Cap = 0;
|
int sumOfType1Cap = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -137,7 +140,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_itShouldReadCorrectNuOfType4Vehicles(){
|
public void whenReadingInstance_itShouldReadCorrectNuOfType4Vehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int nuOfType1Vehicles = 0;
|
int nuOfType1Vehicles = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -152,7 +155,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_theSumOfType4VehicleShouldHvTheCorrectCapacity(){
|
public void whenReadingInstance_theSumOfType4VehicleShouldHvTheCorrectCapacity(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int sumOfType1Cap = 0;
|
int sumOfType1Cap = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -167,7 +170,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_itShouldReadCorrectNuOfType5Vehicles(){
|
public void whenReadingInstance_itShouldReadCorrectNuOfType5Vehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int nuOfType1Vehicles = 0;
|
int nuOfType1Vehicles = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -182,7 +185,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_theSumOfType5VehicleShouldHvTheCorrectCapacity(){
|
public void whenReadingInstance_theSumOfType5VehicleShouldHvTheCorrectCapacity(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int sumOfType1Cap = 0;
|
int sumOfType1Cap = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -197,7 +200,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_itShouldReadCorrectNuOfType6Vehicles(){
|
public void whenReadingInstance_itShouldReadCorrectNuOfType6Vehicles(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int nuOfType1Vehicles = 0;
|
int nuOfType1Vehicles = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -212,7 +215,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_theSumOfType6VehicleShouldHvTheCorrectCapacity(){
|
public void whenReadingInstance_theSumOfType6VehicleShouldHvTheCorrectCapacity(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
int sumOfType1Cap = 0;
|
int sumOfType1Cap = 0;
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
|
|
@ -227,13 +230,13 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_vehicleShouldHvTheCorrectCoord(){
|
public void whenReadingInstance_vehicleShouldHvTheCorrectCoord(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
if(v.getStartLocationCoordinate().getX() != 40.0){
|
if(v.getStartLocation().getCoordinate().getX() != 40.0){
|
||||||
assertFalse(true);
|
assertFalse(true);
|
||||||
}
|
}
|
||||||
if(v.getStartLocationCoordinate().getY() != 40.0){
|
if(v.getStartLocation().getCoordinate().getY() != 40.0){
|
||||||
assertFalse(true);
|
assertFalse(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -244,7 +247,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_service1MustHaveCorrectDemand(){
|
public void whenReadingInstance_service1MustHaveCorrectDemand(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Job job = getJob("1",vrp);
|
Job job = getJob("1",vrp);
|
||||||
assertEquals(18,job.getSize().get(0));
|
assertEquals(18,job.getSize().get(0));
|
||||||
|
|
@ -254,7 +257,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_service1MustHaveCorrectCoordinate(){
|
public void whenReadingInstance_service1MustHaveCorrectCoordinate(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Coordinate coord = getCoord("1",vrp);
|
Coordinate coord = getCoord("1",vrp);
|
||||||
assertEquals(22.0,coord.getX(),0.01);
|
assertEquals(22.0,coord.getX(),0.01);
|
||||||
|
|
@ -265,7 +268,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_service15MustHaveCorrectCoordinate(){
|
public void whenReadingInstance_service15MustHaveCorrectCoordinate(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Coordinate coord = getCoord("15",vrp);
|
Coordinate coord = getCoord("15",vrp);
|
||||||
assertEquals(62.0,coord.getX(),0.01);
|
assertEquals(62.0,coord.getX(),0.01);
|
||||||
|
|
@ -278,7 +281,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_service50MustHaveCorrectCoordinate(){
|
public void whenReadingInstance_service50MustHaveCorrectCoordinate(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Coordinate coord = getCoord("50",vrp);
|
Coordinate coord = getCoord("50",vrp);
|
||||||
assertEquals(15.0,coord.getX(),0.01);
|
assertEquals(15.0,coord.getX(),0.01);
|
||||||
|
|
@ -294,7 +297,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_service4MustHaveCorrectDemand(){
|
public void whenReadingInstance_service4MustHaveCorrectDemand(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Job job = getJob("4",vrp);
|
Job job = getJob("4",vrp);
|
||||||
assertEquals(30,job.getSize().get(0));
|
assertEquals(30,job.getSize().get(0));
|
||||||
|
|
@ -304,7 +307,7 @@ public class GoldenReaderTest {
|
||||||
public void whenReadingInstance_service50MustHaveCorrectDemand(){
|
public void whenReadingInstance_service50MustHaveCorrectDemand(){
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||||
.read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath());
|
.read(getPath("cn_13mix.txt"));
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
Job job = getJob("50",vrp);
|
Job job = getJob("50",vrp);
|
||||||
assertEquals(22,job.getSize().get(0));
|
assertEquals(22,job.getSize().get(0));
|
||||||
|
|
|
||||||
|
|
@ -16,30 +16,37 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.instance.reader;
|
package jsprit.instance.reader;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||||
import jsprit.core.problem.job.Service;
|
import jsprit.core.problem.job.Service;
|
||||||
import jsprit.core.problem.vehicle.Vehicle;
|
import jsprit.core.problem.vehicle.Vehicle;
|
||||||
import jsprit.instance.reader.SolomonReader;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class SolomonReaderTest {
|
public class SolomonReaderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingSolomonInstance_nuOfCustomersIsCorrect(){
|
public void whenReadingSolomonInstance_nuOfCustomersIsCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
new SolomonReader(builder).read(getPath());
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(100,vrp.getJobs().values().size());
|
assertEquals(100,vrp.getJobs().values().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPath() {
|
||||||
|
URL resource = getClass().getClassLoader().getResource("C101_solomon.txt");
|
||||||
|
if(resource == null) throw new IllegalStateException("file C101_solomon.txt does not exist");
|
||||||
|
return resource.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingSolomonInstance_fleetSizeIsInfinite(){
|
public void whenReadingSolomonInstance_fleetSizeIsInfinite(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
new SolomonReader(builder).read(getPath());
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +54,7 @@ public class SolomonReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingSolomonInstance_vehicleCapacitiesAreCorrect(){
|
public void whenReadingSolomonInstance_vehicleCapacitiesAreCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
new SolomonReader(builder).read(getPath());
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
assertEquals(200,v.getType().getCapacityDimensions().get(0));
|
assertEquals(200,v.getType().getCapacityDimensions().get(0));
|
||||||
|
|
@ -57,18 +64,18 @@ public class SolomonReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingSolomonInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation(){
|
public void whenReadingSolomonInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
new SolomonReader(builder).read(getPath());
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
for(Vehicle v : vrp.getVehicles()){
|
for(Vehicle v : vrp.getVehicles()){
|
||||||
assertEquals(40.0,v.getStartLocationCoordinate().getX(),0.01);
|
assertEquals(40.0,v.getStartLocation().getCoordinate().getX(),0.01);
|
||||||
assertEquals(50.0,v.getStartLocationCoordinate().getY(),0.01);
|
assertEquals(50.0,v.getStartLocation().getCoordinate().getY(),0.01);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingSolomonInstance_demandOfCustomerOneIsCorrect(){
|
public void whenReadingSolomonInstance_demandOfCustomerOneIsCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
new SolomonReader(builder).read(getPath());
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(10,vrp.getJobs().get("1").getSize().get(0));
|
assertEquals(10,vrp.getJobs().get("1").getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +83,7 @@ public class SolomonReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingSolomonInstance_serviceDurationOfCustomerTwoIsCorrect(){
|
public void whenReadingSolomonInstance_serviceDurationOfCustomerTwoIsCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
new SolomonReader(builder).read(getPath());
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(90,((Service)vrp.getJobs().get("2")).getServiceDuration(),0.1);
|
assertEquals(90,((Service)vrp.getJobs().get("2")).getServiceDuration(),0.1);
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +91,7 @@ public class SolomonReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingSolomonInstance_earliestServiceStartTimeOfCustomerSixtyTwoIsCorrect(){
|
public void whenReadingSolomonInstance_earliestServiceStartTimeOfCustomerSixtyTwoIsCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
new SolomonReader(builder).read(getPath());
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(262.0,((Service)vrp.getJobs().get("62")).getTimeWindow().getStart(),0.1);
|
assertEquals(262.0,((Service)vrp.getJobs().get("62")).getTimeWindow().getStart(),0.1);
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +99,7 @@ public class SolomonReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenReadingSolomonInstance_latestServiceStartTimeOfCustomerEightySevenIsCorrect(){
|
public void whenReadingSolomonInstance_latestServiceStartTimeOfCustomerEightySevenIsCorrect(){
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
new SolomonReader(builder).read(getPath());
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
assertEquals(144.0,((Service)vrp.getJobs().get("87")).getTimeWindow().getEnd(),0.1);
|
assertEquals(144.0,((Service)vrp.getJobs().get("87")).getTimeWindow().getEnd(),0.1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue