mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
Merge branch 'master' of https://github.com/graphhopper/jsprit
This commit is contained in:
commit
f5dd04329c
31 changed files with 365 additions and 1121 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -11,4 +11,5 @@
|
|||
|
||||
# Eclipse
|
||||
.project
|
||||
.classpath
|
||||
.classpath
|
||||
/.settings/
|
||||
|
|
|
|||
71
.travis.yml
71
.travis.yml
|
|
@ -1,23 +1,66 @@
|
|||
language: java
|
||||
jdk:
|
||||
- openjdk7
|
||||
- oraclejdk7
|
||||
- oraclejdk8
|
||||
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
|
||||
- jdk: oraclejdk9
|
||||
env: JVM=latest
|
||||
sudo: required
|
||||
dist: trusty
|
||||
group: edge
|
||||
allow_failures:
|
||||
- jdk: oraclejdk9
|
||||
|
||||
deploy:
|
||||
provider: script
|
||||
script: "cp .travis.settings.xml $HOME/.m2/settings.xml && mvn deploy"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
env:
|
||||
global:
|
||||
- BASEURL=https://www-eu.apache.org/dist/maven/maven-3/VERSION/binaries/apache-maven-VERSION-bin.zip
|
||||
- FILE=apache-maven-VERSION-bin.zip
|
||||
- DIR=apache-maven-VERSION
|
||||
- VERSION=3.3.9
|
||||
# - secure: "j6a61/qnfFcSjx5XxmxO2hqBOwtVx5HWrD1+4Atl7WG/pRKz9+jSga1Y7oDAFb2SIl8S65kDmPQB/vC8aHxUDj/Wizjxnxn1FhPqoe9yO6Ztft+984FKFyvj7s6tsBJKcehGec+chTOwZQpH4oI4rU6IlepDHnGLHiOd0Iviryg="
|
||||
# - secure: "GiFr+v2lTQk/sTQB7CYjju1/mupS8LSJupmizLqY454utiZkabDMBOZQnF9ukpy7WhveB9hKQyEKf9iP2w7HSYEjgvogT26vZ5f2MeLnR4SWvqEtf/WBvvh+W+k/rb2f6YgitkB4Jlxn2izemBEDuKplGJphzGW41lf8XZ2IxVI="
|
||||
|
||||
before_install:
|
||||
# update maven
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||
wget --no-check-certificate $(echo -n $BASEURL | sed -e 's#VERSION#'$VERSION'#g');
|
||||
unzip -qq $(echo -n $FILE | sed -e 's#VERSION#'$VERSION'#');
|
||||
export M2_HOME=$PWD/$(echo -n $DIR | sed -e 's#VERSION#'$VERSION'#');
|
||||
export PATH=$M2_HOME/bin:$PATH;
|
||||
fi
|
||||
# update java 9
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$JVM" == "latest" ]; then
|
||||
sudo apt-get update -qq;
|
||||
sudo /bin/echo -e oracle-java9-installer shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections;
|
||||
sudo apt-get -o Dpkg::Options::="--force-confnew" install -y oracle-java9-installer oracle-java9-set-default oracle-java9-unlimited-jce-policy;
|
||||
sudo update-java-alternatives -s java-9-oracle;
|
||||
fi
|
||||
# - if [ "$TRAVIS_JDK_VERSION" == oraclejdk9 ]; then
|
||||
# sudo rm /etc/mavenrc;
|
||||
# fi
|
||||
|
||||
# do not install anything instead return true via unix command true
|
||||
install: true
|
||||
script: mvn clean test
|
||||
|
||||
script:
|
||||
- mvn clean test verify -B
|
||||
- mvn clean package
|
||||
|
||||
notifications:
|
||||
email:
|
||||
- github@graphhopper.com
|
||||
|
||||
# enable container-based stack
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
|
||||
deploy:
|
||||
provider: script
|
||||
script: "mvn deploy --settings .travis.settings.xml -DskipTests=true -B -P selected-build"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
branch: master
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public class Skills {
|
|||
* @return true if skill is included, false otherwise
|
||||
*/
|
||||
public boolean containsSkill(String skill) {
|
||||
return skills.contains(skill.toLowerCase());
|
||||
return skills.contains(skill.trim().toLowerCase());// trim to be consistent with addSkill()
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ import com.graphhopper.jsprit.core.problem.driver.Driver;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
public abstract class AbstractForwardVehicleRoutingTransportCosts implements VehicleRoutingTransportCosts {
|
||||
|
||||
@Override
|
||||
public abstract double getDistance(Location from, Location to, double departureTime, Vehicle vehicle);
|
||||
|
||||
@Override
|
||||
public abstract double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@ package com.graphhopper.jsprit.core.problem.cost;
|
|||
* @author schroeder
|
||||
*/
|
||||
|
||||
public interface VehicleRoutingTransportCosts extends TransportTime, TransportCost {
|
||||
public interface VehicleRoutingTransportCosts extends TransportTime, TransportCost, TransportDistance {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
*/
|
||||
package com.graphhopper.jsprit.core.problem.job;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.AbstractJob;
|
||||
import com.graphhopper.jsprit.core.problem.Capacity;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
|
|
@ -28,6 +26,8 @@ import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindows;
|
|||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindowsImpl;
|
||||
import com.graphhopper.jsprit.core.util.Coordinate;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Service implementation of a job.
|
||||
* <p>
|
||||
|
|
@ -72,8 +72,6 @@ public class Service extends AbstractJob {
|
|||
|
||||
protected double serviceTime;
|
||||
|
||||
protected TimeWindow timeWindow = TimeWindow.newInstance(0.0, Double.MAX_VALUE);
|
||||
|
||||
protected Capacity.Builder capacityBuilder = Capacity.Builder.newInstance();
|
||||
|
||||
protected Capacity capacity;
|
||||
|
|
@ -93,10 +91,12 @@ public class Service extends AbstractJob {
|
|||
private int priority = 2;
|
||||
protected Object userData;
|
||||
|
||||
protected double maxTimeInVehicle = Double.MAX_VALUE;Builder(String id){
|
||||
protected double maxTimeInVehicle = Double.MAX_VALUE;
|
||||
|
||||
Builder(String id){
|
||||
this.id = id;
|
||||
timeWindows = new TimeWindowsImpl();
|
||||
timeWindows.add(timeWindow);
|
||||
timeWindows.add(TimeWindow.newInstance(0.0, Double.MAX_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -174,7 +174,6 @@ public class Service extends AbstractJob {
|
|||
|
||||
public Builder<T> setTimeWindow(TimeWindow tw){
|
||||
if(tw == null) throw new IllegalArgumentException("time-window arg must not be null");
|
||||
this.timeWindow = tw;
|
||||
this.timeWindows = new TimeWindowsImpl();
|
||||
timeWindows.add(tw);
|
||||
return this;
|
||||
|
|
@ -194,6 +193,11 @@ public class Service extends AbstractJob {
|
|||
return addTimeWindow(TimeWindow.newInstance(earliest, latest));
|
||||
}
|
||||
|
||||
public Builder<T> addAllTimeWindows(Collection<TimeWindow> timeWindows) {
|
||||
for (TimeWindow tw : timeWindows) addTimeWindow(tw);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the service.
|
||||
*
|
||||
|
|
@ -227,7 +231,7 @@ public class Service extends AbstractJob {
|
|||
|
||||
public Builder<T> addAllSizeDimensions(Capacity size){
|
||||
for(int i=0;i<size.getNuOfDimensions();i++){
|
||||
capacityBuilder.addDimension(i,size.get(i));
|
||||
addSizeDimension(i, size.get(i));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
@ -261,8 +265,6 @@ public class Service extends AbstractJob {
|
|||
|
||||
private final double serviceTime;
|
||||
|
||||
private final TimeWindow timeWindow;
|
||||
|
||||
private final Capacity size;
|
||||
|
||||
private final Skills skills;
|
||||
|
|
@ -271,7 +273,7 @@ public class Service extends AbstractJob {
|
|||
|
||||
private final Location location;
|
||||
|
||||
private final TimeWindows timeWindowManager;
|
||||
private final TimeWindows timeWindows;
|
||||
|
||||
private final int priority;
|
||||
|
||||
|
|
@ -281,18 +283,18 @@ public class Service extends AbstractJob {
|
|||
setUserData(builder.userData);
|
||||
id = builder.id;
|
||||
serviceTime = builder.serviceTime;
|
||||
timeWindow = builder.timeWindow;
|
||||
type = builder.type;
|
||||
size = builder.capacity;
|
||||
skills = builder.skills;
|
||||
name = builder.name;
|
||||
location = builder.location;
|
||||
timeWindowManager = builder.timeWindows;
|
||||
timeWindows = builder.timeWindows;
|
||||
priority = builder.priority;
|
||||
maxTimeInVehicle = builder.maxTimeInVehicle;}
|
||||
maxTimeInVehicle = builder.maxTimeInVehicle;
|
||||
}
|
||||
|
||||
public Collection<TimeWindow> getTimeWindows(){
|
||||
return timeWindowManager.getTimeWindows();
|
||||
return timeWindows.getTimeWindows();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -327,7 +329,7 @@ public class Service extends AbstractJob {
|
|||
*
|
||||
*/
|
||||
public TimeWindow getTimeWindow() {
|
||||
return timeWindowManager.getTimeWindows().iterator().next();
|
||||
return timeWindows.getTimeWindows().iterator().next();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -344,10 +346,11 @@ public class Service extends AbstractJob {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + "][name=" + name + "][type=" + type + "][location=" + location + "][capacity=" + size + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]";
|
||||
return "[id=" + id + "][name=" + name + "][type=" + type + "][location=" + location
|
||||
+ "][capacity=" + size + "][serviceTime=" + serviceTime + "][timeWindows="
|
||||
+ timeWindows + "]";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
*/
|
||||
package com.graphhopper.jsprit.core.problem.job;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.AbstractJob;
|
||||
import com.graphhopper.jsprit.core.problem.Capacity;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
|
|
@ -26,6 +24,8 @@ import com.graphhopper.jsprit.core.problem.Skills;
|
|||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindowsImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Shipment is an implementation of Job and consists of a pickup and a delivery of something.
|
||||
|
|
@ -61,10 +61,6 @@ public class Shipment extends AbstractJob {
|
|||
|
||||
private double deliveryServiceTime = 0.0;
|
||||
|
||||
private TimeWindow deliveryTimeWindow = TimeWindow.newInstance(0.0, Double.MAX_VALUE);
|
||||
|
||||
private TimeWindow pickupTimeWindow = TimeWindow.newInstance(0.0, Double.MAX_VALUE);
|
||||
|
||||
private Capacity.Builder capacityBuilder = Capacity.Builder.newInstance();
|
||||
|
||||
private Capacity capacity;
|
||||
|
|
@ -107,9 +103,9 @@ public class Shipment extends AbstractJob {
|
|||
if (id == null) throw new IllegalArgumentException("id must not be null");
|
||||
this.id = id;
|
||||
pickupTimeWindows = new TimeWindowsImpl();
|
||||
pickupTimeWindows.add(pickupTimeWindow);
|
||||
pickupTimeWindows.add(TimeWindow.newInstance(0.0, Double.MAX_VALUE));
|
||||
deliveryTimeWindows = new TimeWindowsImpl();
|
||||
deliveryTimeWindows.add(deliveryTimeWindow);
|
||||
deliveryTimeWindows.add(TimeWindow.newInstance(0.0, Double.MAX_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -169,7 +165,6 @@ public class Shipment extends AbstractJob {
|
|||
*/
|
||||
public Builder setPickupTimeWindow(TimeWindow timeWindow) {
|
||||
if (timeWindow == null) throw new IllegalArgumentException("delivery time-window must not be null");
|
||||
this.pickupTimeWindow = timeWindow;
|
||||
this.pickupTimeWindows = new TimeWindowsImpl();
|
||||
this.pickupTimeWindows.add(timeWindow);
|
||||
return this;
|
||||
|
|
@ -215,7 +210,6 @@ public class Shipment extends AbstractJob {
|
|||
*/
|
||||
public Builder setDeliveryTimeWindow(TimeWindow timeWindow) {
|
||||
if (timeWindow == null) throw new IllegalArgumentException("delivery time-window must not be null");
|
||||
this.deliveryTimeWindow = timeWindow;
|
||||
this.deliveryTimeWindows = new TimeWindowsImpl();
|
||||
this.deliveryTimeWindows.add(timeWindow);
|
||||
return this;
|
||||
|
|
@ -235,6 +229,13 @@ public class Shipment extends AbstractJob {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder addAllSizeDimensions(Capacity size) {
|
||||
for (int i = 0; i < size.getNuOfDimensions(); i++) {
|
||||
addSizeDimension(i, size.get(i));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds the shipment.
|
||||
|
|
@ -257,6 +258,13 @@ public class Shipment extends AbstractJob {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder addAllRequiredSkills(Skills skills) {
|
||||
for (String s : skills.values()) {
|
||||
addRequiredSkill(s);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
|
|
@ -277,6 +285,11 @@ public class Shipment extends AbstractJob {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder addAllDeliveryTimeWindows(Collection<TimeWindow> timeWindow) {
|
||||
for (TimeWindow tw : timeWindow) addDeliveryTimeWindow(tw);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addPickupTimeWindow(TimeWindow timeWindow) {
|
||||
if(timeWindow == null) throw new IllegalArgumentException("time-window arg must not be null");
|
||||
if(!pickupTimeWindowAdded){
|
||||
|
|
@ -291,6 +304,11 @@ public class Shipment extends AbstractJob {
|
|||
return addPickupTimeWindow(TimeWindow.newInstance(earliest, latest));
|
||||
}
|
||||
|
||||
public Builder addAllPickupTimeWindows(Collection<TimeWindow> timeWindow) {
|
||||
for (TimeWindow tw : timeWindow) addPickupTimeWindow(tw);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set priority to shipment. Only 1 (high) to 10 (low) are allowed.
|
||||
* <p>
|
||||
|
|
@ -325,10 +343,6 @@ public class Shipment extends AbstractJob {
|
|||
|
||||
private final double deliveryServiceTime;
|
||||
|
||||
private final TimeWindow deliveryTimeWindow;
|
||||
|
||||
private final TimeWindow pickupTimeWindow;
|
||||
|
||||
private final Capacity capacity;
|
||||
|
||||
private final Skills skills;
|
||||
|
|
@ -351,9 +365,7 @@ public class Shipment extends AbstractJob {
|
|||
setUserData(builder.userData);
|
||||
this.id = builder.id;
|
||||
this.pickupServiceTime = builder.pickupServiceTime;
|
||||
this.pickupTimeWindow = builder.pickupTimeWindow;
|
||||
this.deliveryServiceTime = builder.deliveryServiceTime;
|
||||
this.deliveryTimeWindow = builder.deliveryTimeWindow;
|
||||
this.capacity = builder.capacity;
|
||||
this.skills = builder.skills;
|
||||
this.name = builder.name;
|
||||
|
|
@ -424,6 +436,21 @@ public class Shipment extends AbstractJob {
|
|||
return pickupTimeWindows.getTimeWindows();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string with the shipment's attributes.
|
||||
* <p>
|
||||
* <p>String is built as follows: [attr1=val1][attr2=val2]...
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + "][name=" + name + "][pickupLocation=" + pickupLocation_
|
||||
+ "][deliveryLocation=" + deliveryLocation_ + "][capacity=" + capacity
|
||||
+ "][pickupServiceTime=" + pickupServiceTime + "][deliveryServiceTime="
|
||||
+ deliveryServiceTime + "][pickupTimeWindows=" + pickupTimeWindows
|
||||
+ "][deliveryTimeWindows=" + deliveryTimeWindows + "]";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
|
|
|||
|
|
@ -48,4 +48,12 @@ public class TimeWindowsImpl implements TimeWindows {
|
|||
return Collections.unmodifiableCollection(timeWindows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer(timeWindows.size() * 60);
|
||||
for (TimeWindow tw : timeWindows) {
|
||||
sb.append("[timeWindow=").append(tw).append("]");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ public class Coordinate {
|
|||
return new Coordinate(x, y);
|
||||
}
|
||||
|
||||
private double x;
|
||||
private final double x;
|
||||
|
||||
private double y;
|
||||
private final double y;
|
||||
|
||||
public Coordinate(double x, double y) {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package com.graphhopper.jsprit.core.util;
|
|||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.cost.AbstractForwardVehicleRoutingTransportCosts;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
|||
/**
|
||||
* @author stefan schroeder
|
||||
*/
|
||||
public class CrowFlyCosts extends AbstractForwardVehicleRoutingTransportCosts implements TransportDistance {
|
||||
public class CrowFlyCosts extends AbstractForwardVehicleRoutingTransportCosts {
|
||||
|
||||
public int speed = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package com.graphhopper.jsprit.core.util;
|
|||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.cost.AbstractForwardVehicleRoutingTransportCosts;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
|||
/**
|
||||
* @author stefan schroeder
|
||||
*/
|
||||
public class EuclideanCosts extends AbstractForwardVehicleRoutingTransportCosts implements TransportDistance {
|
||||
public class EuclideanCosts extends AbstractForwardVehicleRoutingTransportCosts {
|
||||
|
||||
public int speed = 1;
|
||||
|
||||
|
|
@ -59,14 +58,7 @@ public class EuclideanCosts extends AbstractForwardVehicleRoutingTransportCosts
|
|||
}
|
||||
|
||||
private double calculateDistance(Location fromLocation, Location toLocation) {
|
||||
Coordinate from = null;
|
||||
Coordinate to = null;
|
||||
if (fromLocation.getCoordinate() != null & toLocation.getCoordinate() != null) {
|
||||
from = fromLocation.getCoordinate();
|
||||
to = toLocation.getCoordinate();
|
||||
}
|
||||
if (from == null || to == null) throw new NullPointerException();
|
||||
return calculateDistance(from, to);
|
||||
return calculateDistance(fromLocation.getCoordinate(), toLocation.getCoordinate());
|
||||
}
|
||||
|
||||
private double calculateDistance(Coordinate from, Coordinate to) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package com.graphhopper.jsprit.core.util;
|
|||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.cost.AbstractForwardVehicleRoutingTransportCosts;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
|
|
@ -32,7 +31,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
|||
*
|
||||
* @author schroeder
|
||||
*/
|
||||
public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts implements TransportDistance {
|
||||
public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts {
|
||||
|
||||
/**
|
||||
* Builder that builds the matrix.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package com.graphhopper.jsprit.core.util;
|
|||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.cost.AbstractForwardVehicleRoutingTransportCosts;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
|
|
@ -28,7 +27,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
|||
* @author stefan schroeder
|
||||
*/
|
||||
|
||||
public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCosts implements TransportDistance {
|
||||
public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCosts {
|
||||
|
||||
private double speed = 1.;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package com.graphhopper.jsprit.core.util;
|
|||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.cost.AbstractForwardVehicleRoutingTransportCosts;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
|
|
@ -28,7 +27,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
|||
* @author stefan schroeder
|
||||
*/
|
||||
|
||||
public class ManhattanCosts extends AbstractForwardVehicleRoutingTransportCosts implements TransportDistance {
|
||||
public class ManhattanCosts extends AbstractForwardVehicleRoutingTransportCosts {
|
||||
|
||||
public double speed = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import java.util.Map;
|
|||
* @author schroeder
|
||||
*/
|
||||
public class VehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts {
|
||||
|
||||
static class RelationKey {
|
||||
|
||||
static RelationKey newKey(String from, String to) {
|
||||
|
|
@ -261,4 +262,9 @@ public class VehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRo
|
|||
return costParams.perDistanceUnit * getDistance(from.getId(), to.getId()) + costParams.perTransportTimeUnit * getTime(from.getId(), to.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return getDistance(from.getId(), to.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
|||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
|
@ -78,12 +77,7 @@ public class CVRPwithMatrix_IT {
|
|||
final VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_, false);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
SolutionAnalyser sa = new SolutionAnalyser(vrp, Solutions.bestOf(solutions), new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
|
||||
}
|
||||
});
|
||||
SolutionAnalyser sa = new SolutionAnalyser(vrp, Solutions.bestOf(solutions), vrp.getTransportCosts());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,9 @@ import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
|||
import com.graphhopper.jsprit.core.problem.Capacity;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.job.Delivery;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import com.graphhopper.jsprit.core.util.ManhattanCosts;
|
||||
|
|
@ -91,12 +89,7 @@ public class CapacityConstraint_IT {
|
|||
vra.setMaxIterations(2000);
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(vra.searchSolutions());
|
||||
|
||||
SolutionAnalyser sa = new SolutionAnalyser(vrp, solution, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return new ManhattanCosts().getDistance(from,to, 0d, null);
|
||||
}
|
||||
});
|
||||
SolutionAnalyser sa = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts());
|
||||
|
||||
for(VehicleRoute r : solution.getRoutes()){
|
||||
Capacity loadAtBeginning = sa.getLoadAtBeginning(r);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
|||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
|
|
@ -82,12 +81,7 @@ public class VariableDepartureAndWaitingTime_IT {
|
|||
.setObjectiveFunction(new SolutionCostCalculator() {
|
||||
@Override
|
||||
public double getCosts(VehicleRoutingProblemSolution solution) {
|
||||
SolutionAnalyser sa = new SolutionAnalyser(vrp, solution, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
|
||||
}
|
||||
});
|
||||
SolutionAnalyser sa = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts());
|
||||
return sa.getWaitingTime() + sa.getDistance();
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -96,6 +96,11 @@ public class TestCalculatesServiceInsertion {
|
|||
};
|
||||
costs = new AbstractForwardVehicleRoutingTransportCosts() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return ManhattanDistanceCalculator.calculateDistance(locations.getCoord(from.getId()), locations.getCoord(to.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
return ManhattanDistanceCalculator.calculateDistance(locations.getCoord(from.getId()), locations.getCoord(to.getId()));
|
||||
|
|
@ -231,6 +236,11 @@ public class TestCalculatesServiceInsertion {
|
|||
|
||||
AbstractForwardVehicleRoutingTransportCosts routingCosts = new AbstractForwardVehicleRoutingTransportCosts() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return EuclideanDistanceCalculator.calculateDistance(coords.get(from.getId()), coords.get(to.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
return getTransportCost(from, to, departureTime, driver, vehicle);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
|
|||
|
||||
costs = new AbstractForwardVehicleRoutingTransportCosts() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
VehicleRoutingTransportCosts routingCosts = CostFactory.createManhattanCosts();
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@ public class TestJobDistanceAvgCosts {
|
|||
public static void main(String[] args) {
|
||||
VehicleRoutingTransportCosts costs = new VehicleRoutingTransportCosts() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBackwardTransportTime(Location from, Location to, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
|
||||
|
|
@ -65,6 +70,11 @@ public class TestJobDistanceAvgCosts {
|
|||
// (expected=NullPointerException.class)
|
||||
VehicleRoutingTransportCosts costs = new VehicleRoutingTransportCosts() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBackwardTransportTime(Location from, Location to, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -280,6 +280,11 @@ public class VehicleRoutingProblemTest {
|
|||
|
||||
builder.setRoutingCost(new AbstractForwardVehicleRoutingTransportCosts() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransportTime(Location from, Location to,
|
||||
double departureTime, Driver driver, Vehicle vehicle) {
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ package com.graphhopper.jsprit.core.problem.constraint;
|
|||
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateId;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.VehicleDependentTraveledDistance;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.job.Delivery;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.job.Pickup;
|
||||
|
|
@ -100,13 +100,8 @@ public class VehicleDependentTraveledDistanceTest {
|
|||
|
||||
traveledDistanceId = stateManager.createStateId("traveledDistance");
|
||||
|
||||
com.graphhopper.jsprit.core.algorithm.state.VehicleDependentTraveledDistance traveledDistance =
|
||||
new com.graphhopper.jsprit.core.algorithm.state.VehicleDependentTraveledDistance(new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return new ManhattanCosts().getDistance(from, to, departureTime, vehicle);
|
||||
}
|
||||
}, stateManager, traveledDistanceId, Arrays.asList(vehicle, vehicle2));
|
||||
VehicleDependentTraveledDistance traveledDistance =
|
||||
new VehicleDependentTraveledDistance(vrp.getTransportCosts(), stateManager, traveledDistanceId, Arrays.asList(vehicle, vehicle2));
|
||||
|
||||
stateManager.addStateUpdater(traveledDistance);
|
||||
stateManager.informInsertionStarts(Arrays.asList(route), Collections.<Job>emptyList());
|
||||
|
|
@ -123,12 +118,7 @@ public class VehicleDependentTraveledDistanceTest {
|
|||
maxDistanceMap.put(vehicle, 5d);
|
||||
|
||||
MaxDistanceConstraint maxDistanceConstraint =
|
||||
new MaxDistanceConstraint(new StateManager(vrp), traveledDistanceId, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportTime(from, to, departureTime, null, vehicle);
|
||||
}
|
||||
}, maxDistanceMap);
|
||||
new MaxDistanceConstraint(new StateManager(vrp), traveledDistanceId, vrp.getTransportCosts(), maxDistanceMap);
|
||||
JobInsertionContext context = new JobInsertionContext(route, pickup, vehicle, null, 0);
|
||||
Assert.assertTrue(maxDistanceConstraint.fulfilled(context,
|
||||
new Start(vehicle.getStartLocation(), 0, Double.MAX_VALUE), vrp.getActivities(pickup).get(0),
|
||||
|
|
@ -144,12 +134,7 @@ vehicle2 (max distance): 180.0
|
|||
@Test
|
||||
public void insertNewInVehicleShouldFail() {
|
||||
MaxDistanceConstraint maxDistanceConstraint =
|
||||
new MaxDistanceConstraint(stateManager, traveledDistanceId, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportTime(from, to, departureTime, null, vehicle);
|
||||
}
|
||||
}, maxDistanceMap);
|
||||
new MaxDistanceConstraint(stateManager, traveledDistanceId, vrp.getTransportCosts(), maxDistanceMap);
|
||||
JobInsertionContext context = new JobInsertionContext(route, newDelivery, vehicle, null, 0);
|
||||
Assert.assertTrue(maxDistanceConstraint.fulfilled(context, route.getStart(), newAct(), act(0), 0).equals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED));
|
||||
Assert.assertTrue(maxDistanceConstraint.fulfilled(context, act(0), newAct(), act(1), 0).equals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED));
|
||||
|
|
@ -164,12 +149,7 @@ vehicle2 (max distance): 180.0
|
|||
public void insertNewInVehicle2ShouldBeCorrect() {
|
||||
//current distance vehicle2: 160 allowed: 200
|
||||
MaxDistanceConstraint maxDistanceConstraint =
|
||||
new MaxDistanceConstraint(stateManager, traveledDistanceId, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportTime(from, to, departureTime, null, vehicle);
|
||||
}
|
||||
}, maxDistanceMap);
|
||||
new MaxDistanceConstraint(stateManager, traveledDistanceId, vrp.getTransportCosts(), maxDistanceMap);
|
||||
JobInsertionContext context = new JobInsertionContext(route, newDelivery, vehicle2, null, 0);
|
||||
Assert.assertTrue(maxDistanceConstraint.fulfilled(context, route.getStart(), newAct(), act(0), 0).equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
|
||||
//additional distance: 20+35-15=40
|
||||
|
|
@ -284,12 +264,7 @@ vehicle2 (max distance): 180.0
|
|||
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
MaxDistanceConstraint maxDistanceConstraint =
|
||||
new MaxDistanceConstraint(stateManager, traveledDistanceId, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportTime(from, to, departureTime, null, vehicle);
|
||||
}
|
||||
}, maxDistanceMap);
|
||||
new MaxDistanceConstraint(stateManager, traveledDistanceId, vrp.getTransportCosts(), maxDistanceMap);
|
||||
Assert.assertTrue(maxDistanceConstraint.fulfilled(context,
|
||||
new Start(vehicle.getStartLocation(), 0, Double.MAX_VALUE),
|
||||
vrp.getActivities(shipment).get(0),
|
||||
|
|
@ -331,12 +306,7 @@ vehicle2 (max distance): 180.0
|
|||
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
MaxDistanceConstraint maxDistanceConstraint =
|
||||
new MaxDistanceConstraint(stateManager, traveledDistanceId, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportTime(from, to, departureTime, null, vehicle);
|
||||
}
|
||||
}, maxDistanceMap);
|
||||
new MaxDistanceConstraint(stateManager, traveledDistanceId, vrp.getTransportCosts(), maxDistanceMap);
|
||||
Assert.assertTrue(maxDistanceConstraint.fulfilled(context,
|
||||
new Start(vehicle.getStartLocation(), 0, Double.MAX_VALUE),
|
||||
vrp.getActivities(shipment).get(0),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import com.graphhopper.jsprit.core.problem.Location;
|
|||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.MaxDistanceConstraint;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
|
|
@ -122,12 +121,7 @@ public class UnassignedJobReasonTrackerTest {
|
|||
StateId maxDistance = stateManager.createStateId("max-distance");
|
||||
Map<Vehicle, Double> distMap = new HashMap<>();
|
||||
distMap.put(vehicle, 100d);
|
||||
MaxDistanceConstraint distanceConstraint = new MaxDistanceConstraint(stateManager, maxDistance, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, departureTime, null, vehicle);
|
||||
}
|
||||
}, distMap);
|
||||
MaxDistanceConstraint distanceConstraint = new MaxDistanceConstraint(stateManager, maxDistance, vrp.getTransportCosts(), distMap);
|
||||
constraintManager.addConstraint(distanceConstraint, ConstraintManager.Priority.CRITICAL);
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setStateAndConstraintManager(stateManager, constraintManager)
|
||||
|
|
|
|||
|
|
@ -34,16 +34,13 @@ import com.graphhopper.jsprit.core.algorithm.ruin.distance.AvgServiceAndShipment
|
|||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.FiniteFleetManagerFactory;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
|
|
@ -207,12 +204,7 @@ public class BuildAlgorithmFromScratch {
|
|||
|
||||
@Override
|
||||
public double getCosts(VehicleRoutingProblemSolution solution) {
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
|
||||
}
|
||||
});
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts());
|
||||
return analyser.getVariableTransportCosts() + solution.getUnassignedJobs().size() * 500.;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,8 @@ import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
|||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl.Builder;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
||||
|
|
@ -136,12 +134,7 @@ public class MultipleTimeWindowExample2 {
|
|||
*/
|
||||
new Plotter(problem,bestSolution).setLabel(Plotter.Label.ID).plot("output/plot", "mtw");
|
||||
|
||||
SolutionAnalyser a = new SolutionAnalyser(problem, bestSolution, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return problem.getTransportCosts().getTransportTime(from,to,0.,null,null);
|
||||
}
|
||||
});
|
||||
SolutionAnalyser a = new SolutionAnalyser(problem, bestSolution, problem.getTransportCosts());
|
||||
|
||||
System.out.println("distance: " + a.getDistance());
|
||||
System.out.println("ttime: " + a.getTransportTime());
|
||||
|
|
|
|||
|
|
@ -24,11 +24,8 @@ import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
|||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
|
@ -100,14 +97,7 @@ public class PickupAndDeliveryExample {
|
|||
plotter.plot("output/pd_solomon_r101_solution.png", "pd_r101");
|
||||
|
||||
//some stats
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
|
||||
}
|
||||
|
||||
});
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts());
|
||||
|
||||
System.out.println("tp_distance: " + analyser.getDistance());
|
||||
System.out.println("tp_time: " + analyser.getTransportTime());
|
||||
|
|
|
|||
|
|
@ -25,15 +25,12 @@ import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
|||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Capacity;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ServiceDeliveriesFirstConstraint;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
|
@ -125,14 +122,7 @@ public class VRPWithBackhaulsExample2 {
|
|||
// plotter.setLabel(Plotter.Label.SIZE);
|
||||
plotter.plot("output/vrpwbh_christophides_vrpnc1_solution.png", "vrpwbh_vrpnc1");
|
||||
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
|
||||
}
|
||||
|
||||
});
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts());
|
||||
|
||||
for (VehicleRoute route : solution.getRoutes()) {
|
||||
System.out.println("------");
|
||||
|
|
|
|||
|
|
@ -217,6 +217,10 @@ public class Figliozzi {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return EuclideanDistanceCalculator.calculateDistance(locations.getCoord(from.getId()), locations.getCoord(to.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
8
pom.xml
8
pom.xml
|
|
@ -202,6 +202,14 @@
|
|||
|
||||
<!-- mvn clean deploy -P release -->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>selected-build</id>
|
||||
<modules>
|
||||
<module>jsprit-core</module>
|
||||
<module>jsprit-io</module>
|
||||
<module>jsprit-analysis</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<activation>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue