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

driverId_in_service_and_shipment (#64)

* driverId_in_service_and_shipment

* add to interface

* timeWindowConstraintsSet true if instance of time window constraint

* inform listeners if needed

* fix
This commit is contained in:
kandelirina 2018-09-06 16:37:25 +03:00 committed by GitHub
parent dfd84ee5db
commit ee73118f20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 0 deletions

View file

@ -94,6 +94,16 @@ public abstract class AbstractInsertionStrategy implements InsertionStrategy {
return badJobs;
}
@Override
public Collection<Job> insertJobs(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs, boolean informInsertionStarts, boolean informInsertionEnds) {
if (informInsertionStarts)
insertionsListeners.informInsertionStarts(vehicleRoutes, unassignedJobs);
Collection<Job> badJobs = insertUnassignedJobs(vehicleRoutes, unassignedJobs);
if (informInsertionEnds)
insertionsListeners.informInsertionEndsListeners(vehicleRoutes);
return badJobs;
}
public void markUnassigned(Job unassigned, List<String> reasons) {
insertionsListeners.informJobUnassignedListeners(unassigned, reasons);
}

View file

@ -46,4 +46,6 @@ public interface InsertionStrategy {
public Collection<InsertionListener> getListeners();
public Collection<Job> insertJobs(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs, boolean informInsertionStarts, boolean informInsertionEnds);
}

View file

@ -168,6 +168,9 @@ public class ConstraintManager implements HardActivityConstraint, HardRouteConst
// public void add
public void addConstraint(HardActivityConstraint actLevelConstraint, Priority priority) {
if (actLevelConstraint instanceof VehicleDependentTimeWindowConstraints) {
timeWindowConstraintsSet = true;
}
actLevelConstraintManager.addConstraint(actLevelConstraint, priority);
}

View file

@ -65,4 +65,5 @@ public interface Job extends HasId, HasIndex {
public double getMaxTimeInVehicle();
public String getDriverId();
}

View file

@ -93,6 +93,8 @@ public class Service extends AbstractJob {
protected double maxTimeInVehicle = Double.MAX_VALUE;
protected String driverId = null;
Builder(String id){
this.id = id;
timeWindows = new TimeWindowsImpl();
@ -260,6 +262,11 @@ public class Service extends AbstractJob {
// this.maxTimeInVehicle = maxTimeInVehicle;
// return this;
}
public Builder<T> setDriverId(String driverId) {
this.driverId = driverId;
return this;
}
}
private final String id;
@ -282,6 +289,8 @@ public class Service extends AbstractJob {
private final double maxTimeInVehicle;
private final String driverId;
Service(Builder<?> builder) {
setUserData(builder.userData);
id = builder.id;
@ -294,6 +303,7 @@ public class Service extends AbstractJob {
timeWindows = builder.timeWindows;
priority = builder.priority;
maxTimeInVehicle = builder.maxTimeInVehicle;
driverId = builder.driverId;
}
public Collection<TimeWindow> getTimeWindows(){
@ -414,4 +424,7 @@ public class Service extends AbstractJob {
return this.maxTimeInVehicle;
}
public String getDriverId() {
return driverId;
}
}

View file

@ -89,6 +89,8 @@ public class Shipment extends AbstractJob {
public double maxTimeInVehicle = Double.MAX_VALUE;
private String driverId = null;
/**
* Returns new instance of this builder.
*
@ -239,6 +241,10 @@ public class Shipment extends AbstractJob {
return this;
}
public Builder setDriverId(String driverId) {
this.driverId = driverId;
return this;
}
/**
* Builds the shipment.
@ -368,6 +374,8 @@ public class Shipment extends AbstractJob {
private final double maxTimeInVehicle;
private final String driverId;
Shipment(Builder builder) {
setUserData(builder.userData);
this.id = builder.id;
@ -382,6 +390,7 @@ public class Shipment extends AbstractJob {
this.pickupTimeWindows = builder.pickupTimeWindows;
this.priority = builder.priority;
this.maxTimeInVehicle = builder.maxTimeInVehicle;
this.driverId = builder.driverId;
}
@Override
@ -520,4 +529,8 @@ public class Shipment extends AbstractJob {
public double getMaxTimeInVehicle() {
return maxTimeInVehicle;
}
public String getDriverId() {
return driverId;
}
}