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

Compare commits

...

8 commits

Author SHA1 Message Date
oblonski
ce16a1aacf
simplify and remove redundant stuff 2019-04-10 22:31:24 +02:00
oblonski
31cd22ece0
simplify and remove redundant stuff 2019-04-10 22:30:39 +02:00
oblonski
26a9ecfdfa
simplify and remove redundant stuff 2019-04-10 22:12:59 +02:00
oblonski
fda4500302
simplify and remove redundant stuff 2019-04-10 21:55:50 +02:00
oblonski
4c49dfb589
Merge remote-tracking branch 'origin/master' 2019-04-10 21:47:40 +02:00
oblonski
d4dfa4a468
switch to jdk 1.8 2019-04-10 21:47:31 +02:00
Stefan Schröder
c11fd8d435
Update CHANGELOG.md 2019-04-10 21:44:16 +02:00
oblonski
ff8984c203
1.8-SNAPSHOT 2019-04-10 21:42:46 +02:00
28 changed files with 99 additions and 170 deletions

View file

@ -3,7 +3,6 @@ sudo: false
matrix:
fast_finish: true
include:
- jdk: openjdk7
- jdk: oraclejdk8
# Java 9 needs to be manually installed/upgraded
# see: https://github.com/travis-ci/travis-ci/issues/2968#issuecomment-149164058
@ -52,7 +51,7 @@ script:
notifications:
email:
- $EMAIL
cache:
directories:
- $HOME/.m2

View file

@ -1,5 +1,6 @@
Change-log
==========
**v1.7.3** @ 2019-04-10
**v1.7.2** @ 2017-06-08
- see [Whats new](https://github.com/graphhopper/jsprit/blob/master/WHATS_NEW.md)

View file

@ -20,7 +20,7 @@
<parent>
<groupId>com.graphhopper</groupId>
<artifactId>jsprit</artifactId>
<version>1.7.3-SNAPSHOT</version>
<version>1.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jsprit-analysis</artifactId>

View file

@ -21,7 +21,7 @@
<parent>
<groupId>com.graphhopper</groupId>
<artifactId>jsprit</artifactId>
<version>1.7.3-SNAPSHOT</version>
<version>1.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jsprit-core</artifactId>

View file

@ -406,7 +406,6 @@ public class Jsprit {
vehicleFleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
} else {
FiniteFleetManagerFactory finiteFleetManagerFactory = new FiniteFleetManagerFactory(vrp.getVehicles());
finiteFleetManagerFactory.setRandom(random);
vehicleFleetManager = finiteFleetManagerFactory.createFleetManager();
}
}

View file

@ -171,9 +171,7 @@ public class Capacity {
}
private void copy(int[] from, int[] to) {
for (int i = 0; i < dimensions.length; i++) {
to[i] = from[i];
}
System.arraycopy(from, 0, to, 0, dimensions.length);
}
/**
@ -195,7 +193,7 @@ public class Capacity {
*
* @param capacity capacity to be copied
*/
Capacity(Capacity capacity) {
private Capacity(Capacity capacity) {
this.dimensions = new int[capacity.getNuOfDimensions()];
for (int i = 0; i < capacity.getNuOfDimensions(); i++) {
this.dimensions[i] = capacity.get(i);
@ -261,11 +259,11 @@ public class Capacity {
@Override
public String toString() {
String string = "[noDimensions=" + getNuOfDimensions() + "]";
StringBuilder string = new StringBuilder("[noDimensions=" + getNuOfDimensions() + "]");
for (int i = 0; i < getNuOfDimensions(); i++) {
string += "[[dimIndex=" + i + "][dimValue=" + dimensions[i] + "]]";
string.append("[[dimIndex=").append(i).append("][dimValue=").append(dimensions[i]).append("]]");
}
return string;
return string.toString();
}
/**
@ -300,9 +298,7 @@ public class Capacity {
Capacity capacity = (Capacity) o;
if (!Arrays.equals(dimensions, capacity.dimensions)) return false;
return true;
return Arrays.equals(dimensions, capacity.dimensions);
}
@Override

View file

@ -23,6 +23,6 @@ package com.graphhopper.jsprit.core.problem;
*/
public interface HasId {
public String getId();
String getId();
}

View file

@ -23,6 +23,6 @@ package com.graphhopper.jsprit.core.problem;
*/
public interface HasIndex {
public int getIndex();
int getIndex();
}

View file

@ -27,6 +27,6 @@ import java.util.List;
*/
public interface JobActivityFactory {
public List<AbstractActivity> createActivities(Job job);
List<AbstractActivity> createActivities(Job job);
}

View file

@ -49,8 +49,8 @@ public final class Location implements HasIndex, HasId {
/**
* Factory method (and shortcut) for creating location object just with location index
*
* @param index
* @return
* @param index of location
* @return this builder
*/
public static Location newInstance(int index) {
return Location.Builder.newInstance().setIndex(index).build();
@ -92,7 +92,7 @@ public final class Location implements HasIndex, HasId {
/**
* Sets location index
*
* @param index
* @param index location index
* @return the builder
*/
public Builder setIndex(int index) {
@ -104,8 +104,8 @@ public final class Location implements HasIndex, HasId {
/**
* Sets coordinate of location
*
* @param coordinate
* @return
* @param coordinate of location
* @return this Builder
*/
public Builder setCoordinate(Coordinate coordinate) {
this.coordinate = coordinate;
@ -115,8 +115,8 @@ public final class Location implements HasIndex, HasId {
/**
* Sets location id
*
* @param id
* @return
* @param id id of location
* @return this Builder
*/
public Builder setId(String id) {
this.id = id;
@ -126,8 +126,8 @@ public final class Location implements HasIndex, HasId {
/**
* Adds name, e.g. street name, to location
*
* @param name
* @return
* @param name name of location
* @return this Builder
*/
public Builder setName(String name) {
this.name = name;
@ -198,14 +198,10 @@ public final class Location implements HasIndex, HasId {
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Location)) return false;
Location location = (Location) o;
if (index != location.index) return false;
if (coordinate != null ? !coordinate.equals(location.coordinate) : location.coordinate != null) return false;
if (id != null ? !id.equals(location.id) : location.id != null) return false;
return true;
return id != null ? id.equals(location.id) : location.id == null;
}
@Override

View file

@ -39,7 +39,7 @@ public class Skills {
return new Builder();
}
private Set<String> skills = new HashSet<String>();
private Set<String> skills = new HashSet<>();
/**
* Adds skill. Skill is transformed into lowerCase.
@ -74,7 +74,7 @@ public class Skills {
}
private Set<String> skills = new HashSet<String>();
private Set<String> skills = new HashSet<>();
private Skills(Builder builder) {
skills.addAll(builder.skills);
@ -90,16 +90,16 @@ public class Skills {
}
public String toString() {
String s = "[";
StringBuilder s = new StringBuilder("[");
boolean first = true;
for (String skill : values()) {
if (first) {
s += skill;
s.append(skill);
first = false;
} else s += ", " + skill;
} else s.append(", ").append(skill);
}
s += "]";
return s;
s.append("]");
return s.toString();
}
/**
@ -119,9 +119,7 @@ public class Skills {
Skills skills1 = (Skills) o;
if (skills != null ? !skills.equals(skills1.skills) : skills1.skills != null) return false;
return true;
return skills != null ? skills.equals(skills1.skills) : skills1.skills == null;
}
@Override

View file

@ -157,14 +157,7 @@ public class VehicleRoutingProblem {
* @return locations
*/
public Locations getLocations() {
return new Locations() {
@Override
public Coordinate getCoord(String id) {
return tentative_coordinates.get(id);
}
};
return id -> tentative_coordinates.get(id);
}
/**
@ -513,7 +506,6 @@ public class VehicleRoutingProblem {
}
private Builder addService(Service service) {
// tentative_coordinates.put(service.getLocation().getId(), service.getLocation().getCoordinate());
addLocationToTentativeLocations(service);
if (jobs.containsKey(service.getId())) {
logger.warn("The service " + service + " has already been added to job list. This overrides existing job.");
@ -579,14 +571,7 @@ public class VehicleRoutingProblem {
private int nuActivities;
private final JobActivityFactory jobActivityFactory = new JobActivityFactory() {
@Override
public List<AbstractActivity> createActivities(Job job) {
return copyAndGetActivities(job);
}
};
private final JobActivityFactory jobActivityFactory = job -> copyAndGetActivities(job);
private VehicleRoutingProblem(Builder builder) {
this.jobs = builder.jobs;

View file

@ -17,10 +17,7 @@
*/
package com.graphhopper.jsprit.core.problem.vehicle;
import com.graphhopper.jsprit.core.util.RandomNumberGeneration;
import java.util.Collection;
import java.util.Random;
/**
* Factory that creates a finite fleetmanager.
@ -31,8 +28,6 @@ public class FiniteFleetManagerFactory implements VehicleFleetManagerFactory {
private Collection<Vehicle> vehicles;
private Random random = RandomNumberGeneration.getRandom();
/**
* Constucts the factory.
*
@ -43,10 +38,6 @@ public class FiniteFleetManagerFactory implements VehicleFleetManagerFactory {
this.vehicles = vehicles;
}
public void setRandom(Random random) {
this.random = random;
}
/**
* Creates the finite fleetmanager.
*
@ -58,7 +49,6 @@ public class FiniteFleetManagerFactory implements VehicleFleetManagerFactory {
if (vehicles == null) throw new IllegalStateException("vehicles is null. this must not be.");
if (vehicles.isEmpty()) throw new IllegalStateException("vehicle-collection is empty. this must not be");
VehicleFleetManagerImpl vehicleFleetManager = new VehicleFleetManagerImpl(vehicles);
vehicleFleetManager.setRandom(random);
vehicleFleetManager.init();
return vehicleFleetManager;
}

View file

@ -32,7 +32,7 @@ public class InfiniteFleetManagerFactory implements VehicleFleetManagerFactory {
/**
* Constructs the factory.
*
* @param vehicles
* @param vehicles that are used to initialize the fleet manager
*/
public InfiniteFleetManagerFactory(Collection<Vehicle> vehicles) {
super();

View file

@ -34,11 +34,10 @@ class InfiniteVehicles implements VehicleFleetManager {
private static Logger logger = LoggerFactory.getLogger(InfiniteVehicles.class);
private Map<VehicleTypeKey, Vehicle> types = new HashMap<VehicleTypeKey, Vehicle>();
private Map<VehicleTypeKey, Vehicle> types = new HashMap<>();
// private List<VehicleTypeKey> sortedTypes = new ArrayList<VehicleTypeKey>();
public InfiniteVehicles(Collection<Vehicle> vehicles) {
InfiniteVehicles(Collection<Vehicle> vehicles) {
extractTypes(vehicles);
logger.debug("initialise " + this);
}
@ -85,7 +84,7 @@ class InfiniteVehicles implements VehicleFleetManager {
@Override
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType) {
Collection<Vehicle> vehicles = new ArrayList<Vehicle>();
Collection<Vehicle> vehicles = new ArrayList<>();
VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType.getType().getTypeId(), withoutThisType.getStartLocation().getId(), withoutThisType.getEndLocation().getId(), withoutThisType.getEarliestDeparture(), withoutThisType.getLatestArrival(), withoutThisType.getSkills(), withoutThisType.isReturnToDepot());
for (VehicleTypeKey key : types.keySet()) {
if (!key.equals(thisKey)) {

View file

@ -35,50 +35,50 @@ public interface Vehicle extends HasId, HasIndex {
*
* @return earliest departure time
*/
public abstract double getEarliestDeparture();
double getEarliestDeparture();
/**
* Returns the latest arrival time at this vehicle's end-location which should be the upper bound of this vehicle's arrival times at end-location.
*
* @return latest arrival time of this vehicle
*/
public abstract double getLatestArrival();
double getLatestArrival();
/**
* Returns the {@link VehicleType} of this vehicle.
*
* @return {@link VehicleType} of this vehicle
*/
public abstract VehicleType getType();
VehicleType getType();
/**
* Returns the id of this vehicle.
*
* @return id
*/
public abstract String getId();
String getId();
/**
* Returns true if vehicle returns to depot, false otherwise.
*
* @return true if isReturnToDepot
*/
public abstract boolean isReturnToDepot();
boolean isReturnToDepot();
public abstract Location getStartLocation();
Location getStartLocation();
public abstract Location getEndLocation();
Location getEndLocation();
public abstract VehicleTypeKey getVehicleTypeIdentifier();
VehicleTypeKey getVehicleTypeIdentifier();
public abstract Skills getSkills();
Skills getSkills();
/**
* @return User-specific domain data associated with the vehicle
*/
public Object getUserData();
Object getUserData();
public abstract Break getBreak();
Break getBreak();
// Switch to this as soon as we switct to Java 8:
// default Object getUserData() {
// return null;

View file

@ -27,31 +27,31 @@ public interface VehicleFleetManager {
* <p>
* <p>This indicates that this vehicle is being used. Thus it is not in list of available vehicles.
*
* @param vehicle
* @param vehicle to lock
*/
public abstract void lock(Vehicle vehicle);
void lock(Vehicle vehicle);
/**
* Unlocks vehicle.
* <p>
* <p>This indicates that this vehicle is not being used anymore. Thus it is in list of available vehicles.
*
* @param vehicle
* @param vehicle to unlock
*/
public abstract void unlock(Vehicle vehicle);
void unlock(Vehicle vehicle);
/**
* Returns true if locked.
*
* @param vehicle
* @return
* @param vehicle vehicle to lock
* @return true if locked
*/
public abstract boolean isLocked(Vehicle vehicle);
boolean isLocked(Vehicle vehicle);
/**
* Unlocks all locked vehicles.
*/
public abstract void unlockAll();
void unlockAll();
/**
* Returns a collection of available vehicles.
@ -61,11 +61,11 @@ public interface VehicleFleetManager {
* This is to avoid returning too many vehicles that are basically equal.
* <p>Look at {@link VehicleTypeKey} to figure out whether two vehicles are equal or not.
*
* @return
* @return collection of available vehicles
*/
public abstract Collection<Vehicle> getAvailableVehicles();
Collection<Vehicle> getAvailableVehicles();
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType);
Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType);
public Vehicle getAvailableVehicle(VehicleTypeKey vehicleTypeIdentifier);
Vehicle getAvailableVehicle(VehicleTypeKey vehicleTypeIdentifier);
}

View file

@ -19,6 +19,6 @@ package com.graphhopper.jsprit.core.problem.vehicle;
public interface VehicleFleetManagerFactory {
public VehicleFleetManager createFleetManager();
VehicleFleetManager createFleetManager();
}

View file

@ -23,7 +23,6 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
class VehicleFleetManagerImpl implements VehicleFleetManager {
@ -40,7 +39,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
TypeContainer() {
super();
vehicleList = new ArrayList<Vehicle>();
vehicleList = new ArrayList<>();
}
void add(Vehicle vehicle) {
@ -56,8 +55,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
Vehicle getVehicle() {
if(index >= vehicleList.size()) index = 0;
Vehicle vehicle = vehicleList.get(index);
return vehicle;
return vehicleList.get(index);
}
void incIndex(){
@ -80,8 +78,6 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
private Vehicle[] vehicleArr;
private Random random;
VehicleFleetManagerImpl(Collection<Vehicle> vehicles) {
super();
this.vehicles = vehicles;
@ -90,10 +86,6 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
vehicleArr = new Vehicle[arrSize];
}
void setRandom(Random random) {
this.random = random;
}
void init(){
initializeVehicleTypes();
logger.debug("initialise {}",this);
@ -142,10 +134,10 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
*/
@Override
public Collection<Vehicle> getAvailableVehicles() {
List<Vehicle> vehicles = new ArrayList<Vehicle>();
for(int i=0;i< vehicleTypes.length;i++){
if(!vehicleTypes[i].isEmpty()){
vehicles.add(vehicleTypes[i].getVehicle());
List<Vehicle> vehicles = new ArrayList<>();
for (TypeContainer vehicleType : vehicleTypes) {
if (!vehicleType.isEmpty()) {
vehicles.add(vehicleType.getVehicle());
}
}
return vehicles;
@ -153,7 +145,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
@Override
public Collection<Vehicle> getAvailableVehicles(Vehicle withoutThisType) {
List<Vehicle> vehicles = new ArrayList<Vehicle>();
List<Vehicle> vehicles = new ArrayList<>();
for(int i=0;i< vehicleTypes.length;i++){
if(!vehicleTypes[i].isEmpty() && i != withoutThisType.getVehicleTypeIdentifier().getIndex()){
vehicles.add(vehicleTypes[i].getVehicle());
@ -218,8 +210,8 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
unlock(vehicleArr[i]);
}
}
for(int i=0;i<vehicleTypes.length;i++){
vehicleTypes[i].incIndex();
for (TypeContainer vehicleType : vehicleTypes) {
vehicleType.incIndex();
}
}

View file

@ -21,8 +21,6 @@ import com.graphhopper.jsprit.core.problem.AbstractVehicle;
import com.graphhopper.jsprit.core.problem.Location;
import com.graphhopper.jsprit.core.problem.Skills;
import com.graphhopper.jsprit.core.problem.job.Break;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
@ -48,9 +46,6 @@ public class VehicleImpl extends AbstractVehicle {
private VehicleType type = VehicleTypeImpl.Builder.newInstance("noType").build();
public NoVehicle() {
}
@Override
public double getEarliestDeparture() {
return 0;
@ -110,8 +105,6 @@ public class VehicleImpl extends AbstractVehicle {
*/
public static class Builder {
static final Logger log = LoggerFactory.getLogger(Builder.class.getName());
private String id;
private double earliestStart = 0.0;
@ -143,7 +136,7 @@ public class VehicleImpl extends AbstractVehicle {
/**
* This can be used to initialize the new vehicle (to be built) with another vehicle.
*
* @param baseVehicle
* @param baseVehicle vehicle to build from
*/
private Builder(Vehicle baseVehicle) {
this.id = baseVehicle.getId();
@ -312,8 +305,8 @@ public class VehicleImpl extends AbstractVehicle {
/**
* Returns new instance of vehicle builder and initializes every attribute with a attributes of baseVehicle
*
* @param baseVehicle
* @return
* @param baseVehicle base vehicle that is used to initialize the vehicle builder
* @return this builder
*/
public static Builder newInstance(Vehicle baseVehicle) {
return new Builder(baseVehicle);
@ -333,8 +326,8 @@ public class VehicleImpl extends AbstractVehicle {
/**
* Returns a simple copy of vehicle.
*
* @param vehicle
* @return
* @param vehicle to copy
* @return copied vehicle
*/
public static Vehicle copyOf(Vehicle vehicle) {
return VehicleImpl.Builder.newInstance(vehicle).build();

View file

@ -31,38 +31,34 @@ public interface VehicleType {
*
* @return typeId
*/
public String getTypeId();
String getTypeId();
/**
* Returns capacity dimensions.
*
* @return {@link com.graphhopper.jsprit.core.problem.Capacity}
*/
public Capacity getCapacityDimensions();
Capacity getCapacityDimensions();
/**
* Returns maximum velocity of this vehicle-type.
*
* @return max velocity
*/
public double getMaxVelocity();
double getMaxVelocity();
/**
* Return the cost-parameter of this vehicle-type.
*
* @return parameter
*/
public VehicleTypeImpl.VehicleCostParams getVehicleCostParams();
VehicleTypeImpl.VehicleCostParams getVehicleCostParams();
public String getProfile();
String getProfile();
/**
* @return User-specific domain data associated with the vehicle type
*/
public Object getUserData();
Object getUserData();
// Switch to this as soon as we switct to Java 8:
// default Object getUserData() {
// return null;
// };
}

View file

@ -42,8 +42,7 @@ public class VehicleTypeImpl implements VehicleType {
}
public final double fix;
@Deprecated
public final double perTimeUnit;
public final double perTransportTimeUnit;
public final double perDistanceUnit;
public final double perWaitingTimeUnit;
@ -52,7 +51,6 @@ public class VehicleTypeImpl implements VehicleType {
private VehicleCostParams(double fix, double perTimeUnit, double perDistanceUnit) {
super();
this.fix = fix;
this.perTimeUnit = perTimeUnit;
this.perTransportTimeUnit = perTimeUnit;
this.perDistanceUnit = perDistanceUnit;
this.perWaitingTimeUnit = 0.;
@ -61,7 +59,6 @@ public class VehicleTypeImpl implements VehicleType {
public VehicleCostParams(double fix, double perTimeUnit, double perDistanceUnit, double perWaitingTimeUnit) {
this.fix = fix;
this.perTimeUnit = perTimeUnit;
this.perTransportTimeUnit = perTimeUnit;
this.perDistanceUnit = perDistanceUnit;
this.perWaitingTimeUnit = perWaitingTimeUnit;
@ -70,7 +67,6 @@ public class VehicleTypeImpl implements VehicleType {
public VehicleCostParams(double fix, double perTimeUnit, double perDistanceUnit, double perWaitingTimeUnit, double perServiceTimeUnit) {
this.fix = fix;
this.perTimeUnit = perTimeUnit;
this.perTransportTimeUnit = perTimeUnit;
this.perDistanceUnit = perDistanceUnit;
this.perWaitingTimeUnit = perWaitingTimeUnit;
@ -128,7 +124,6 @@ public class VehicleTypeImpl implements VehicleType {
}
private String id;
private int capacity = 0;
private double maxVelo = Double.MAX_VALUE;
/**
* default cost values for default vehicle type
@ -176,7 +171,7 @@ public class VehicleTypeImpl implements VehicleType {
* Sets the maximum velocity this vehicle-type can go [in meter per
* seconds].
*
* @param inMeterPerSeconds
* @param inMeterPerSeconds in m/s
* @return this builder
* @throws IllegalArgumentException
* if velocity is smaller than zero
@ -193,7 +188,7 @@ public class VehicleTypeImpl implements VehicleType {
* <p>
* <p>by default it is 0.
*
* @param fixedCost
* @param fixedCost fixed cost of vehicle type
* @return this builder
* @throws IllegalArgumentException if fixedCost is smaller than zero
*/
@ -208,7 +203,7 @@ public class VehicleTypeImpl implements VehicleType {
* <p>
* <p>by default it is 1.0
*
* @param perDistance
* @param perDistance cost per distance
* @return this builder
* @throws IllegalArgumentException if perDistance is smaller than zero
*/
@ -224,7 +219,7 @@ public class VehicleTypeImpl implements VehicleType {
* <p>
* <p>by default it is 0.0
*
* @param perTime
* @param perTime cost per time
* @return this builder
* @throws IllegalArgumentException if costPerTime is smaller than zero
* @deprecated use .setCostPerTransportTime(..) instead
@ -241,7 +236,7 @@ public class VehicleTypeImpl implements VehicleType {
* <p>
* <p>by default it is 0.0
*
* @param perTime
* @param perTime cost per time
* @return this builder
* @throws IllegalArgumentException if costPerTime is smaller than zero
*/
@ -256,7 +251,7 @@ public class VehicleTypeImpl implements VehicleType {
* <p>
* <p>by default it is 0.0
*
* @param perWaitingTime
* @param perWaitingTime cost per waiting time
* @return this builder
* @throws IllegalArgumentException if costPerTime is smaller than zero
*/
@ -286,8 +281,8 @@ public class VehicleTypeImpl implements VehicleType {
/**
* Adds a capacity dimension.
*
* @param dimIndex
* @param dimVal
* @param dimIndex dimension index
* @param dimVal dimension value
* @return the builder
* @throws IllegalArgumentException if dimVal < 0
* @throws IllegalArgumentException if capacity dimension is already set
@ -310,7 +305,7 @@ public class VehicleTypeImpl implements VehicleType {
* your dimensions with <code>addCapacityDimension(int dimIndex, int dimVal)</code> or set the already built dimensions with
* this method.
*
* @param capacity
* @param capacity capacity of vehicle type
* @return this builder
* @throws IllegalArgumentException if capacityDimension has already been added
*/
@ -358,8 +353,6 @@ public class VehicleTypeImpl implements VehicleType {
private final String typeId;
private final int capacity;
private final String profile;
private final VehicleTypeImpl.VehicleCostParams vehicleCostParams;
@ -373,12 +366,11 @@ public class VehicleTypeImpl implements VehicleType {
/**
* priv constructor constructing vehicle-type
*
* @param builder
* @param builder vehicle type builder
*/
private VehicleTypeImpl(VehicleTypeImpl.Builder builder) {
this.userData = builder.userData;
typeId = builder.id;
capacity = builder.capacity;
maxVelocity = builder.maxVelo;
vehicleCostParams = new VehicleCostParams(builder.fixedCost, builder.perTime, builder.perDistance, builder.perWaitingTime, builder.perServiceTime);
capacityDimensions = builder.capacityDimensions;

View file

@ -84,10 +84,8 @@ public class VehicleTypeKey extends AbstractVehicle.AbstractTypeKey {
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(type).append("_").append(startLocationId).append("_").append(endLocationId)
.append("_").append(Double.toString(earliestStart)).append("_").append(Double.toString(latestEnd));
return stringBuilder.toString();
return type + "_" + startLocationId + "_" + endLocationId +
"_" + Double.toString(earliestStart) + "_" + Double.toString(latestEnd);
}

View file

@ -136,11 +136,6 @@ public class VehicleTypeImplTest {
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("type").setCostPerTime(-10).build();
}
@Test
public void whenSettingPerTimeCosts_itShouldBeSetCorrectly() {
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("type").setCostPerTime(10).build();
assertEquals(10.0, type.getVehicleCostParams().perTimeUnit, 0.0);
}
@Test
public void whenHavingTwoTypesWithTheSameId_theyShouldBeEqual() {

View file

@ -20,7 +20,7 @@
<parent>
<groupId>com.graphhopper</groupId>
<artifactId>jsprit</artifactId>
<version>1.7.3-SNAPSHOT</version>
<version>1.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View file

@ -20,7 +20,7 @@
<parent>
<groupId>com.graphhopper</groupId>
<artifactId>jsprit</artifactId>
<version>1.7.3-SNAPSHOT</version>
<version>1.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View file

@ -23,7 +23,7 @@
<parent>
<groupId>com.graphhopper</groupId>
<artifactId>jsprit</artifactId>
<version>1.7.3-SNAPSHOT</version>
<version>1.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View file

@ -22,7 +22,7 @@
<groupId>com.graphhopper</groupId>
<artifactId>jsprit</artifactId>
<version>1.7.3-SNAPSHOT</version>
<version>1.8-SNAPSHOT</version>
<packaging>pom</packaging>
@ -71,7 +71,7 @@
</modules>
<properties>
<jdkVersion>1.7</jdkVersion>
<jdkVersion>1.8</jdkVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.12</junit.version>
<mockito.version>1.9.5</mockito.version>