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

remove deprecated methods dealing with old location concept

This commit is contained in:
oblonski 2015-04-22 00:43:53 +02:00
parent 917d5d3d2c
commit b3af33ccf9
22 changed files with 201 additions and 551 deletions

View file

@ -17,8 +17,6 @@
package jsprit.core.problem.job;
import jsprit.core.problem.Location;
/**
* Delivery extends Service and is intended to model a Service where smth is UNLOADED (i.e. delivered) from a transport unit.
*
@ -50,9 +48,7 @@ public class Delivery extends Service{
* @throws IllegalStateException if neither locationId nor coord is set
*/
public Delivery build(){
if(location == null) {
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
}
if(location == null) throw new IllegalStateException("location is missing");
this.setType("delivery");
super.capacity = super.capacityBuilder.build();
super.skills = super.skillBuilder.build();

View file

@ -17,8 +17,6 @@
package jsprit.core.problem.job;
import jsprit.core.problem.Location;
/**
* Pickup extends Service and is intended to model a Service where smth is LOADED (i.e. picked up) to a transport unit.
*
@ -52,9 +50,7 @@ public class Pickup extends Service {
* @throws IllegalStateException if neither locationId nor coordinate has been set
*/
public Pickup build(){
if(location == null) {
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
}
if(location == null) throw new IllegalStateException("location is missing");
this.setType("pickup");
super.capacity = super.capacityBuilder.build();
super.skills = super.skillBuilder.build();

View file

@ -100,19 +100,6 @@ public class Service extends AbstractJob {
return this;
}
/**
* Sets the location-id of this service.
*
* @param locationId the location id of the service
* @return builder
* @deprecated use .setLocation(..) instead
*/
@Deprecated
public Builder setLocationId(String locationId){
this.locationId = locationId;
return this;
}
/**
* Sets location
*
@ -124,19 +111,6 @@ public class Service extends AbstractJob {
return this;
}
/**
* Sets the coordinate of this service.
*
* @param coord the coordinate of service
* @return builder
* @deprecated use .setLocation(..) instead and add coordinate ot Location obj
*/
@Deprecated
public Builder setCoord(Coordinate coord){
this.coord = coord;
return this;
}
/**
* Sets the serviceTime of this service.
*
@ -189,9 +163,7 @@ public class Service extends AbstractJob {
* @throws IllegalStateException if neither locationId nor coordinate is set.
*/
public Service build(){
if(location == null) {
location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
}
if(location == null) throw new IllegalStateException("location is missing");
this.setType("service");
capacity = capacityBuilder.build();
skills = skillBuilder.build();
@ -242,28 +214,6 @@ public class Service extends AbstractJob {
return id;
}
/**
* Returns the location-id of this service.
*
* @return String that indicates the location
* @deprecated use .getLocation().getId() instead
*/
@Deprecated
public String getLocationId() {
return location.getId();
}
// public AbstractLocation getLocation()
/**
* Returns the coordinate of this service.
*
* @return {@link Coordinate}
* @deprecated use .getLocation().getCoordinate() instead
*/
@Deprecated
public Coordinate getCoord(){ return location.getCoordinate(); }
/**
* Returns location.
*

View file

@ -21,7 +21,7 @@ import jsprit.core.problem.Capacity;
import jsprit.core.problem.Location;
import jsprit.core.problem.Skills;
import jsprit.core.problem.solution.route.activity.TimeWindow;
import jsprit.core.util.Coordinate;
/**
* Shipment is an implementation of Job and consists of a pickup and a delivery of something.
@ -54,16 +54,8 @@ public class Shipment extends AbstractJob{
private String id;
private String pickupLocation;
private Coordinate pickupCoord;
private double pickupServiceTime = 0.0;
private String deliveryLocation;
private Coordinate deliveryCoord;
private double deliveryServiceTime = 0.0;
private TimeWindow deliveryTimeWindow = TimeWindow.newInstance(0.0, Double.MAX_VALUE);
@ -99,21 +91,6 @@ public class Shipment extends AbstractJob{
this.id = id;
}
/**
* Sets pickup-location id.
*
* @param pickupLocationId the location id of shipment's pickup
* @return builder
* @throws IllegalArgumentException if location is null
* @deprecated use .setLocation(..) instead
*/
@Deprecated
public Builder setPickupLocationId(String pickupLocationId){
if(pickupLocationId == null) throw new IllegalArgumentException("location must not be null");
this.pickupLocation = pickupLocationId;
return this;
}
/**
* Sets pickup location.
*
@ -125,36 +102,6 @@ public class Shipment extends AbstractJob{
return this;
}
/**
* Sets pickup-location id.
*
* @param pickupLocationId the location id of shipment's pickup
* @return builder
* @throws IllegalArgumentException if location is null
* @deprecated use .setPickupLocationId(locationId) instead
*/
@Deprecated
public Builder setPickupLocation(String pickupLocationId){
if(pickupLocationId == null) throw new IllegalArgumentException("location must not be null");
this.pickupLocation = pickupLocationId;
return this;
}
/**
* Sets pickup-coordinate.
*
* @param pickupCoord the coordinate of shipment's pickup location
* @return builder
* @throws IllegalArgumentException if pickupCoord is null
* @deprecated use .setLocation(..) instead and add coordinate to location obj.
*/
@Deprecated
public Builder setPickupCoord(Coordinate pickupCoord){
if(pickupCoord == null) throw new IllegalArgumentException("coord must not be null");
this.pickupCoord = pickupCoord;
return this;
}
/**
* Sets pickupServiceTime.
*
@ -186,21 +133,6 @@ public class Shipment extends AbstractJob{
return this;
}
/**
* Sets the delivery-location.
*
* @param deliveryLocationId the delivery location id
* @return builder
* @throws IllegalArgumentException if location is null
* @deprecated use .setDeliveryLocation instead
*/
@Deprecated
public Builder setDeliveryLocationId(String deliveryLocationId){
if(deliveryLocationId == null) throw new IllegalArgumentException("delivery location must not be null");
this.deliveryLocation = deliveryLocationId;
return this;
}
/**
* Sets delivery location.
*
@ -212,37 +144,6 @@ public class Shipment extends AbstractJob{
return this;
}
/**
* Sets the delivery-location.
*
* @param deliveryLocation the delivery location id
* @return builder
* @throws IllegalArgumentException if location is null
* @deprecated use .setDeliveryLocationId(deliveryLocationId)
*
*/
@Deprecated
public Builder setDeliveryLocation(String deliveryLocation){
if(deliveryLocation == null) throw new IllegalArgumentException("delivery location must not be null");
this.deliveryLocation = deliveryLocation;
return this;
}
/**
* Sets delivery-coord.
*
* @param deliveryCoord the coordinate of shipment's delivery location
* @return builder
* @throws IllegalArgumentException if coord is null;
* @deprecated use .setDeliveryLocation(..) instead and add coordinate to location obj
*/
@Deprecated
public Builder setDeliveryCoord(Coordinate deliveryCoord){
if(deliveryCoord == null) throw new IllegalArgumentException("coord must not be null");
this.deliveryCoord = deliveryCoord;
return this;
}
/**
* Sets the delivery service-time.
*
@ -297,12 +198,8 @@ public class Shipment extends AbstractJob{
* is set
*/
public Shipment build(){
if(pickupLocation_ == null) {
this.pickupLocation_ = Location.Builder.newInstance().setCoordinate(pickupCoord).setId(pickupLocation).build();
}
if(deliveryLocation_ == null) {
this.deliveryLocation_ = Location.Builder.newInstance().setCoordinate(deliveryCoord).setId(deliveryLocation).build();
}
if(pickupLocation_ == null) throw new IllegalStateException("pickup location is missing");
if(deliveryLocation_ == null) throw new IllegalStateException("delivery location is missing");
capacity = capacityBuilder.build();
skills = skillBuilder.build();
return new Shipment(this);
@ -358,28 +255,6 @@ public class Shipment extends AbstractJob{
return id;
}
/**
* Returns the pickup-location.
*
* @return pickup-location
* @deprecated use .getLocation().getId() instead
*/
@Deprecated
public String getPickupLocationId() {
return pickupLocation_.getId();
}
/**
* Returns the pickup-coordinate.
*
* @return coordinate of the pickup
* @deprecated use .getLocation(..).getCoordinate() instead
*/
@Deprecated
public Coordinate getPickupCoord() {
return pickupLocation_.getCoordinate();
}
public Location getPickupLocation(){ return pickupLocation_; }
/**
@ -393,28 +268,6 @@ public class Shipment extends AbstractJob{
return pickupServiceTime;
}
/**
* Returns delivery-location.
*
* @return delivery-location
* @deprecated use .getLocation().getId() instead
*/
@Deprecated
public String getDeliveryLocationId() {
return deliveryLocation_.getId();
}
/**
* Returns coordinate of the delivery.
*
* @return coordinate of delivery
* @deprecated use .getLocation().getCoordinate() instead
*/
@Deprecated
public Coordinate getDeliveryCoord() {
return deliveryLocation_.getCoordinate();
}
public Location getDeliveryLocation() { return deliveryLocation_; }
/**

View file

@ -20,7 +20,6 @@ import jsprit.core.problem.HasId;
import jsprit.core.problem.HasIndex;
import jsprit.core.problem.Location;
import jsprit.core.problem.Skills;
import jsprit.core.util.Coordinate;
/**
* Basic interface for vehicle-data.
@ -66,35 +65,10 @@ public interface Vehicle extends HasId, HasIndex {
*/
public abstract boolean isReturnToDepot();
/**
* Returns the start-locationId of this vehicle.
*/
@Deprecated
public abstract String getStartLocationId();
/**
* Returns the start-locationCoord of this vehicle.
*/
@Deprecated
public abstract Coordinate getStartLocationCoordinate();
public abstract Location getStartLocation();
/**
* Returns the end-locationId of this vehicle.
*
*/
@Deprecated
public abstract String getEndLocationId();
public abstract Location getEndLocation();
/**
* Returns the end-locationCoord of this vehicle.
*/
@Deprecated
public abstract Coordinate getEndLocationCoordinate();
public abstract VehicleTypeKey getVehicleTypeIdentifier();
public abstract Skills getSkills();

View file

@ -19,7 +19,6 @@ package jsprit.core.problem.vehicle;
import jsprit.core.problem.AbstractVehicle;
import jsprit.core.problem.Location;
import jsprit.core.problem.Skills;
import jsprit.core.util.Coordinate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -78,36 +77,16 @@ public class VehicleImpl extends AbstractVehicle{
return false;
}
@Override
public String getStartLocationId() {
return null;
}
@Override
public Coordinate getStartLocationCoordinate() {
return null;
}
@Override
public Location getStartLocation() {
return null;
}
@Override
public String getEndLocationId() {
return null;
}
@Override
public Location getEndLocation() {
return null;
}
@Override
public Coordinate getEndLocationCoordinate() {
return null;
}
@Override
public Skills getSkills() {
return null;
@ -130,22 +109,10 @@ public class VehicleImpl extends AbstractVehicle{
private String id;
private String locationId;
private Coordinate locationCoord;
private double earliestStart = 0.0;
private double latestArrival = Double.MAX_VALUE;
private String startLocationId;
private Coordinate startLocationCoord;
private String endLocationId;
private Coordinate endLocationCoord;
private boolean returnToDepot = true;
private VehicleType type = VehicleTypeImpl.Builder.newInstance("default").build();
@ -193,36 +160,6 @@ public class VehicleImpl extends AbstractVehicle{
return this;
}
/**
* Sets the start-location of this vehicle.
*
* @param startLocationId the location id of vehicle's start
* @return this builder
* @throws IllegalArgumentException if startLocationId is null
* @deprecated use .setStartLocation(..) instead
*/
@Deprecated
public Builder setStartLocationId(String startLocationId){
if(startLocationId == null) throw new IllegalArgumentException("startLocationId cannot be null");
this.startLocationId = startLocationId;
this.locationId = startLocationId;
return this;
}
/**
* Sets the start-coordinate of this vehicle.
*
* @param coord the coordinate of vehicle's start location
* @return this builder
* @deprecated use .setStartLocation(..) instead
*/
@Deprecated
public Builder setStartLocationCoordinate(Coordinate coord){
this.startLocationCoord = coord;
this.locationCoord = coord;
return this;
}
/**
* Sets start location.
* @param startLocation start location
@ -233,32 +170,6 @@ public class VehicleImpl extends AbstractVehicle{
return this;
}
/**
* Sets the end-locationId of this vehicle.
*
* @param endLocationId the location id of vehicle's end
* @return this builder
* @deprecated use .setEndLocation(..) instead
*/
@Deprecated
public Builder setEndLocationId(String endLocationId){
this.endLocationId = endLocationId;
return this;
}
/**
* Sets the end-coordinate of this vehicle.
*
* @param coord the coordinate of vehicle's end location
* @return this builder
* @deprecated use .setEndLocation(..) instead
*/
@Deprecated
public Builder setEndLocationCoordinate(Coordinate coord){
this.endLocationCoord = coord;
return this;
}
public Builder setEndLocation(Location endLocation){
this.endLocation = endLocation;
return this;
@ -312,30 +223,12 @@ public class VehicleImpl extends AbstractVehicle{
if( !startLocation.getId().equals(endLocation.getId()) && !returnToDepot) throw new IllegalStateException("this must not be. you specified both endLocationId and open-routes. this is contradictory. <br>" +
"if you set endLocation, returnToDepot must be true. if returnToDepot is false, endLocationCoord must not be specified.");
}
if (startLocation != null && endLocation == null && endLocationId == null && endLocationCoord == null) {
if (startLocation != null && endLocation == null) {
endLocation = startLocation;
}
if(startLocation == null && endLocation == null) {
if ((locationId == null && locationCoord == null) && (startLocationId == null && startLocationCoord == null)) {
throw new IllegalStateException("vehicle requires startLocation. but neither locationId nor locationCoord nor startLocationId nor startLocationCoord has been set");
}
if(locationId == null && locationCoord == null) throw new IllegalStateException("locationId and locationCoord is missing.");
if(locationCoord == null) log.warn("locationCoord for vehicle " + id + " is missing.");
if (locationId == null && locationCoord != null) {
locationId = locationCoord.toString();
startLocationId = locationCoord.toString();
}
startLocation = Location.Builder.newInstance().setCoordinate(locationCoord).setId(locationId).build();
if (endLocationId == null && endLocationCoord != null) endLocationId = endLocationCoord.toString();
if (endLocationId == null && endLocationCoord == null) {
endLocationId = startLocationId;
endLocationCoord = startLocationCoord;
}
endLocation = Location.Builder.newInstance().setCoordinate(endLocationCoord).setId(endLocationId).build();
if( !startLocationId.equals(endLocationId) && !returnToDepot) throw new IllegalStateException("this must not be. you specified both endLocationId and open-routes. this is contradictory. <br>" +
"if you set endLocation, returnToDepot must be true. if returnToDepot is false, endLocationCoord must not be specified.");
}
skills = skillBuilder.build();
return new VehicleImpl(this);
}
@ -433,36 +326,16 @@ public class VehicleImpl extends AbstractVehicle{
return returnToDepot;
}
@Override
public String getStartLocationId() {
return this.startLocation.getId();
}
@Override
public Coordinate getStartLocationCoordinate() {
return this.startLocation.getCoordinate();
}
@Override
public Location getStartLocation() {
return startLocation;
}
@Override
public String getEndLocationId() {
return this.endLocation.getId();
}
@Override
public Location getEndLocation() {
return endLocation;
}
@Override
public Coordinate getEndLocationCoordinate() {
return this.endLocation.getCoordinate();
}
@Override
public Skills getSkills() {
return skills;

View file

@ -1,24 +0,0 @@
/*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.core.util;
@Deprecated
public interface Neighborhood {
public boolean areNeighbors(String location1, String location2);
}

View file

@ -1,107 +0,0 @@
/*******************************************************************************
* Copyright (C) 2014 Stefan Schroeder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.core.util;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.vehicle.Vehicle;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
@Deprecated
public class NeighborhoodImpl implements Neighborhood{
private static Logger log = LogManager.getLogger(NeighborhoodImpl.class);
private Set<String> neighborsToAll;
private double threshold = Double.MAX_VALUE;
private boolean initialised = false;
public void setThreshold(double threshold) {
this.threshold = threshold;
log.info("set threshold to " + threshold);
}
private Map<String,Set<String>> neighbors;
private Collection<Vehicle> vehicles;
private Collection<Service> services;
public NeighborhoodImpl(Collection<Vehicle> vehicles, Collection<Service> services) {
neighborsToAll = new HashSet<String>();
this.vehicles = vehicles;
this.services = services;
neighbors = new HashMap<String, Set<String>>();
}
private void makeNeighbors() {
for(Service i : services){
Set<String> neigh = new HashSet<String>();
for(Vehicle v : vehicles){
double dist2depot = EuclideanDistanceCalculator.calculateDistance(v.getStartLocationCoordinate(), i.getLocation().getCoordinate());
if(dist2depot <= threshold){
neighborsToAll.add(((Service)i).getLocation().getId());
}
}
for(Service j : services){
double crowFlyDistance = EuclideanDistanceCalculator.calculateDistance(i.getLocation().getCoordinate(), j.getLocation().getCoordinate());
if(crowFlyDistance <= threshold) {
neigh.add(((Service)j).getLocation().getId());
}
}
neighbors.put(((Service)i).getLocation().getId(), neigh);
}
}
private void makeNeighborsToAll(Collection<Vehicle> vehicles) {
for(Vehicle v : vehicles){
neighborsToAll.add(v.getStartLocationId());
}
}
public void initialise(){
log.info("initialise neighboorhood [threshold="+ this.threshold + "]");
makeNeighborsToAll(vehicles);
makeNeighbors();
initialised = true;
}
public boolean areNeighbors(String location1, String location2){
if(!initialised) {
// initialise();
return true;
}
if(neighborsToAll.contains(location1) || neighborsToAll.contains(location2)){
return true;
}
if(neighbors.get(location1).contains(location2)){
return true;
}
return false;
}
@Override
public String toString() {
return "[name=euclideanNeighborhood][threshold="+threshold+"]";
}
}

View file

@ -0,0 +1,135 @@
/*******************************************************************************
* Copyright (C) 2014 Stefan Schroeder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.core.algorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.analysis.SolutionAnalyser;
import jsprit.core.problem.Location;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.cost.TransportDistance;
import jsprit.core.problem.io.VrpXMLReader;
import jsprit.core.problem.job.Job;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.problem.vehicle.VehicleImpl;
import jsprit.core.util.EuclideanDistanceCalculator;
import jsprit.core.util.FastVehicleRoutingTransportCostsMatrix;
import jsprit.core.util.Solutions;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static org.junit.Assert.*;
public class CVRPwithMatrix_IT {
private int index = 0;
@Test
public void whenReturnToDepot_itShouldWorkWithMatrix(){
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
VehicleRoutingProblem vrp_ = vrpBuilder.build();
VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_, true);
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(530.0, Solutions.bestOf(solutions).getCost(),50.0);
assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
}
@Test
public void whenNotReturnToDepot_itShouldWorkWithMatrix(){
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
VehicleRoutingProblem vrp_ = vrpBuilder.build();
VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_,false);
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
try {
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertTrue(true);
}
catch (Exception e){
assertFalse(true);
}
}
@Test
public void whenCalcTimeWithSolutionAnalyser_itShouldWork(){
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
VehicleRoutingProblem vrp_ = vrpBuilder.build();
final VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_,false);
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionAnalyser sa = new SolutionAnalyser(vrp, Solutions.bestOf(solutions), new TransportDistance() {
@Override
public double getDistance(Location from, Location to) {
return vrp.getTransportCosts().getTransportCost(from,to,0.,null,null);
}
});
System.out.println(sa.getDistance());
System.out.println(sa.getTransportTime());
}
private VehicleRoutingProblem createVrpWithLocationIndecesAndMatrix(VehicleRoutingProblem vrp_, boolean return_to_depot) {
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
List<Location> locations = new ArrayList<Location>();
for (Vehicle v : vrp_.getVehicles()) {
Location l = Location.Builder.newInstance().setIndex(getIndex()).setId(v.getStartLocation().getId())
.setCoordinate(v.getStartLocation().getCoordinate()).build();
VehicleImpl.Builder newVehicleBuilder = VehicleImpl.Builder.newInstance(v.getId()).setType(v.getType())
.setEarliestStart(v.getEarliestDeparture()).setLatestArrival(v.getLatestArrival())
.setStartLocation(l).setReturnToDepot(return_to_depot);
VehicleImpl newVehicle = newVehicleBuilder.build();
vrpBuilder.addVehicle(newVehicle);
locations.add(l);
}
for (Job j : vrp_.getJobs().values()){
Service s = (Service) j;
Location l = Location.Builder.newInstance().setIndex(getIndex())
.setId(s.getLocation().getId()).setCoordinate(s.getLocation().getCoordinate()).build();
Service newService = Service.Builder.newInstance(s.getId()).setServiceTime(s.getServiceDuration())
.addSizeDimension(0,s.getSize().get(0))
.setLocation(l).build();
vrpBuilder.addJob(newService);
locations.add(l);
}
FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(locations.size(),true);
for(Location from : locations){
for(Location to : locations){
double distance = EuclideanDistanceCalculator.calculateDistance(from.getCoordinate(), to.getCoordinate());
matrixBuilder.addTransportDistance(from.getIndex(),to.getIndex(), distance);
matrixBuilder.addTransportTime(from.getIndex(),to.getIndex(),distance);
}
}
vrpBuilder.setRoutingCost(matrixBuilder.build());
return vrpBuilder.build();
}
public int getIndex() {
int i = index;
index++;
return i;
}
}

View file

@ -114,7 +114,7 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT {
VehicleTypeImpl bigType = typeBuilder.build();
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocationId("1");
vehicleBuilder.setStartLocation(Location.newInstance("1"));
vehicleBuilder.setType(bigType);
vehicleBuilder.setLatestArrival(220);
Vehicle bigVehicle = vehicleBuilder.build();

View file

@ -114,7 +114,7 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndD
VehicleTypeImpl bigType = typeBuilder.build();
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocationId("1");
vehicleBuilder.setStartLocation(Location.newInstance("1"));
vehicleBuilder.setType(bigType);
vehicleBuilder.setLatestArrival(220);
Vehicle bigVehicle = vehicleBuilder.build();

View file

@ -94,7 +94,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
public void doBefore(){
routingCosts = CostFactory.createManhattanCosts();
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);
createInsertionCalculator(hardRouteLevelConstraint);
vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
@ -112,7 +112,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").addSizeDimension(0, 15).setLocation(Location.newInstance("0,10")).build();
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").addCapacityDimension(0, 50).setCostPerDistance(1).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(type).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("0,0")).setType(type).build();
final VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(delivery).addJob(pickup).addVehicle(vehicle).build();

View file

@ -78,10 +78,10 @@ public class TestCalculatesServiceInsertion {
public void setup(){
VehicleType t1 = VehicleTypeImpl.Builder.newInstance("t1").addCapacityDimension(0, 1000).setCostPerDistance(1.0).build();
vehicle = VehicleImpl.Builder.newInstance("vehicle").setLatestArrival(100.0).setStartLocationId("0,0").setType(t1).build();
vehicle = VehicleImpl.Builder.newInstance("vehicle").setLatestArrival(100.0).setStartLocation(Location.newInstance("0,0")).setType(t1).build();
VehicleType t2 = VehicleTypeImpl.Builder.newInstance("t2").addCapacityDimension(0, 1000).setCostPerDistance(2.0).build();
newVehicle = VehicleImpl.Builder.newInstance("newVehicle").setLatestArrival(100.0).setStartLocationId("0,0").setType(t2).build();
newVehicle = VehicleImpl.Builder.newInstance("newVehicle").setLatestArrival(100.0).setStartLocation(Location.newInstance("0,0")).setType(t2).build();
driver = DriverImpl.noDriver();

View file

@ -78,8 +78,8 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
costs = mock(VehicleRoutingTransportCosts.class);
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").addCapacityDimension(0,1000).build();
vehicle = VehicleImpl.Builder.newInstance("v1").setType(type).setStartLocationId("0,0").setLatestArrival(100.).build();
newVehicle = VehicleImpl.Builder.newInstance("v2").setType(type).setStartLocationId("0,0").setLatestArrival(100.).build();
vehicle = VehicleImpl.Builder.newInstance("v1").setType(type).setStartLocation(Location.newInstance("0,0")).setLatestArrival(100.).build();
newVehicle = VehicleImpl.Builder.newInstance("v2").setType(type).setStartLocation(Location.newInstance("0,0")).setLatestArrival(100.).build();
driver = DriverImpl.noDriver();
costs = new AbstractForwardVehicleRoutingTransportCosts() {

View file

@ -18,6 +18,7 @@ package jsprit.core.algorithm.recreate;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.problem.Location;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.Builder;
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
@ -74,7 +75,7 @@ public class TestDepartureTimeOpt {
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
Service service = Service.Builder.newInstance("s")
.setLocation(TestUtils.loc("servLoc",Coordinate.newInstance(0, 10))).setTimeWindow(timeWindow).build();
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0))
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.Builder.newInstance().setId("vehLoc").setCoordinate(Coordinate.newInstance(0, 0)).build())
.setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();

View file

@ -89,7 +89,7 @@ public class SolomonSkills_IT {
constraintManager.addSkillsConstraint();
VehicleRoutingAlgorithm vra = vraBuilder.build();
vra.setMaxIterations(500);
vra.setMaxIterations(2000);
try {
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -74,7 +74,7 @@ public class StateManagerTest {
@Test
public void whenVehicleDependentInternalRouteStateIsSet_itMustBeSetCorrectly(){
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
@ -87,7 +87,7 @@ public class StateManagerTest {
@Test
public void whenVehicleDependentInternalRouteStateIsNotSet_itMustBeSetCorrectly(){
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
@ -221,7 +221,7 @@ public class StateManagerTest {
@Test
public void whenCreatingAVehicleDependentRouteState_itShouldBeMemorized(){
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
VehicleRoute route = getRoute(vehicle);
@ -235,7 +235,7 @@ public class StateManagerTest {
@Test
public void whenCreatingAVehicleDependentActivityState_itShouldBeMemorized(){
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
@ -250,7 +250,7 @@ public class StateManagerTest {
@Test
public void whenMemorizingVehicleInfo_itShouldBeMemorized(){
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
VehicleRoute route = getRoute(vehicle);
@ -264,8 +264,8 @@ public class StateManagerTest {
@Test
public void whenMemorizingTwoVehicleInfoForRoute_itShouldBeMemorized(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").setCostPerDistance(4.).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).setType(type).build();
VehicleRoute route = getRoute(vehicle);
//getting the indices created in vrpBuilder
@ -284,8 +284,8 @@ public class StateManagerTest {
@Test
public void whenMemorizingTwoVehicleInfoForAct_itShouldBeMemorized(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").setCostPerDistance(4.).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).setType(type).build();
//getting the indices created in vrpBuilder
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
@ -306,8 +306,8 @@ public class StateManagerTest {
@Test
public void whenClearing_arrElementsShouldBeNull(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").setCostPerDistance(4.).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).setType(type).build();
//getting the indices created in vrpBuilder
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();

View file

@ -95,7 +95,7 @@ public class VehicleRouteBuilderTest {
Capacity capacity = Capacity.Builder.newInstance().build();
when(s.getSize()).thenReturn(capacity);
when(s2.getSize()).thenReturn(capacity);
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setEndLocationId("vehLoc")
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("vehLoc")).setEndLocation(Location.newInstance("vehLoc"))
.build();
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class));

View file

@ -16,6 +16,7 @@
******************************************************************************/
package jsprit.core.problem.vehicle;
import jsprit.core.problem.Location;
import org.junit.Before;
import org.junit.Test;
@ -38,8 +39,8 @@ public class TestVehicleFleetManagerImpl {
public void setUp(){
List<Vehicle> vehicles = new ArrayList<Vehicle>();
v1 = VehicleImpl.Builder.newInstance("standard").setStartLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("standard").build()).build();
v2 = VehicleImpl.Builder.newInstance("foo").setStartLocationId("fooLoc").setType(VehicleTypeImpl.Builder.newInstance("foo").build()).build();
v1 = VehicleImpl.Builder.newInstance("standard").setStartLocation(Location.newInstance("loc")).setType(VehicleTypeImpl.Builder.newInstance("standard").build()).build();
v2 = VehicleImpl.Builder.newInstance("foo").setStartLocation(Location.newInstance("fooLoc")).setType(VehicleTypeImpl.Builder.newInstance("foo").build()).build();
// v1.
vehicles.add(v1);
@ -96,7 +97,7 @@ public class TestVehicleFleetManagerImpl {
@Test
public void testWithPenalty_whenHavingOneRegularVehicleAvailable_noPenaltyVehicleIsReturn(){
Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocationId("loc").
Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocation(Location.newInstance("loc")).
setType(VehicleTypeImpl.Builder.newInstance("standard").build()).build();
List<Vehicle> vehicles = new ArrayList<Vehicle>();
@ -114,8 +115,8 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithSameTypeIdAndLocation_getAvailableVehicleShouldReturnOnlyOneOfThem(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setType(type).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setType(type).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles();
assertEquals(1,vehicles.size());
@ -124,9 +125,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithSameTypeIdStartAndEndLocationAndWorkingShift_getAvailableVehicleShouldReturnOnlyOneOfThem(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles();
@ -137,9 +138,9 @@ public class TestVehicleFleetManagerImpl {
public void whenAddingTwoVehiclesWithDifferentType_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("type2").build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type2).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles();
@ -151,9 +152,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithDifferentStartLocation_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("startloc").setEndLocationId("endLoc")
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("startLoc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles();
@ -165,9 +166,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithDifferentEndLocation_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLocation")
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLocation"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles();
@ -179,9 +180,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithDifferentEarliestStart_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(5.).setLatestArrival(10.).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles();
@ -193,9 +194,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithDifferentLatestArr_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(20.).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles();

View file

@ -1,6 +1,7 @@
package jsprit.core.problem.vehicle;
import jsprit.core.problem.Location;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
@ -10,18 +11,18 @@ public class VehicleTypeKeyTest {
@Test
public void typeIdentifierShouldBeEqual(){
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("start").addSkill("skill1").addSkill("skill2")
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("start")).addSkill("skill1").addSkill("skill2")
.addSkill("skill3").build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("start").addSkill("skill2").addSkill("skill1")
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("start")).addSkill("skill2").addSkill("skill1")
.addSkill("skill3").build();
assertTrue(v1.getVehicleTypeIdentifier().equals(v2.getVehicleTypeIdentifier()));
}
@Test
public void typeIdentifierShouldNotBeEqual(){
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("start").addSkill("skill1").addSkill("skill2")
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("start")).addSkill("skill1").addSkill("skill2")
.build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("start").addSkill("skill2").addSkill("skill1")
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("start")).addSkill("skill2").addSkill("skill1")
.addSkill("skill3").build();
assertFalse(v1.getVehicleTypeIdentifier().equals(v2.getVehicleTypeIdentifier()));
}

View file

@ -22,7 +22,6 @@ import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.solution.route.activity.TimeWindow;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.problem.vehicle.VehicleImpl;
import jsprit.core.problem.vehicle.VehicleTypeImpl;
import jsprit.core.util.Coordinate;
@ -123,8 +122,9 @@ public class LuiShenReader {
VehicleTypeImpl type = typeBuilder.build();
Vehicle reprVehicle = VehicleImpl.Builder.newInstance(vehicleId).setEarliestStart(start).setLatestArrival(end).
setStartLocationId(locationId).setStartLocationCoordinate(coord).setType(type).build();
VehicleImpl reprVehicle = VehicleImpl.Builder.newInstance(vehicleId).setEarliestStart(start).setLatestArrival(end).
setStartLocation(Location.Builder.newInstance().setId(locationId).setCoordinate(coord).build())
.setType(type).build();
vrpBuilder.addVehicle(reprVehicle);

View file

@ -159,8 +159,9 @@ public class TSPLIB95Reader {
vrpBuilder.setFleetSize(VehicleRoutingProblem.FleetSize.FINITE);
for(Integer depotId : depotIds){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0,capacity).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId(depotId.toString())
.setStartLocationCoordinate(coords[depotId - 1]).setType(type).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle")
.setStartLocation(Location.Builder.newInstance().setId(depotId.toString()).setCoordinate(coords[depotId - 1]).build())
.setType(type).build();
vrpBuilder.addVehicle(vehicle);
}