mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
rename vehicleType to vehicleTypeImpl, extract interface vehicleType;
refactor vehicleType to new file; add penaltyVehicleType; improve vehicleFleetManagerImpl
This commit is contained in:
parent
d223475cb4
commit
c1849a9d5a
39 changed files with 319 additions and 572 deletions
|
|
@ -88,13 +88,13 @@ final class CalculatesServiceInsertionConsideringFixCost implements JobInsertion
|
||||||
double currentFix = 0.0;
|
double currentFix = 0.0;
|
||||||
if(route.getVehicle() != null){
|
if(route.getVehicle() != null){
|
||||||
if(!(route.getVehicle() instanceof NoVehicle)){
|
if(!(route.getVehicle() instanceof NoVehicle)){
|
||||||
currentFix += route.getVehicle().getType().vehicleCostParams.fix;
|
currentFix += route.getVehicle().getType().getVehicleCostParams().fix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(newVehicle.getCapacity() < load){
|
if(newVehicle.getCapacity() < load){
|
||||||
return Double.MAX_VALUE;
|
return Double.MAX_VALUE;
|
||||||
}
|
}
|
||||||
return newVehicle.getType().vehicleCostParams.fix - currentFix;
|
return newVehicle.getType().getVehicleCostParams().fix - currentFix;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getDeltaRelativeFixCost(VehicleRoute route, Vehicle newVehicle, Job job) {
|
private double getDeltaRelativeFixCost(VehicleRoute route, Vehicle newVehicle, Job job) {
|
||||||
|
|
@ -103,13 +103,13 @@ final class CalculatesServiceInsertionConsideringFixCost implements JobInsertion
|
||||||
double currentRelFix = 0.0;
|
double currentRelFix = 0.0;
|
||||||
if(route.getVehicle() != null){
|
if(route.getVehicle() != null){
|
||||||
if(!(route.getVehicle() instanceof NoVehicle)){
|
if(!(route.getVehicle() instanceof NoVehicle)){
|
||||||
currentRelFix += route.getVehicle().getType().vehicleCostParams.fix*currentLoad/route.getVehicle().getCapacity();
|
currentRelFix += route.getVehicle().getType().getVehicleCostParams().fix*currentLoad/route.getVehicle().getCapacity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(newVehicle.getCapacity() < load){
|
if(newVehicle.getCapacity() < load){
|
||||||
return Double.MAX_VALUE;
|
return Double.MAX_VALUE;
|
||||||
}
|
}
|
||||||
double relativeFixCost = newVehicle.getType().vehicleCostParams.fix*(load/newVehicle.getCapacity()) - currentRelFix;
|
double relativeFixCost = newVehicle.getType().getVehicleCostParams().fix*(load/newVehicle.getCapacity()) - currentRelFix;
|
||||||
return relativeFixCost;
|
return relativeFixCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ import basics.Job;
|
||||||
import basics.route.Driver;
|
import basics.route.Driver;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl.NoVehicle;
|
import basics.route.VehicleImpl.NoVehicle;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,11 @@ final class FindCheaperVehicleAlgo {
|
||||||
|
|
||||||
for(Vehicle vehicle : fleetManager.getAvailableVehicle(vehicleRoute.getVehicle().getType().getTypeId(), vehicleRoute.getVehicle().getLocationId())){
|
for(Vehicle vehicle : fleetManager.getAvailableVehicle(vehicleRoute.getVehicle().getType().getTypeId(), vehicleRoute.getVehicle().getLocationId())){
|
||||||
// Vehicle vehicle = fleetManager.getEmptyVehicle(vehicleType);
|
// Vehicle vehicle = fleetManager.getEmptyVehicle(vehicleType);
|
||||||
if(vehicle.getType().typeId.equals(vehicleRoute.getVehicle().getType().typeId)){
|
if(vehicle.getType().getTypeId().equals(vehicleRoute.getVehicle().getType().getTypeId())){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(states.getRouteState(vehicleRoute).getLoad() <= vehicle.getCapacity()){
|
if(states.getRouteState(vehicleRoute).getLoad() <= vehicle.getCapacity()){
|
||||||
double fixCostSaving = vehicleRoute.getVehicle().getType().vehicleCostParams.fix - vehicle.getType().vehicleCostParams.fix;
|
double fixCostSaving = vehicleRoute.getVehicle().getType().getVehicleCostParams().fix - vehicle.getType().getVehicleCostParams().fix;
|
||||||
double departureTime = vehicleRoute.getStart().getEndTime();
|
double departureTime = vehicleRoute.getStart().getEndTime();
|
||||||
double newCost = auxilliaryCostCalculator.costOfPath(path, departureTime, vehicleRoute.getDriver(), vehicle);
|
double newCost = auxilliaryCostCalculator.costOfPath(path, departureTime, vehicleRoute.getDriver(), vehicle);
|
||||||
double varCostSaving = states.getRouteState(vehicleRoute).getCosts() - newCost;
|
double varCostSaving = states.getRouteState(vehicleRoute).getCosts() - newCost;
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,8 @@ package algorithms;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -72,16 +70,6 @@ class InfiniteVehicles implements VehicleFleetManager{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vehicle getEmptyVehicle(TypeKey typeId) {
|
|
||||||
return types.get(typeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<TypeKey> getAvailableVehicleTypes() {
|
|
||||||
return sortedTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Vehicle vehicle) {
|
public void lock(Vehicle vehicle) {
|
||||||
|
|
||||||
|
|
@ -92,12 +80,6 @@ class InfiniteVehicles implements VehicleFleetManager{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<TypeKey> getAvailableVehicleTypes(TypeKey withoutThisType) {
|
|
||||||
Set<TypeKey> typeSet = new HashSet<TypeKey>(types.keySet());
|
|
||||||
typeSet.remove(withoutThisType);
|
|
||||||
return typeSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLocked(Vehicle vehicle) {
|
public boolean isLocked(Vehicle vehicle) {
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,10 @@ package algorithms;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
|
|
||||||
interface VehicleFleetManager {
|
interface VehicleFleetManager {
|
||||||
|
|
||||||
public static class TypeKey {
|
static class TypeKey {
|
||||||
|
|
||||||
public final String type;
|
public final String type;
|
||||||
public final String locationId;
|
public final String locationId;
|
||||||
|
|
@ -74,21 +73,15 @@ interface VehicleFleetManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Vehicle getEmptyVehicle(TypeKey typeId);
|
abstract void lock(Vehicle vehicle);
|
||||||
|
|
||||||
public abstract Collection<TypeKey> getAvailableVehicleTypes();
|
abstract void unlock(Vehicle vehicle);
|
||||||
|
|
||||||
public abstract void lock(Vehicle vehicle);
|
abstract boolean isLocked(Vehicle vehicle);
|
||||||
|
|
||||||
public abstract void unlock(Vehicle vehicle);
|
abstract void unlockAll();
|
||||||
|
|
||||||
public abstract Collection<TypeKey> getAvailableVehicleTypes(TypeKey withoutThisType);
|
abstract Collection<? extends Vehicle> getAvailableVehicles();
|
||||||
|
|
||||||
public abstract boolean isLocked(Vehicle vehicle);
|
|
||||||
|
|
||||||
public abstract void unlockAll();
|
|
||||||
|
|
||||||
public abstract Collection<? extends Vehicle> getAvailableVehicles();
|
|
||||||
|
|
||||||
Collection<? extends Vehicle> getAvailableVehicle(String withoutThisType, String locationId);
|
Collection<? extends Vehicle> getAvailableVehicle(String withoutThisType, String locationId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import basics.route.PenaltyVehicleType;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl.NoVehicle;
|
import basics.route.VehicleImpl.NoVehicle;
|
||||||
|
|
||||||
|
|
@ -136,10 +137,9 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
if(v.getType() == null){
|
if(v.getType() == null){
|
||||||
throw new IllegalStateException("vehicle needs type");
|
throw new IllegalStateException("vehicle needs type");
|
||||||
}
|
}
|
||||||
String typeId = v.getType().typeId;
|
String typeId = v.getType().getTypeId();
|
||||||
if(typeId.contains("penalty")){
|
if(v.getType() instanceof PenaltyVehicleType){
|
||||||
String[] typeIdTokens = typeId.split("#");
|
TypeKey typeKey = new TypeKey(typeId,v.getLocationId());
|
||||||
TypeKey typeKey = new TypeKey(typeIdTokens[0],v.getLocationId());
|
|
||||||
penaltyVehicles.put(typeKey, v);
|
penaltyVehicles.put(typeKey, v);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -153,7 +153,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
|
|
||||||
private void removeVehicle(Vehicle v){
|
private void removeVehicle(Vehicle v){
|
||||||
//it might be better to introduce a class PenaltyVehicle
|
//it might be better to introduce a class PenaltyVehicle
|
||||||
if(!v.getType().getTypeId().contains("penalty")){
|
if(!(v.getType() instanceof PenaltyVehicleType)){
|
||||||
TypeKey key = new TypeKey(v.getType().getTypeId(),v.getLocationId());
|
TypeKey key = new TypeKey(v.getType().getTypeId(),v.getLocationId());
|
||||||
if(typeMapOfAvailableVehicles.containsKey(key)){
|
if(typeMapOfAvailableVehicles.containsKey(key)){
|
||||||
typeMapOfAvailableVehicles.get(key).remove(v);
|
typeMapOfAvailableVehicles.get(key).remove(v);
|
||||||
|
|
@ -161,34 +161,6 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.matsim.contrib.freight.vrp.basics.VehicleFleetManager#getEmptyVehicle(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Vehicle getEmptyVehicle(TypeKey typeId){
|
|
||||||
Vehicle v = null;
|
|
||||||
if(typeMapOfAvailableVehicles.containsKey(typeId)){
|
|
||||||
v = typeMapOfAvailableVehicles.get(typeId).getVehicle();
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.matsim.contrib.freight.vrp.basics.VehicleFleetManager#getAvailableVehicleTypes()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<TypeKey> getAvailableVehicleTypes(){
|
|
||||||
List<TypeKey> types = new ArrayList<TypeKey>();
|
|
||||||
for(TypeKey key : typeMapOfAvailableVehicles.keySet()){
|
|
||||||
if(!typeMapOfAvailableVehicles.get(key).isEmpty()){
|
|
||||||
types.add(key);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a collection of available vehicles.
|
* Returns a collection of available vehicles.
|
||||||
|
|
@ -250,7 +222,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
if(vehicles.isEmpty() || vehicle instanceof NoVehicle){
|
if(vehicles.isEmpty() || vehicle instanceof NoVehicle){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(vehicle.getType().getTypeId().contains("penalty")) return;
|
if(vehicle.getType() instanceof PenaltyVehicleType) return;
|
||||||
boolean locked = lockedVehicles.add(vehicle);
|
boolean locked = lockedVehicles.add(vehicle);
|
||||||
removeVehicle(vehicle);
|
removeVehicle(vehicle);
|
||||||
if(!locked){
|
if(!locked){
|
||||||
|
|
@ -267,30 +239,11 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(vehicle == null) return;
|
if(vehicle == null) return;
|
||||||
if(vehicle.getType().getTypeId().contains("penalty")) return;
|
if(vehicle.getType() instanceof PenaltyVehicleType) return;
|
||||||
lockedVehicles.remove(vehicle);
|
lockedVehicles.remove(vehicle);
|
||||||
addVehicle(vehicle);
|
addVehicle(vehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.matsim.contrib.freight.vrp.basics.VehicleFleetManager#getAvailableVehicleTypes(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<TypeKey> getAvailableVehicleTypes(TypeKey withoutThisType) {
|
|
||||||
List<TypeKey> types = new ArrayList<TypeKey>();
|
|
||||||
for(TypeKey typeKey : typeMapOfAvailableVehicles.keySet()){
|
|
||||||
if(typeKey.equals(withoutThisType)){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!typeMapOfAvailableVehicles.get(typeKey).isEmpty()){
|
|
||||||
types.add(typeKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.matsim.contrib.freight.vrp.basics.VehicleFleetManager#isLocked(org.matsim.contrib.freight.vrp.basics.Vehicle)
|
* @see org.matsim.contrib.freight.vrp.basics.VehicleFleetManager#isLocked(org.matsim.contrib.freight.vrp.basics.Vehicle)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ import basics.costs.VehicleRoutingActivityCosts;
|
||||||
import basics.costs.VehicleRoutingTransportCosts;
|
import basics.costs.VehicleRoutingTransportCosts;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains and describes the vehicle routing problem.
|
* Contains and describes the vehicle routing problem.
|
||||||
|
|
@ -96,7 +97,7 @@ public class VehicleRoutingProblem {
|
||||||
jobs = new HashMap<String, Job>();
|
jobs = new HashMap<String, Job>();
|
||||||
vehicles = new ArrayList<Vehicle>();
|
vehicles = new ArrayList<Vehicle>();
|
||||||
coordinates = new HashMap<String, Coordinate>();
|
coordinates = new HashMap<String, Coordinate>();
|
||||||
vehicleTypes = new ArrayList<VehicleImpl.VehicleType>();
|
vehicleTypes = new ArrayList<VehicleType>();
|
||||||
services = new ArrayList<Service>();
|
services = new ArrayList<Service>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,7 +238,7 @@ public class VehicleRoutingProblem {
|
||||||
* @param type
|
* @param type
|
||||||
* @return builder
|
* @return builder
|
||||||
*/
|
*/
|
||||||
public Builder addVehicleType(VehicleType type){
|
public Builder addVehicleType(VehicleTypeImpl type){
|
||||||
vehicleTypes.add(type);
|
vehicleTypes.add(type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -445,7 +446,7 @@ public class VehicleRoutingProblem {
|
||||||
* Returns the entire, unmodifiable collection of types.
|
* Returns the entire, unmodifiable collection of types.
|
||||||
*
|
*
|
||||||
* @return unmodifiable collection of types
|
* @return unmodifiable collection of types
|
||||||
* @see VehicleType
|
* @see VehicleTypeImpl
|
||||||
*/
|
*/
|
||||||
public Collection<VehicleType> getTypes(){
|
public Collection<VehicleType> getTypes(){
|
||||||
return Collections.unmodifiableCollection(vehicleTypes);
|
return Collections.unmodifiableCollection(vehicleTypes);
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,9 @@ import basics.route.TimeWindow;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleBuilder;
|
import basics.route.VehicleImpl.VehicleBuilder;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class VrpXMLReader{
|
public class VrpXMLReader{
|
||||||
|
|
||||||
|
|
@ -255,7 +256,7 @@ public class VrpXMLReader{
|
||||||
private void readVehiclesAndTheirTypes(XMLConfiguration vrpProblem) {
|
private void readVehiclesAndTheirTypes(XMLConfiguration vrpProblem) {
|
||||||
|
|
||||||
//read vehicle-types
|
//read vehicle-types
|
||||||
Map<String, VehicleType> types = new HashMap<String, VehicleType>();
|
Map<String, VehicleTypeImpl> types = new HashMap<String, VehicleTypeImpl>();
|
||||||
List<HierarchicalConfiguration> typeConfigs = vrpProblem.configurationsAt("vehicleTypes.type");
|
List<HierarchicalConfiguration> typeConfigs = vrpProblem.configurationsAt("vehicleTypes.type");
|
||||||
for(HierarchicalConfiguration typeConfig : typeConfigs){
|
for(HierarchicalConfiguration typeConfig : typeConfigs){
|
||||||
String typeId = typeConfig.getString("id");
|
String typeId = typeConfig.getString("id");
|
||||||
|
|
@ -267,12 +268,12 @@ public class VrpXMLReader{
|
||||||
// Double end = typeConfig.getDouble("timeSchedule.end");
|
// Double end = typeConfig.getDouble("timeSchedule.end");
|
||||||
if(typeId == null) throw new IllegalStateException("typeId is missing.");
|
if(typeId == null) throw new IllegalStateException("typeId is missing.");
|
||||||
if(capacity == null) throw new IllegalStateException("capacity is missing.");
|
if(capacity == null) throw new IllegalStateException("capacity is missing.");
|
||||||
VehicleType.Builder typeBuilder = VehicleType.Builder.newInstance(typeId, capacity);
|
VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance(typeId, capacity);
|
||||||
if(fix != null) typeBuilder.setFixedCost(fix);
|
if(fix != null) typeBuilder.setFixedCost(fix);
|
||||||
if(timeC != null) typeBuilder.setCostPerTime(timeC);
|
if(timeC != null) typeBuilder.setCostPerTime(timeC);
|
||||||
if(distC != null) typeBuilder.setCostPerDistance(distC);
|
if(distC != null) typeBuilder.setCostPerDistance(distC);
|
||||||
// if(start != null && end != null) typeBuilder.setTimeSchedule(new TimeSchedule(start, end));
|
// if(start != null && end != null) typeBuilder.setTimeSchedule(new TimeSchedule(start, end));
|
||||||
VehicleType type = typeBuilder.build();
|
VehicleTypeImpl type = typeBuilder.build();
|
||||||
types.put(type.typeId, type);
|
types.put(type.typeId, type);
|
||||||
vrpBuilder.addVehicleType(type);
|
vrpBuilder.addVehicleType(type);
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +287,7 @@ public class VrpXMLReader{
|
||||||
VehicleBuilder builder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
VehicleBuilder builder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
||||||
String typeId = vehicleConfig.getString("typeId");
|
String typeId = vehicleConfig.getString("typeId");
|
||||||
if(typeId == null) throw new IllegalStateException("typeId is missing.");
|
if(typeId == null) throw new IllegalStateException("typeId is missing.");
|
||||||
VehicleType type = types.get(typeId);
|
VehicleTypeImpl type = types.get(typeId);
|
||||||
if(type == null) throw new IllegalStateException("vehicleType with typeId " + typeId + " is missing.");
|
if(type == null) throw new IllegalStateException("vehicleType with typeId " + typeId + " is missing.");
|
||||||
builder.setType(type);
|
builder.setType(type);
|
||||||
String locationId = vehicleConfig.getString("location.id");
|
String locationId = vehicleConfig.getString("location.id");
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ import basics.VehicleRoutingProblemSolution;
|
||||||
import basics.route.ServiceActivity;
|
import basics.route.ServiceActivity;
|
||||||
import basics.route.TourActivity;
|
import basics.route.TourActivity;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
|
import basics.route.VehicleType;
|
||||||
|
|
||||||
public class VrpXMLWriter {
|
public class VrpXMLWriter {
|
||||||
|
|
||||||
|
|
@ -226,7 +226,7 @@ public class VrpXMLWriter {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for(Vehicle vehicle : vrp.getVehicles()){
|
for(Vehicle vehicle : vrp.getVehicles()){
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").id", vehicle.getId());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").id", vehicle.getId());
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").typeId", vehicle.getType().typeId);
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").typeId", vehicle.getType().getTypeId());
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").location.id", vehicle.getLocationId());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").location.id", vehicle.getLocationId());
|
||||||
if(vehicle.getCoord() != null){
|
if(vehicle.getCoord() != null){
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").location.coord[@x]", vehicle.getCoord().getX());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").location.coord[@x]", vehicle.getCoord().getX());
|
||||||
|
|
@ -248,13 +248,13 @@ public class VrpXMLWriter {
|
||||||
String typePathString = Schema.builder().append(Schema.TYPES).dot(Schema.TYPE).build();
|
String typePathString = Schema.builder().append(Schema.TYPES).dot(Schema.TYPE).build();
|
||||||
int typeCounter = 0;
|
int typeCounter = 0;
|
||||||
for(VehicleType type : vrp.getTypes()){
|
for(VehicleType type : vrp.getTypes()){
|
||||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").id", type.typeId);
|
xmlConfig.setProperty(typePathString + "("+typeCounter+").id", type.getTypeId());
|
||||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").capacity", type.capacity);
|
xmlConfig.setProperty(typePathString + "("+typeCounter+").capacity", type.getCapacity());
|
||||||
// xmlConfig.setProperty(typePathString + "("+typeCounter+").timeSchedule.start", type.getTimeSchedule().getEarliestStart());
|
// xmlConfig.setProperty(typePathString + "("+typeCounter+").timeSchedule.start", type.getTimeSchedule().getEarliestStart());
|
||||||
// xmlConfig.setProperty(typePathString + "("+typeCounter+").timeSchedule.end", type.getTimeSchedule().getLatestEnd());
|
// xmlConfig.setProperty(typePathString + "("+typeCounter+").timeSchedule.end", type.getTimeSchedule().getLatestEnd());
|
||||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.fixed", type.vehicleCostParams.fix);
|
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.fixed", type.getVehicleCostParams().fix);
|
||||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.distance", type.vehicleCostParams.perDistanceUnit);
|
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.distance", type.getVehicleCostParams().perDistanceUnit);
|
||||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.time", type.vehicleCostParams.perTimeUnit);
|
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.time", type.getVehicleCostParams().perTimeUnit);
|
||||||
typeCounter++;
|
typeCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package basics.route;
|
package basics.route;
|
||||||
|
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
|
|
||||||
|
|
||||||
public class DefaultVehicleRouteCostCalculator implements VehicleRouteCostCalculator {
|
public class DefaultVehicleRouteCostCalculator implements VehicleRouteCostCalculator {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package basics.route;
|
||||||
|
|
||||||
|
import basics.route.VehicleTypeImpl.VehicleCostParams;
|
||||||
|
|
||||||
|
public class PenaltyVehicleType implements VehicleType{
|
||||||
|
|
||||||
|
private VehicleType type;
|
||||||
|
|
||||||
|
public PenaltyVehicleType(VehicleType type) {
|
||||||
|
super();
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeId() {
|
||||||
|
return type.getTypeId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCapacity() {
|
||||||
|
return type.getCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VehicleCostParams getVehicleCostParams() {
|
||||||
|
return type.getVehicleCostParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
package basics.route;
|
package basics.route;
|
||||||
|
|
||||||
import util.Coordinate;
|
import util.Coordinate;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class VehicleImpl implements Vehicle {
|
||||||
public static class NoVehicle extends VehicleImpl {
|
public static class NoVehicle extends VehicleImpl {
|
||||||
|
|
||||||
public NoVehicle() {
|
public NoVehicle() {
|
||||||
super(VehicleBuilder.newInstance("noVehicle").setType(VehicleType.newInstance(null, 0, null)));
|
super(VehicleBuilder.newInstance("noVehicle").setType(VehicleTypeImpl.newInstance(null, 0, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCapacity(){
|
public int getCapacity(){
|
||||||
|
|
@ -40,129 +40,6 @@ public class VehicleImpl implements Vehicle {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class VehicleType {
|
|
||||||
|
|
||||||
public static class Builder{
|
|
||||||
|
|
||||||
public static Builder newInstance(String id, int capacity){
|
|
||||||
return new Builder(id,capacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
private int capacity;
|
|
||||||
/**
|
|
||||||
* default cost values for default vehicle type
|
|
||||||
*/
|
|
||||||
private double fixedCost = 0.0;
|
|
||||||
private double perDistance = 1.0;
|
|
||||||
private double perTime = 0.0;
|
|
||||||
|
|
||||||
public Builder(String id, int capacity) {
|
|
||||||
super();
|
|
||||||
this.id = id;
|
|
||||||
this.capacity = capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setFixedCost(double fixedCost) { this.fixedCost = fixedCost; return this; }
|
|
||||||
|
|
||||||
public Builder setCostPerDistance(double perDistance){ this.perDistance = perDistance; return this; }
|
|
||||||
|
|
||||||
public Builder setCostPerTime(double perTime){ this.perTime = perTime; return this; }
|
|
||||||
|
|
||||||
public VehicleType build(){
|
|
||||||
return new VehicleType(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result
|
|
||||||
+ ((typeId == null) ? 0 : typeId.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
VehicleType other = (VehicleType) obj;
|
|
||||||
if (typeId == null) {
|
|
||||||
if (other.typeId != null)
|
|
||||||
return false;
|
|
||||||
} else if (!typeId.equals(other.typeId))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String typeId;
|
|
||||||
public final int capacity;
|
|
||||||
public final VehicleCostParams vehicleCostParams;
|
|
||||||
|
|
||||||
public static VehicleType newInstance(String typeId, int capacity, VehicleCostParams para){
|
|
||||||
return new VehicleType(typeId, capacity, para);
|
|
||||||
}
|
|
||||||
|
|
||||||
private VehicleType(Builder builder){
|
|
||||||
typeId = builder.id;
|
|
||||||
capacity = builder.capacity;
|
|
||||||
vehicleCostParams = new VehicleCostParams(builder.fixedCost, builder.perTime, builder.perDistance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VehicleType(String typeId, int capacity,VehicleCostParams vehicleCostParams) {
|
|
||||||
super();
|
|
||||||
this.typeId = typeId;
|
|
||||||
this.capacity = capacity;
|
|
||||||
this.vehicleCostParams = vehicleCostParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTypeId() {
|
|
||||||
return typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCapacity() {
|
|
||||||
return capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VehicleCostParams getVehicleCostParams() {
|
|
||||||
return vehicleCostParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[typeId="+typeId+"][capacity="+capacity+"]" + vehicleCostParams;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class VehicleCostParams {
|
|
||||||
|
|
||||||
public static VehicleCostParams newInstance(double fix, double perTimeUnit,double perDistanceUnit){
|
|
||||||
return new VehicleCostParams(fix, perTimeUnit, perDistanceUnit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final double fix;
|
|
||||||
public final double perTimeUnit;
|
|
||||||
public final double perDistanceUnit;
|
|
||||||
|
|
||||||
private VehicleCostParams(double fix, double perTimeUnit,double perDistanceUnit) {
|
|
||||||
super();
|
|
||||||
this.fix = fix;
|
|
||||||
this.perTimeUnit = perTimeUnit;
|
|
||||||
this.perDistanceUnit = perDistanceUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[fixed="+fix+"][perTime="+perTimeUnit+"][perDistance="+perDistanceUnit+"]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class VehicleBuilder {
|
public static class VehicleBuilder {
|
||||||
static Logger log = Logger.getLogger(VehicleBuilder.class);
|
static Logger log = Logger.getLogger(VehicleBuilder.class);
|
||||||
private String id;
|
private String id;
|
||||||
|
|
@ -172,7 +49,7 @@ public class VehicleImpl implements Vehicle {
|
||||||
private double earliestStart = 0.0;
|
private double earliestStart = 0.0;
|
||||||
private double latestArrival = Double.MAX_VALUE;
|
private double latestArrival = Double.MAX_VALUE;
|
||||||
|
|
||||||
private VehicleType type = VehicleType.Builder.newInstance("default", 0).build();
|
private VehicleType type = VehicleTypeImpl.Builder.newInstance("default", 0).build();
|
||||||
|
|
||||||
private VehicleBuilder(String id) {
|
private VehicleBuilder(String id) {
|
||||||
super();
|
super();
|
||||||
|
|
@ -309,7 +186,7 @@ public class VehicleImpl implements Vehicle {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getCapacity() {
|
public int getCapacity() {
|
||||||
return type.capacity;
|
return type.getCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
jsprit-core/src/main/java/basics/route/VehicleType.java
Normal file
14
jsprit-core/src/main/java/basics/route/VehicleType.java
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
package basics.route;
|
||||||
|
|
||||||
|
import basics.route.VehicleTypeImpl.VehicleCostParams;
|
||||||
|
|
||||||
|
|
||||||
|
public interface VehicleType {
|
||||||
|
|
||||||
|
public String getTypeId();
|
||||||
|
|
||||||
|
public int getCapacity();
|
||||||
|
|
||||||
|
public VehicleCostParams getVehicleCostParams();
|
||||||
|
|
||||||
|
}
|
||||||
138
jsprit-core/src/main/java/basics/route/VehicleTypeImpl.java
Normal file
138
jsprit-core/src/main/java/basics/route/VehicleTypeImpl.java
Normal file
|
|
@ -0,0 +1,138 @@
|
||||||
|
package basics.route;
|
||||||
|
|
||||||
|
|
||||||
|
public class VehicleTypeImpl implements VehicleType {
|
||||||
|
|
||||||
|
public static class VehicleCostParams {
|
||||||
|
|
||||||
|
public static VehicleTypeImpl.VehicleCostParams newInstance(double fix, double perTimeUnit,double perDistanceUnit){
|
||||||
|
return new VehicleCostParams(fix, perTimeUnit, perDistanceUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final double fix;
|
||||||
|
public final double perTimeUnit;
|
||||||
|
public final double perDistanceUnit;
|
||||||
|
|
||||||
|
private VehicleCostParams(double fix, double perTimeUnit,double perDistanceUnit) {
|
||||||
|
super();
|
||||||
|
this.fix = fix;
|
||||||
|
this.perTimeUnit = perTimeUnit;
|
||||||
|
this.perDistanceUnit = perDistanceUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[fixed="+fix+"][perTime="+perTimeUnit+"][perDistance="+perDistanceUnit+"]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Builder{
|
||||||
|
|
||||||
|
public static VehicleTypeImpl.Builder newInstance(String id, int capacity){
|
||||||
|
return new Builder(id,capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private int capacity;
|
||||||
|
/**
|
||||||
|
* default cost values for default vehicle type
|
||||||
|
*/
|
||||||
|
private double fixedCost = 0.0;
|
||||||
|
private double perDistance = 1.0;
|
||||||
|
private double perTime = 0.0;
|
||||||
|
|
||||||
|
public Builder(String id, int capacity) {
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.capacity = capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VehicleTypeImpl.Builder setFixedCost(double fixedCost) { this.fixedCost = fixedCost; return this; }
|
||||||
|
|
||||||
|
public VehicleTypeImpl.Builder setCostPerDistance(double perDistance){ this.perDistance = perDistance; return this; }
|
||||||
|
|
||||||
|
public VehicleTypeImpl.Builder setCostPerTime(double perTime){ this.perTime = perTime; return this; }
|
||||||
|
|
||||||
|
public VehicleTypeImpl build(){
|
||||||
|
return new VehicleTypeImpl(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result
|
||||||
|
+ ((typeId == null) ? 0 : typeId.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
VehicleTypeImpl other = (VehicleTypeImpl) obj;
|
||||||
|
if (typeId == null) {
|
||||||
|
if (other.typeId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!typeId.equals(other.typeId))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String typeId;
|
||||||
|
public final int capacity;
|
||||||
|
public final VehicleTypeImpl.VehicleCostParams vehicleCostParams;
|
||||||
|
|
||||||
|
public static VehicleTypeImpl newInstance(String typeId, int capacity, VehicleTypeImpl.VehicleCostParams para){
|
||||||
|
return new VehicleTypeImpl(typeId, capacity, para);
|
||||||
|
}
|
||||||
|
|
||||||
|
private VehicleTypeImpl(VehicleTypeImpl.Builder builder){
|
||||||
|
typeId = builder.id;
|
||||||
|
capacity = builder.capacity;
|
||||||
|
vehicleCostParams = new VehicleCostParams(builder.fixedCost, builder.perTime, builder.perDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VehicleTypeImpl(String typeId, int capacity,VehicleTypeImpl.VehicleCostParams vehicleCostParams) {
|
||||||
|
super();
|
||||||
|
this.typeId = typeId;
|
||||||
|
this.capacity = capacity;
|
||||||
|
this.vehicleCostParams = vehicleCostParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see basics.route.VehicleType#getTypeId()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getTypeId() {
|
||||||
|
return typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see basics.route.VehicleType#getCapacity()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getCapacity() {
|
||||||
|
return capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see basics.route.VehicleType#getVehicleCostParams()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public VehicleTypeImpl.VehicleCostParams getVehicleCostParams() {
|
||||||
|
return vehicleCostParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[typeId="+typeId+"][capacity="+capacity+"]" + vehicleCostParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,7 +20,6 @@ import org.apache.log4j.Logger;
|
||||||
import basics.costs.VehicleRoutingTransportCosts;
|
import basics.costs.VehicleRoutingTransportCosts;
|
||||||
import basics.route.Driver;
|
import basics.route.Driver;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ public class RouteUtils {
|
||||||
if(r.getTourActivities().isEmpty()){
|
if(r.getTourActivities().isEmpty()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
total += r.getVehicle().getType().vehicleCostParams.fix;
|
total += r.getVehicle().getType().getVehicleCostParams().fix;
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,15 @@ import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import algorithms.VehicleFleetManager.TypeKey;
|
|
||||||
import basics.Service;
|
import basics.Service;
|
||||||
import basics.route.TimeWindow;
|
import basics.route.TimeWindow;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -53,18 +51,13 @@ public class CalcVehicleTypeDependentServiceInsertionTest {
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
veh1 = mock(Vehicle.class);
|
veh1 = mock(Vehicle.class);
|
||||||
veh2 = mock(Vehicle.class);
|
veh2 = mock(Vehicle.class);
|
||||||
when(veh1.getType()).thenReturn(VehicleImpl.VehicleType.Builder.newInstance("type1", 0).build());
|
when(veh1.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type1", 0).build());
|
||||||
when(veh2.getType()).thenReturn(VehicleImpl.VehicleType.Builder.newInstance("type2", 0).build());
|
when(veh2.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type2", 0).build());
|
||||||
when(veh1.getLocationId()).thenReturn("loc1");
|
when(veh1.getLocationId()).thenReturn("loc1");
|
||||||
when(veh2.getLocationId()).thenReturn("loc2");
|
when(veh2.getLocationId()).thenReturn("loc2");
|
||||||
fleetManager = mock(VehicleFleetManager.class);
|
fleetManager = mock(VehicleFleetManager.class);
|
||||||
service = mock(Service.class);
|
service = mock(Service.class);
|
||||||
vehicleRoute = mock(VehicleRoute.class);
|
vehicleRoute = mock(VehicleRoute.class);
|
||||||
TypeKey typeKey1 = new TypeKey(veh1.getType().getTypeId(),veh1.getLocationId());
|
|
||||||
TypeKey typeKey2 = new TypeKey(veh2.getType().getTypeId(),veh2.getLocationId());
|
|
||||||
when(fleetManager.getAvailableVehicleTypes()).thenReturn(Arrays.asList(typeKey1,typeKey2));
|
|
||||||
when(fleetManager.getEmptyVehicle(typeKey1)).thenReturn(veh1);
|
|
||||||
when(fleetManager.getEmptyVehicle(typeKey2)).thenReturn(veh2);
|
|
||||||
|
|
||||||
when(veh1.getCapacity()).thenReturn(10);
|
when(veh1.getCapacity()).thenReturn(10);
|
||||||
when(veh2.getCapacity()).thenReturn(10);
|
when(veh2.getCapacity()).thenReturn(10);
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ import basics.costs.VehicleRoutingTransportCosts;
|
||||||
import basics.route.Driver;
|
import basics.route.Driver;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class CalcWithTimeSchedulingTest {
|
public class CalcWithTimeSchedulingTest {
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class CalcWithTimeSchedulingTest {
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("myVehicle").setEarliestStart(0.0).setLatestArrival(100.0).
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("myVehicle").setEarliestStart(0.0).setLatestArrival(100.0).
|
||||||
setLocationCoord(Coordinate.newInstance(0, 0)).setLocationId("0,0")
|
setLocationCoord(Coordinate.newInstance(0, 0)).setLocationId("0,0")
|
||||||
.setType(VehicleType.Builder.newInstance("myType", 20).setCostPerDistance(1.0).build()).build();
|
.setType(VehicleTypeImpl.Builder.newInstance("myType", 20).setCostPerDistance(1.0).build()).build();
|
||||||
vrpBuilder.addVehicle(vehicle);
|
vrpBuilder.addVehicle(vehicle);
|
||||||
vrpBuilder.addService(Service.Builder.newInstance("myService", 2).setLocationId("0,20").setCoord(Coordinate.newInstance(0, 20)).build());
|
vrpBuilder.addService(Service.Builder.newInstance("myService", 2).setLocationId("0,20").setCoord(Coordinate.newInstance(0, 20)).build());
|
||||||
vrpBuilder.setFleetSize(FleetSize.INFINITE);
|
vrpBuilder.setFleetSize(FleetSize.INFINITE);
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,9 @@ import basics.route.TimeWindow;
|
||||||
import basics.route.TourActivities;
|
import basics.route.TourActivities;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class GendreauPostOptTest {
|
public class GendreauPostOptTest {
|
||||||
|
|
||||||
|
|
@ -109,7 +110,7 @@ public class GendreauPostOptTest {
|
||||||
|
|
||||||
double costPerDistanceUnit;
|
double costPerDistanceUnit;
|
||||||
if(vehicle != null){
|
if(vehicle != null){
|
||||||
costPerDistanceUnit = vehicle.getType().vehicleCostParams.perDistanceUnit;
|
costPerDistanceUnit = vehicle.getType().getVehicleCostParams().perDistanceUnit;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
costPerDistanceUnit = 1;
|
costPerDistanceUnit = 1;
|
||||||
|
|
@ -124,8 +125,8 @@ public class GendreauPostOptTest {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
VehicleType lightType = VehicleImpl.VehicleType.Builder.newInstance("light", 10).setFixedCost(10).setCostPerDistance(1.0).build();
|
VehicleTypeImpl lightType = VehicleTypeImpl.Builder.newInstance("light", 10).setFixedCost(10).setCostPerDistance(1.0).build();
|
||||||
VehicleType heavyType = VehicleImpl.VehicleType.Builder.newInstance("heavy", 10).setFixedCost(30).setCostPerDistance(2.0).build();
|
VehicleTypeImpl heavyType = VehicleTypeImpl.Builder.newInstance("heavy", 10).setFixedCost(30).setCostPerDistance(2.0).build();
|
||||||
|
|
||||||
lightVehicle1 = VehicleImpl.VehicleBuilder.newInstance("light").setLocationId("0,0").setType(lightType).build();
|
lightVehicle1 = VehicleImpl.VehicleBuilder.newInstance("light").setLocationId("0,0").setType(lightType).build();
|
||||||
lightVehicle2 = VehicleImpl.VehicleBuilder.newInstance("light2").setLocationId("0,0").setType(lightType).build();
|
lightVehicle2 = VehicleImpl.VehicleBuilder.newInstance("light2").setLocationId("0,0").setType(lightType).build();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package algorithms;
|
package algorithms;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -40,7 +40,8 @@ import basics.route.TimeWindow;
|
||||||
import basics.route.TourActivity;
|
import basics.route.TourActivity;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class TestDepartureTimeOpt {
|
public class TestDepartureTimeOpt {
|
||||||
|
|
||||||
|
|
@ -48,9 +49,9 @@ public class TestDepartureTimeOpt {
|
||||||
public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_totalCostsShouldBe50(){
|
public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_totalCostsShouldBe50(){
|
||||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||||
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
|
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
|
||||||
VehicleType type = mock(VehicleType.class);
|
VehicleType type = mock(VehicleTypeImpl.class);
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
||||||
.setType(VehicleType.Builder.newInstance("vType", 0).build()).build();
|
.setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build();
|
||||||
|
|
||||||
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
||||||
|
|
@ -76,9 +77,9 @@ public class TestDepartureTimeOpt {
|
||||||
public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_depTimeShouldBe0(){
|
public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_depTimeShouldBe0(){
|
||||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||||
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
|
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
|
||||||
VehicleType type = mock(VehicleType.class);
|
VehicleType type = mock(VehicleTypeImpl.class);
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
||||||
.setType(VehicleType.Builder.newInstance("vType", 0).build()).build();
|
.setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build();
|
||||||
|
|
||||||
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
||||||
|
|
@ -105,7 +106,7 @@ public class TestDepartureTimeOpt {
|
||||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||||
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
|
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
||||||
.setType(VehicleType.Builder.newInstance("vType", 0).build()).build();
|
.setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build();
|
||||||
|
|
||||||
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
||||||
|
|
@ -133,7 +134,7 @@ public class TestDepartureTimeOpt {
|
||||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||||
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
|
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
||||||
.setType(VehicleType.Builder.newInstance("vType", 0).build()).build();
|
.setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build();
|
||||||
|
|
||||||
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
||||||
|
|
@ -165,7 +166,7 @@ public class TestDepartureTimeOpt {
|
||||||
setTimeWindow(TimeWindow.newInstance(30, 40)).build();
|
setTimeWindow(TimeWindow.newInstance(30, 40)).build();
|
||||||
|
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
||||||
.setType(VehicleType.Builder.newInstance("vType", 0).build()).build();
|
.setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build();
|
||||||
|
|
||||||
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
||||||
|
|
@ -197,7 +198,7 @@ public class TestDepartureTimeOpt {
|
||||||
setTimeWindow(TimeWindow.newInstance(30, 40)).build();
|
setTimeWindow(TimeWindow.newInstance(30, 40)).build();
|
||||||
|
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
|
||||||
.setType(VehicleType.Builder.newInstance("vType", 0).build()).build();
|
.setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build();
|
||||||
|
|
||||||
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts(){
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,9 @@ import basics.route.TimeWindow;
|
||||||
import basics.route.TourActivities;
|
import basics.route.TourActivities;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
|
|
||||||
public class TestTourStateUpdaterWithService {
|
public class TestTourStateUpdaterWithService {
|
||||||
|
|
@ -102,7 +103,7 @@ public class TestTourStateUpdaterWithService {
|
||||||
states = new RouteStates();
|
states = new RouteStates();
|
||||||
states.initialiseStateOfJobs(services);
|
states.initialiseStateOfJobs(services);
|
||||||
|
|
||||||
VehicleType type = VehicleImpl.VehicleType.Builder.newInstance("test", 0).build();
|
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("test", 0).build();
|
||||||
vehicle = VehicleImpl.VehicleBuilder.newInstance("testvehicle").setType(type).setLocationId("0,0")
|
vehicle = VehicleImpl.VehicleBuilder.newInstance("testvehicle").setType(type).setLocationId("0,0")
|
||||||
.setEarliestStart(0.0).setLatestArrival(50.0).build();
|
.setEarliestStart(0.0).setLatestArrival(50.0).build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,17 +24,11 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import algorithms.VehicleFleetManager.TypeKey;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleBuilder;
|
import basics.route.VehicleTypeImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
import basics.route.VehicleImpl.VehicleType.Builder;
|
|
||||||
|
|
||||||
import algorithms.VehicleFleetManager;
|
|
||||||
import algorithms.VehicleFleetManagerImpl;
|
|
||||||
import algorithms.VehicleFleetManager.TypeKey;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
public class TestVehicleFleetManager extends TestCase{
|
public class TestVehicleFleetManager extends TestCase{
|
||||||
|
|
||||||
|
|
@ -47,8 +41,8 @@ public class TestVehicleFleetManager extends TestCase{
|
||||||
public void setUp(){
|
public void setUp(){
|
||||||
List<Vehicle> vehicles = new ArrayList<Vehicle>();
|
List<Vehicle> vehicles = new ArrayList<Vehicle>();
|
||||||
|
|
||||||
v1 = VehicleImpl.VehicleBuilder.newInstance("standard").setLocationId("loc").setType(VehicleImpl.VehicleType.Builder.newInstance("standard", 0).build()).build();
|
v1 = VehicleImpl.VehicleBuilder.newInstance("standard").setLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("standard", 0).build()).build();
|
||||||
v2 = VehicleImpl.VehicleBuilder.newInstance("foo").setLocationId("fooLoc").setType(VehicleImpl.VehicleType.Builder.newInstance("foo", 0).build()).build();
|
v2 = VehicleImpl.VehicleBuilder.newInstance("foo").setLocationId("fooLoc").setType(VehicleTypeImpl.Builder.newInstance("foo", 0).build()).build();
|
||||||
|
|
||||||
vehicles.add(v1);
|
vehicles.add(v1);
|
||||||
vehicles.add(v2);
|
vehicles.add(v2);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import org.junit.Test;
|
||||||
import basics.VehicleRoutingProblem.FleetSize;
|
import basics.VehicleRoutingProblem.FleetSize;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class VehicleRoutingProblemBuilderTest {
|
public class VehicleRoutingProblemBuilderTest {
|
||||||
|
|
||||||
|
|
@ -48,8 +48,8 @@ public class VehicleRoutingProblemBuilderTest {
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
builder.setFleetSize(FleetSize.FINITE);
|
builder.setFleetSize(FleetSize.FINITE);
|
||||||
|
|
||||||
VehicleType type1 = VehicleType.Builder.newInstance("t1", 20).build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("t1", 20).build();
|
||||||
VehicleType type2 = VehicleType.Builder.newInstance("t2", 200).build();
|
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("t2", 200).build();
|
||||||
|
|
||||||
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("yo").setType(type1).build();
|
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("yo").setType(type1).build();
|
||||||
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("yo").setType(type1).build();
|
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("yo").setType(type1).build();
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ import basics.route.Start;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class VrpWriterV2Test {
|
public class VrpWriterV2Test {
|
||||||
|
|
||||||
|
|
@ -65,7 +66,7 @@ public class VrpWriterV2Test {
|
||||||
// builder.addDepot(depot2);
|
// builder.addDepot(depot2);
|
||||||
// builder.assignVehicleType(depot, VehicleType.Builder.newInstance("vehType", 20).build());
|
// builder.assignVehicleType(depot, VehicleType.Builder.newInstance("vehType", 20).build());
|
||||||
// builder.assignVehicleType(depot, VehicleType.Builder.newInstance("vehType2", 200).build());
|
// builder.assignVehicleType(depot, VehicleType.Builder.newInstance("vehType2", 200).build());
|
||||||
VehicleType type = VehicleType.Builder.newInstance("vehType", 20).build();
|
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("myVehicle").setLocationId("loc").setType(type).build();
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("myVehicle").setLocationId("loc").setType(type).build();
|
||||||
builder.addVehicle(vehicle);
|
builder.addVehicle(vehicle);
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
|
|
@ -80,8 +81,8 @@ public class VrpWriterV2Test {
|
||||||
// Depot depot = new Depot("depotLoc",Coordinate.newInstance(0, 0));
|
// Depot depot = new Depot("depotLoc",Coordinate.newInstance(0, 0));
|
||||||
// Depot depot2 = new Depot("depotLoc2",Coordinate.newInstance(100, 100));
|
// Depot depot2 = new Depot("depotLoc2",Coordinate.newInstance(100, 100));
|
||||||
// builder.addDepot(depot2);
|
// builder.addDepot(depot2);
|
||||||
VehicleType type1 = VehicleType.Builder.newInstance("vehType", 20).build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
|
||||||
VehicleType type2 = VehicleType.Builder.newInstance("vehType2", 200).build();
|
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
|
||||||
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
||||||
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
||||||
builder.addVehicleType(type1);
|
builder.addVehicleType(type1);
|
||||||
|
|
@ -100,8 +101,8 @@ public class VrpWriterV2Test {
|
||||||
// Depot depot = new Depot("depotLoc",Coordinate.newInstance(0, 0));
|
// Depot depot = new Depot("depotLoc",Coordinate.newInstance(0, 0));
|
||||||
// Depot depot2 = new Depot("depotLoc2",Coordinate.newInstance(100, 100));
|
// Depot depot2 = new Depot("depotLoc2",Coordinate.newInstance(100, 100));
|
||||||
// builder.addDepot(depot2);
|
// builder.addDepot(depot2);
|
||||||
VehicleType type1 = VehicleType.Builder.newInstance("vehType", 20).build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
|
||||||
VehicleType type2 = VehicleType.Builder.newInstance("vehType2", 200).build();
|
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
|
||||||
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
||||||
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
||||||
builder.addVehicleType(type1);
|
builder.addVehicleType(type1);
|
||||||
|
|
@ -119,8 +120,8 @@ public class VrpWriterV2Test {
|
||||||
public void whenWritingServices_itWritesThemCorrectly(){
|
public void whenWritingServices_itWritesThemCorrectly(){
|
||||||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
|
|
||||||
VehicleType type1 = VehicleType.Builder.newInstance("vehType", 20).build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
|
||||||
VehicleType type2 = VehicleType.Builder.newInstance("vehType2", 200).build();
|
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
|
||||||
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
||||||
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
||||||
|
|
||||||
|
|
@ -152,8 +153,8 @@ public class VrpWriterV2Test {
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
|
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
|
||||||
builder.setFleetSize(FleetSize.FINITE);
|
builder.setFleetSize(FleetSize.FINITE);
|
||||||
VehicleType type1 = VehicleType.Builder.newInstance("vehType", 20).build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
|
||||||
VehicleType type2 = VehicleType.Builder.newInstance("vehType2", 200).build();
|
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
|
||||||
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
||||||
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
||||||
builder.addVehicleType(type1);
|
builder.addVehicleType(type1);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ import basics.route.Start;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleRoute;
|
import basics.route.VehicleRoute;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class VrpWriterV3Test {
|
public class VrpWriterV3Test {
|
||||||
|
|
||||||
|
|
@ -59,8 +60,8 @@ public class VrpWriterV3Test {
|
||||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
|
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
|
||||||
builder.setFleetSize(FleetSize.FINITE);
|
builder.setFleetSize(FleetSize.FINITE);
|
||||||
VehicleType type1 = VehicleType.Builder.newInstance("vehType", 20).build();
|
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
|
||||||
VehicleType type2 = VehicleType.Builder.newInstance("vehType2", 200).build();
|
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
|
||||||
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
Vehicle v1 = VehicleImpl.VehicleBuilder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
||||||
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
Vehicle v2 = VehicleImpl.VehicleBuilder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
||||||
builder.addVehicleType(type1);
|
builder.addVehicleType(type1);
|
||||||
|
|
|
||||||
|
|
@ -29,15 +29,6 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import basics.Service;
|
import basics.Service;
|
||||||
import basics.Service.Builder;
|
|
||||||
import basics.route.DriverImpl;
|
|
||||||
import basics.route.ServiceActivity;
|
|
||||||
import basics.route.Start;
|
|
||||||
import basics.route.TourActivities;
|
|
||||||
import basics.route.TourActivity;
|
|
||||||
import basics.route.Vehicle;
|
|
||||||
import basics.route.VehicleImpl;
|
|
||||||
import basics.route.VehicleRoute;
|
|
||||||
import basics.route.DriverImpl.NoDriver;
|
import basics.route.DriverImpl.NoDriver;
|
||||||
|
|
||||||
public class TestVehicleRoute {
|
public class TestVehicleRoute {
|
||||||
|
|
@ -47,7 +38,7 @@ public class TestVehicleRoute {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("loc").setType(VehicleImpl.VehicleType.Builder.newInstance("yo", 0).build()).build();
|
vehicle = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("yo", 0).build()).build();
|
||||||
driver = DriverImpl.noDriver();
|
driver = DriverImpl.noDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,7 +88,7 @@ public class TestVehicleRoute {
|
||||||
@Test
|
@Test
|
||||||
public void whenBuildingEmptyTour_tourIterIteratesOverAnEmptyList(){
|
public void whenBuildingEmptyTour_tourIterIteratesOverAnEmptyList(){
|
||||||
TourActivities tour = new TourActivities();
|
TourActivities tour = new TourActivities();
|
||||||
Vehicle v = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("loc").setType(VehicleImpl.VehicleType.Builder.newInstance("yo", 0).build()).build();
|
Vehicle v = VehicleImpl.VehicleBuilder.newInstance("v").setLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("yo", 0).build()).build();
|
||||||
VehicleRoute route = VehicleRoute.newInstance(tour,DriverImpl.noDriver(),v);
|
VehicleRoute route = VehicleRoute.newInstance(tour,DriverImpl.noDriver(),v);
|
||||||
Iterator<TourActivity> iter = route.getTourActivities().iterator();
|
Iterator<TourActivity> iter = route.getTourActivities().iterator();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
||||||
|
|
@ -34,19 +34,19 @@
|
||||||
<searchStrategy name="randomRuinAndRecreate">
|
<searchStrategy name="randomRuinAndRecreate">
|
||||||
<selector name="selectBest"/>
|
<selector name="selectBest"/>
|
||||||
<acceptor name="schrimpfAcceptance">
|
<acceptor name="schrimpfAcceptance">
|
||||||
<alpha>0.15</alpha>
|
<alpha>0.0</alpha>
|
||||||
<warmup>100</warmup>
|
<warmup>100</warmup>
|
||||||
</acceptor>
|
</acceptor>
|
||||||
<modules>
|
<modules>
|
||||||
<module name="ruin_and_recreate">
|
<module name="ruin_and_recreate">
|
||||||
<ruin name="randomRuin">
|
<ruin name="randomRuin">
|
||||||
<share>0.3</share>
|
<share>0.15</share>
|
||||||
</ruin>
|
</ruin>
|
||||||
<insertion name="bestInsertion"/>
|
<insertion name="bestInsertion"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
</modules>
|
</modules>
|
||||||
<probability>0.3</probability>
|
<probability>0.0</probability>
|
||||||
</searchStrategy>
|
</searchStrategy>
|
||||||
|
|
||||||
<searchStrategy name="radialRuinAndRecreate">
|
<searchStrategy name="radialRuinAndRecreate">
|
||||||
|
|
@ -55,13 +55,13 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module name="ruin_and_recreate">
|
<module name="ruin_and_recreate">
|
||||||
<ruin name="radialRuin">
|
<ruin name="radialRuin">
|
||||||
<share>0.2</share>
|
<share>0.1</share>
|
||||||
</ruin>
|
</ruin>
|
||||||
<insertion name="bestInsertion"/>
|
<insertion name="bestInsertion"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
</modules>
|
</modules>
|
||||||
<probability>0.3</probability>
|
<probability>0.2</probability>
|
||||||
</searchStrategy>
|
</searchStrategy>
|
||||||
|
|
||||||
<searchStrategy name="radialRuinAndRecreate">
|
<searchStrategy name="radialRuinAndRecreate">
|
||||||
|
|
@ -70,13 +70,13 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module name="ruin_and_recreate">
|
<module name="ruin_and_recreate">
|
||||||
<ruin name="radialRuin" id="1">
|
<ruin name="radialRuin" id="1">
|
||||||
<share>0.1</share>
|
<share>0.025</share>
|
||||||
</ruin>
|
</ruin>
|
||||||
<insertion name="bestInsertion"/>
|
<insertion name="bestInsertion"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
</modules>
|
</modules>
|
||||||
<probability>0.4</probability>
|
<probability>0.8</probability>
|
||||||
</searchStrategy>
|
</searchStrategy>
|
||||||
|
|
||||||
</searchStrategies>
|
</searchStrategies>
|
||||||
|
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
package examples;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
import util.Coordinate;
|
|
||||||
import util.Solutions;
|
|
||||||
import algorithms.VehicleRoutingAlgorithms;
|
|
||||||
import analysis.AlgorithmSearchProgressChartListener;
|
|
||||||
import analysis.SolutionPlotter;
|
|
||||||
import analysis.SolutionPrinter;
|
|
||||||
import analysis.StopWatch;
|
|
||||||
import basics.VehicleRoutingAlgorithm;
|
|
||||||
import basics.VehicleRoutingProblem;
|
|
||||||
import basics.VehicleRoutingProblem.FleetSize;
|
|
||||||
import basics.VehicleRoutingProblemSolution;
|
|
||||||
import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
|
|
||||||
import basics.io.VrpXMLReader;
|
|
||||||
import basics.route.Vehicle;
|
|
||||||
import basics.route.VehicleImpl;
|
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
|
|
||||||
public class ConcurrentMultipleDepotExample {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
|
||||||
/*
|
|
||||||
* Read cordeau-instance p01, BUT only its services without any vehicles
|
|
||||||
*/
|
|
||||||
new VrpXMLReader(vrpBuilder).read("input/vrp_cordeau_01.xml");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* add vehicles with its depots
|
|
||||||
* 4 depots:
|
|
||||||
* (20,20)
|
|
||||||
* (30,40)
|
|
||||||
* (50,30)
|
|
||||||
* (60,50)
|
|
||||||
*
|
|
||||||
* each with 4 vehicles each with a capacity of 80
|
|
||||||
*/
|
|
||||||
int nuOfVehicles = 4;
|
|
||||||
int capacity = 80;
|
|
||||||
Coordinate firstDepotCoord = Coordinate.newInstance(20, 20);
|
|
||||||
Coordinate second = Coordinate.newInstance(30, 40);
|
|
||||||
Coordinate third = Coordinate.newInstance(50, 30);
|
|
||||||
Coordinate fourth = Coordinate.newInstance(60, 50);
|
|
||||||
|
|
||||||
int depotCounter = 1;
|
|
||||||
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second,third,fourth)){
|
|
||||||
for(int i=0;i<nuOfVehicles;i++){
|
|
||||||
VehicleType vehicleType = VehicleType.Builder.newInstance(depotCounter + "_" + (i+1) + "_type", capacity).setCostPerDistance(1.0).build();
|
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance(depotCounter + "_" + (i+1) + "_vehicle").setLocationCoord(depotCoord).setType(vehicleType).build();
|
|
||||||
vrpBuilder.addVehicle(vehicle);
|
|
||||||
}
|
|
||||||
depotCounter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* define problem with finite fleet
|
|
||||||
*/
|
|
||||||
vrpBuilder.setFleetSize(FleetSize.FINITE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* build the problem
|
|
||||||
*/
|
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* plot to see how the problem looks like
|
|
||||||
*/
|
|
||||||
// SolutionPlotter.plotVrpAsPNG(vrp, "output/problem01.png", "p01");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Def. executorService and nuOfThreads
|
|
||||||
*/
|
|
||||||
int nuOfThreads = Runtime.getRuntime().availableProcessors() + 2;
|
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(nuOfThreads);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* solve the problem
|
|
||||||
*/
|
|
||||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateConcurrentAlgorithm(vrp, "input/algorithmConfig.xml", executor, nuOfThreads);
|
|
||||||
vra.setNuOfIterations(20000);
|
|
||||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
|
||||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
|
||||||
|
|
||||||
executor.shutdown();
|
|
||||||
// Wait until all threads are finish
|
|
||||||
while (!executor.isTerminated()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
System.out.println("Finished all threads");
|
|
||||||
|
|
||||||
SolutionPrinter.print(Solutions.getBest(solutions));
|
|
||||||
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.getBest(solutions), "output/p01_solution.png", "p01");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,126 +0,0 @@
|
||||||
package examples;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
import util.Coordinate;
|
|
||||||
import util.Solutions;
|
|
||||||
import algorithms.VehicleRoutingAlgorithms;
|
|
||||||
import analysis.AlgorithmSearchProgressChartListener;
|
|
||||||
import analysis.SolutionPlotter;
|
|
||||||
import analysis.SolutionPrinter;
|
|
||||||
import analysis.StopWatch;
|
|
||||||
import basics.VehicleRoutingAlgorithm;
|
|
||||||
import basics.VehicleRoutingProblem;
|
|
||||||
import basics.VehicleRoutingProblem.FleetSize;
|
|
||||||
import basics.VehicleRoutingProblemSolution;
|
|
||||||
import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
|
|
||||||
import basics.io.VrpXMLReader;
|
|
||||||
import basics.route.Vehicle;
|
|
||||||
import basics.route.VehicleImpl;
|
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
|
||||||
|
|
||||||
public class ConcurrentMultipleDepotExampleWithPenaltyVehicles {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
|
||||||
/*
|
|
||||||
* Read cordeau-instance p01, BUT only its services without any vehicles
|
|
||||||
*/
|
|
||||||
new VrpXMLReader(vrpBuilder).read("input/vrp_cordeau_08.xml");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* add vehicles with its depots
|
|
||||||
* 2 depots:
|
|
||||||
* (-33,33)
|
|
||||||
* (33,-33)
|
|
||||||
*
|
|
||||||
* each with 14 vehicles each with a capacity of 500 and a maximum duration of 310
|
|
||||||
*/
|
|
||||||
int nuOfVehicles = 14;
|
|
||||||
int capacity = 500;
|
|
||||||
double maxDuration = 310;
|
|
||||||
Coordinate firstDepotCoord = Coordinate.newInstance(-33, 33);
|
|
||||||
Coordinate second = Coordinate.newInstance(33, -33);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* number of penalty vehicles
|
|
||||||
*/
|
|
||||||
int nuOfPenaltyVehicles = 4;
|
|
||||||
int depotCounter = 1;
|
|
||||||
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second)){
|
|
||||||
for(int i=0;i<nuOfVehicles;i++){
|
|
||||||
VehicleType vehicleType = VehicleType.Builder.newInstance(depotCounter + "_type", capacity).setCostPerDistance(1.0).build();
|
|
||||||
String vehicleId = depotCounter + "_" + (i+1) + "_vehicle";
|
|
||||||
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
|
||||||
vehicleBuilder.setLocationCoord(depotCoord);
|
|
||||||
vehicleBuilder.setType(vehicleType);
|
|
||||||
vehicleBuilder.setLatestArrival(maxDuration);
|
|
||||||
Vehicle vehicle = vehicleBuilder.build();
|
|
||||||
vrpBuilder.addVehicle(vehicle);
|
|
||||||
}
|
|
||||||
// for(int i=0;i<nuOfPenaltyVehicles;i++){
|
|
||||||
VehicleType penaltyType = VehicleType.Builder.newInstance(depotCounter + "_type#penalty", capacity).setFixedCost(50).setCostPerDistance(3.0).build();
|
|
||||||
String vehicleId = depotCounter + "_vehicle#penalty";
|
|
||||||
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
|
||||||
vehicleBuilder.setLocationCoord(depotCoord);
|
|
||||||
vehicleBuilder.setType(penaltyType);
|
|
||||||
vehicleBuilder.setLatestArrival(maxDuration);
|
|
||||||
Vehicle penaltyVehicle = vehicleBuilder.build();
|
|
||||||
vrpBuilder.addVehicle(penaltyVehicle);
|
|
||||||
// }
|
|
||||||
depotCounter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* define problem with finite fleet
|
|
||||||
*/
|
|
||||||
vrpBuilder.setFleetSize(FleetSize.FINITE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* build the problem
|
|
||||||
*/
|
|
||||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* plot to see how the problem looks like
|
|
||||||
*/
|
|
||||||
// SolutionPlotter.plotVrpAsPNG(vrp, "output/problem08.png", "p08");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Def. executorService and nuOfThreads
|
|
||||||
*/
|
|
||||||
int nuOfThreads = Runtime.getRuntime().availableProcessors() + 2;
|
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(nuOfThreads);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* solve the problem
|
|
||||||
*/
|
|
||||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateConcurrentAlgorithm(vrp, "input/algorithmConfig.xml",executor,nuOfThreads);
|
|
||||||
vra.setNuOfIterations(5000);
|
|
||||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
|
||||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
|
||||||
|
|
||||||
executor.shutdown();
|
|
||||||
// Wait until all threads are finish
|
|
||||||
while (!executor.isTerminated()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
System.out.println("Finished all threads");
|
|
||||||
|
|
||||||
SolutionPrinter.print(Solutions.getBest(solutions));
|
|
||||||
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.getBest(solutions), "output/p08_solution.png", "p08");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -18,7 +18,8 @@ import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
|
||||||
import basics.io.VrpXMLReader;
|
import basics.io.VrpXMLReader;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class MultipleDepotExample {
|
public class MultipleDepotExample {
|
||||||
|
|
||||||
|
|
@ -53,7 +54,7 @@ public class MultipleDepotExample {
|
||||||
int depotCounter = 1;
|
int depotCounter = 1;
|
||||||
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second,third,fourth)){
|
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second,third,fourth)){
|
||||||
for(int i=0;i<nuOfVehicles;i++){
|
for(int i=0;i<nuOfVehicles;i++){
|
||||||
VehicleType vehicleType = VehicleType.Builder.newInstance(depotCounter + "_type", capacity).setCostPerDistance(1.0).build();
|
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type", capacity).setCostPerDistance(1.0).build();
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance(depotCounter + "_" + (i+1) + "_vehicle").setLocationCoord(depotCoord).setType(vehicleType).build();
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance(depotCounter + "_" + (i+1) + "_vehicle").setLocationCoord(depotCoord).setType(vehicleType).build();
|
||||||
vrpBuilder.addVehicle(vehicle);
|
vrpBuilder.addVehicle(vehicle);
|
||||||
}
|
}
|
||||||
|
|
@ -73,15 +74,16 @@ public class MultipleDepotExample {
|
||||||
/*
|
/*
|
||||||
* plot to see how the problem looks like
|
* plot to see how the problem looks like
|
||||||
*/
|
*/
|
||||||
SolutionPlotter.plotVrpAsPNG(vrp, "output/problem01.png", "p01");
|
// SolutionPlotter.plotVrpAsPNG(vrp, "output/problem01.png", "p01");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* solve the problem
|
* solve the problem
|
||||||
*/
|
*/
|
||||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
|
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
|
||||||
vra.setNuOfIterations(10000);
|
vra.setNuOfIterations(10000);
|
||||||
|
vra.setPrematureBreak(100);
|
||||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
||||||
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||||
|
|
||||||
SolutionPrinter.print(Solutions.getBest(solutions));
|
SolutionPrinter.print(Solutions.getBest(solutions));
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import algorithms.VehicleRoutingAlgorithms;
|
||||||
import analysis.AlgorithmSearchProgressChartListener;
|
import analysis.AlgorithmSearchProgressChartListener;
|
||||||
import analysis.SolutionPlotter;
|
import analysis.SolutionPlotter;
|
||||||
import analysis.SolutionPrinter;
|
import analysis.SolutionPrinter;
|
||||||
|
import analysis.SolutionPrinter.Print;
|
||||||
import analysis.StopWatch;
|
import analysis.StopWatch;
|
||||||
import basics.VehicleRoutingAlgorithm;
|
import basics.VehicleRoutingAlgorithm;
|
||||||
import basics.VehicleRoutingProblem;
|
import basics.VehicleRoutingProblem;
|
||||||
|
|
@ -16,9 +17,10 @@ import basics.VehicleRoutingProblem.FleetSize;
|
||||||
import basics.VehicleRoutingProblemSolution;
|
import basics.VehicleRoutingProblemSolution;
|
||||||
import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
|
import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
|
||||||
import basics.io.VrpXMLReader;
|
import basics.io.VrpXMLReader;
|
||||||
|
import basics.route.PenaltyVehicleType;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class MultipleDepotExampleWithPenaltyVehicles {
|
public class MultipleDepotExampleWithPenaltyVehicles {
|
||||||
|
|
||||||
|
|
@ -50,7 +52,7 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
||||||
int depotCounter = 1;
|
int depotCounter = 1;
|
||||||
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second)){
|
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second)){
|
||||||
for(int i=0;i<nuOfVehicles;i++){
|
for(int i=0;i<nuOfVehicles;i++){
|
||||||
VehicleType vehicleType = VehicleType.Builder.newInstance(depotCounter + "_type", capacity).setCostPerDistance(1.0).build();
|
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type", capacity).setCostPerDistance(1.0).build();
|
||||||
String vehicleId = depotCounter + "_" + (i+1) + "_vehicle";
|
String vehicleId = depotCounter + "_" + (i+1) + "_vehicle";
|
||||||
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
||||||
vehicleBuilder.setLocationCoord(depotCoord);
|
vehicleBuilder.setLocationCoord(depotCoord);
|
||||||
|
|
@ -59,11 +61,12 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
||||||
Vehicle vehicle = vehicleBuilder.build();
|
Vehicle vehicle = vehicleBuilder.build();
|
||||||
vrpBuilder.addVehicle(vehicle);
|
vrpBuilder.addVehicle(vehicle);
|
||||||
}
|
}
|
||||||
VehicleType penaltyType = VehicleType.Builder.newInstance(depotCounter + "_type#penalty", capacity).setFixedCost(50).setCostPerDistance(3.0).build();
|
VehicleTypeImpl penaltyType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type", capacity).setFixedCost(50).setCostPerDistance(3.0).build();
|
||||||
|
PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType);
|
||||||
String vehicleId = depotCounter + "_vehicle#penalty";
|
String vehicleId = depotCounter + "_vehicle#penalty";
|
||||||
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
||||||
vehicleBuilder.setLocationCoord(depotCoord);
|
vehicleBuilder.setLocationCoord(depotCoord);
|
||||||
vehicleBuilder.setType(penaltyType);
|
vehicleBuilder.setType(penaltyVehicleType);
|
||||||
vehicleBuilder.setLatestArrival(maxDuration);
|
vehicleBuilder.setLatestArrival(maxDuration);
|
||||||
Vehicle penaltyVehicle = vehicleBuilder.build();
|
Vehicle penaltyVehicle = vehicleBuilder.build();
|
||||||
vrpBuilder.addVehicle(penaltyVehicle);
|
vrpBuilder.addVehicle(penaltyVehicle);
|
||||||
|
|
@ -92,12 +95,13 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
||||||
* solve the problem
|
* solve the problem
|
||||||
*/
|
*/
|
||||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
|
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
|
||||||
vra.setNuOfIterations(5000);
|
vra.setNuOfIterations(80000);
|
||||||
|
vra.setPrematureBreak(1000);
|
||||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
||||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||||
|
|
||||||
SolutionPrinter.print(Solutions.getBest(solutions));
|
SolutionPrinter.print(Solutions.getBest(solutions),Print.VERBOSE);
|
||||||
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.getBest(solutions), "output/p08_solution.png", "p08");
|
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.getBest(solutions), "output/p08_solution.png", "p08");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ import basics.io.VrpXMLWriter;
|
||||||
import basics.route.Driver;
|
import basics.route.Driver;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -157,9 +157,9 @@ public class RefuseCollectionExample {
|
||||||
/*
|
/*
|
||||||
* create vehicle-type and vehicle
|
* create vehicle-type and vehicle
|
||||||
*/
|
*/
|
||||||
VehicleType.Builder typeBuilder = VehicleType.Builder.newInstance("vehicle-type", 23);
|
VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance("vehicle-type", 23);
|
||||||
typeBuilder.setCostPerDistance(1.0);
|
typeBuilder.setCostPerDistance(1.0);
|
||||||
VehicleType bigType = typeBuilder.build();
|
VehicleTypeImpl bigType = typeBuilder.build();
|
||||||
|
|
||||||
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance("vehicle");
|
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance("vehicle");
|
||||||
vehicleBuilder.setLocationId("1");
|
vehicleBuilder.setLocationId("1");
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ import basics.io.VrpXMLWriter;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleBuilder;
|
import basics.route.VehicleImpl.VehicleBuilder;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class SimpleExample {
|
public class SimpleExample {
|
||||||
|
|
||||||
|
|
@ -45,8 +46,8 @@ public class SimpleExample {
|
||||||
/*
|
/*
|
||||||
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
|
* get a vehicle type-builder and build a type with the typeId "vehicleType" and a capacity of 2
|
||||||
*/
|
*/
|
||||||
VehicleType.Builder vehicleTypeBuilder = VehicleImpl.VehicleType.Builder.newInstance("vehicleType", 2);
|
VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance("vehicleType", 2);
|
||||||
VehicleType vehicleType = vehicleTypeBuilder.build();
|
VehicleTypeImpl vehicleType = vehicleTypeBuilder.build();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
|
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class SolomonExample {
|
||||||
* The algorithm can be defined and configured in an xml-file.
|
* The algorithm can be defined and configured in an xml-file.
|
||||||
*/
|
*/
|
||||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||||
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener(pngFileName));
|
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
|
||||||
/*
|
/*
|
||||||
* Solve the problem.
|
* Solve the problem.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ import util.Coordinate;
|
||||||
|
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
import basics.Service;
|
import basics.Service;
|
||||||
import basics.VehicleRoutingProblem;
|
import basics.VehicleRoutingProblem;
|
||||||
import basics.VehicleRoutingProblem.FleetSize;
|
import basics.VehicleRoutingProblem.FleetSize;
|
||||||
|
|
@ -92,7 +93,7 @@ public class ChristophidesReader {
|
||||||
else if(counter == 1){
|
else if(counter == 1){
|
||||||
String id = Integer.valueOf(counter).toString();
|
String id = Integer.valueOf(counter).toString();
|
||||||
Coordinate depotCoord = makeCoord(tokens[0].trim(),tokens[1].trim());
|
Coordinate depotCoord = makeCoord(tokens[0].trim(),tokens[1].trim());
|
||||||
VehicleType vehicleType = VehicleImpl.VehicleType.Builder.newInstance("christophidesType", vehicleCapacity).
|
VehicleTypeImpl vehicleType = VehicleType.Builder.newInstance("christophidesType", vehicleCapacity).
|
||||||
setCostPerDistance(1.0).setFixedCost(100).build();
|
setCostPerDistance(1.0).setFixedCost(100).build();
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("christophidesVehicle").setLatestArrival(endTime).setLocationId(id).setLocationCoord(depotCoord).
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("christophidesVehicle").setLatestArrival(endTime).setLocationId(id).setLocationCoord(depotCoord).
|
||||||
setType(vehicleType).build();
|
setType(vehicleType).build();
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ import util.Coordinate;
|
||||||
import basics.VehicleRoutingProblem.FleetSize;
|
import basics.VehicleRoutingProblem.FleetSize;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleBuilder;
|
import basics.route.VehicleImpl.VehicleBuilder;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
import basics.Service;
|
import basics.Service;
|
||||||
import basics.VehicleRoutingProblem;
|
import basics.VehicleRoutingProblem;
|
||||||
|
|
||||||
|
|
@ -100,7 +101,7 @@ public class CordeauReader {
|
||||||
int duration = Integer.parseInt(tokens[0].trim());
|
int duration = Integer.parseInt(tokens[0].trim());
|
||||||
if(duration == 0) duration = 999999;
|
if(duration == 0) duration = 999999;
|
||||||
int capacity = Integer.parseInt(tokens[1].trim());
|
int capacity = Integer.parseInt(tokens[1].trim());
|
||||||
VehicleType vehicleType = VehicleImpl.VehicleType.Builder.newInstance(counter + "_cordeauType", capacity).
|
VehicleTypeImpl vehicleType = VehicleType.Builder.newInstance(counter + "_cordeauType", capacity).
|
||||||
setCostPerDistance(1.0).setFixedCost(0).build();
|
setCostPerDistance(1.0).setFixedCost(0).build();
|
||||||
List<VehicleBuilder> builders = new ArrayList<VehicleImpl.VehicleBuilder>();
|
List<VehicleBuilder> builders = new ArrayList<VehicleImpl.VehicleBuilder>();
|
||||||
for(int vehicleCounter=0;vehicleCounter<nOfVehiclesAtEachDepot;vehicleCounter++){
|
for(int vehicleCounter=0;vehicleCounter<nOfVehiclesAtEachDepot;vehicleCounter++){
|
||||||
|
|
@ -134,7 +135,7 @@ public class CordeauReader {
|
||||||
}
|
}
|
||||||
if(addPenaltyVehicles){
|
if(addPenaltyVehicles){
|
||||||
for(int i=0;i<5;i++){
|
for(int i=0;i<5;i++){
|
||||||
VehicleType penaltyType = VehicleImpl.VehicleType.Builder.newInstance(counter + "_penaltyType", cap).
|
VehicleTypeImpl penaltyType = VehicleType.Builder.newInstance(counter + "_penaltyType", cap).
|
||||||
setCostPerDistance(3.0).setFixedCost(50).build();
|
setCostPerDistance(3.0).setFixedCost(50).build();
|
||||||
VehicleImpl penaltyVehicle = VehicleImpl.VehicleBuilder.newInstance(counter + "_" + (i+1) + "_penaltyVehicle").setLatestArrival(latestArrTime)
|
VehicleImpl penaltyVehicle = VehicleImpl.VehicleBuilder.newInstance(counter + "_" + (i+1) + "_penaltyVehicle").setLatestArrival(latestArrTime)
|
||||||
.setType(penaltyType).setLocationCoord(coord).build();
|
.setType(penaltyType).setLocationCoord(coord).build();
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@ import basics.VehicleRoutingProblem.FleetSize;
|
||||||
import basics.route.TimeWindow;
|
import basics.route.TimeWindow;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
|
|
||||||
public class LuiShenReader {
|
public class LuiShenReader {
|
||||||
|
|
||||||
|
|
@ -122,10 +123,10 @@ public class LuiShenReader {
|
||||||
int capacity = Integer.parseInt(tokens[capacityColumn]);
|
int capacity = Integer.parseInt(tokens[capacityColumn]);
|
||||||
int fixCost = Integer.parseInt(tokens[costScenarioColumn]);
|
int fixCost = Integer.parseInt(tokens[costScenarioColumn]);
|
||||||
|
|
||||||
VehicleType.Builder typeBuilder = VehicleImpl.VehicleType.Builder.newInstance(vehicleId, capacity);
|
VehicleTypeImpl.Builder typeBuilder = VehicleType.Builder.newInstance(vehicleId, capacity);
|
||||||
typeBuilder.setFixedCost(fixCost).setCostPerDistance(1.0);
|
typeBuilder.setFixedCost(fixCost).setCostPerDistance(1.0);
|
||||||
|
|
||||||
VehicleType type = typeBuilder.build();
|
VehicleTypeImpl type = typeBuilder.build();
|
||||||
|
|
||||||
Vehicle reprVehicle = VehicleImpl.VehicleBuilder.newInstance(vehicleId).setEarliestStart(start).setLatestArrival(end).
|
Vehicle reprVehicle = VehicleImpl.VehicleBuilder.newInstance(vehicleId).setEarliestStart(start).setLatestArrival(end).
|
||||||
setLocationId(locationId).setLocationCoord(coord).setType(type).build();
|
setLocationId(locationId).setLocationCoord(coord).setType(type).build();
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ import util.Coordinate;
|
||||||
import basics.route.TimeWindow;
|
import basics.route.TimeWindow;
|
||||||
import basics.route.Vehicle;
|
import basics.route.Vehicle;
|
||||||
import basics.route.VehicleImpl;
|
import basics.route.VehicleImpl;
|
||||||
import basics.route.VehicleImpl.VehicleType;
|
import basics.route.VehicleType;
|
||||||
|
import basics.route.VehicleTypeImpl;
|
||||||
import basics.Service;
|
import basics.Service;
|
||||||
import basics.VehicleRoutingProblem;
|
import basics.VehicleRoutingProblem;
|
||||||
import basics.VehicleRoutingProblem.FleetSize;
|
import basics.VehicleRoutingProblem.FleetSize;
|
||||||
|
|
@ -96,10 +97,10 @@ public class SolomonReader {
|
||||||
double end = Double.parseDouble(tokens[5])*timeProjectionFactor;
|
double end = Double.parseDouble(tokens[5])*timeProjectionFactor;
|
||||||
double serviceTime = Double.parseDouble(tokens[6])*timeProjectionFactor;
|
double serviceTime = Double.parseDouble(tokens[6])*timeProjectionFactor;
|
||||||
if(counter == 10){
|
if(counter == 10){
|
||||||
VehicleType.Builder typeBuilder = VehicleImpl.VehicleType.Builder.newInstance("solomonType", vehicleCapacity);
|
VehicleTypeImpl.Builder typeBuilder = VehicleType.Builder.newInstance("solomonType", vehicleCapacity);
|
||||||
typeBuilder.setCostPerDistance(1.0*variableCostProjectionFactor).setFixedCost(100);
|
typeBuilder.setCostPerDistance(1.0*variableCostProjectionFactor).setFixedCost(100);
|
||||||
|
|
||||||
VehicleType vehicleType = typeBuilder.build();
|
VehicleTypeImpl vehicleType = typeBuilder.build();
|
||||||
|
|
||||||
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("solomonVehicle").setEarliestStart(start).setLatestArrival(end)
|
Vehicle vehicle = VehicleImpl.VehicleBuilder.newInstance("solomonVehicle").setEarliestStart(start).setLatestArrival(end)
|
||||||
.setLocationId(customerId).setLocationCoord(coord).setType(vehicleType).build();
|
.setLocationId(customerId).setLocationCoord(coord).setType(vehicleType).build();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue