mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
model and test priorities - #242
This commit is contained in:
parent
ee3b1589ba
commit
6cf2ac2d56
6 changed files with 184 additions and 16 deletions
|
|
@ -39,7 +39,6 @@ import java.util.Collection;
|
|||
*/
|
||||
public class Service extends AbstractJob {
|
||||
|
||||
|
||||
/**
|
||||
* Builder that builds a service.
|
||||
*
|
||||
|
|
@ -48,6 +47,8 @@ public class Service extends AbstractJob {
|
|||
public static class Builder<T extends Service> {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new instance of builder that builds a service.
|
||||
*
|
||||
|
|
@ -86,6 +87,8 @@ public class Service extends AbstractJob {
|
|||
|
||||
private boolean twAdded = false;
|
||||
|
||||
private int priority = 2;
|
||||
|
||||
Builder(String id){
|
||||
this.id = id;
|
||||
timeWindows = new TimeWindowsImpl();
|
||||
|
|
@ -206,6 +209,20 @@ public class Service extends AbstractJob {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set priority to service. Only 1 = high priority, 2 = medium and 3 = low are allowed.
|
||||
* <p>
|
||||
* Default is 2 = medium.
|
||||
*
|
||||
* @param priority
|
||||
* @return builder
|
||||
*/
|
||||
public Builder<T> setPriority(int priority) {
|
||||
if(priority < 1 || priority > 3) throw new IllegalStateException("incorrect priority. only 1 = high, 2 = medium and 3 = low is allowed");
|
||||
this.priority = priority;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String id;
|
||||
|
|
@ -226,6 +243,8 @@ public class Service extends AbstractJob {
|
|||
|
||||
private final TimeWindows timeWindowManager;
|
||||
|
||||
private final int priority;
|
||||
|
||||
Service(Builder builder) {
|
||||
id = builder.id;
|
||||
serviceTime = builder.serviceTime;
|
||||
|
|
@ -236,6 +255,7 @@ public class Service extends AbstractJob {
|
|||
name = builder.name;
|
||||
location = builder.location;
|
||||
timeWindowManager = builder.timeWindows;
|
||||
priority = builder.priority;
|
||||
}
|
||||
|
||||
public Collection<TimeWindow> getTimeWindows(){
|
||||
|
|
@ -338,4 +358,15 @@ public class Service extends AbstractJob {
|
|||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get priority of service. Only 1 = high priority, 2 = medium and 3 = low are allowed.
|
||||
* <p>
|
||||
* Default is 2 = medium.
|
||||
*
|
||||
* @return priority
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public class Shipment extends AbstractJob {
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Builder that builds the shipment.
|
||||
*
|
||||
|
|
@ -85,6 +86,8 @@ public class Shipment extends AbstractJob {
|
|||
|
||||
private TimeWindowsImpl pickupTimeWindows;
|
||||
|
||||
private int priority = 2;
|
||||
|
||||
/**
|
||||
* Returns new instance of this builder.
|
||||
*
|
||||
|
|
@ -263,6 +266,20 @@ public class Shipment extends AbstractJob {
|
|||
public Builder addPickupTimeWindow(double earliest, double latest) {
|
||||
return addPickupTimeWindow(TimeWindow.newInstance(earliest, latest));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set priority to shipment. Only 1 = high priority, 2 = medium and 3 = low are allowed.
|
||||
* <p>
|
||||
* Default is 2 = medium.
|
||||
*
|
||||
* @param priority
|
||||
* @return builder
|
||||
*/
|
||||
public Builder setPriority(int priority) {
|
||||
if(priority < 1 || priority > 3) throw new IllegalStateException("incorrect priority. only 1 = high, 2 = medium and 3 = low is allowed");
|
||||
this.priority = priority;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String id;
|
||||
|
|
@ -289,6 +306,8 @@ public class Shipment extends AbstractJob {
|
|||
|
||||
private final TimeWindowsImpl pickupTimeWindows;
|
||||
|
||||
private final int priority;
|
||||
|
||||
Shipment(Builder builder) {
|
||||
this.id = builder.id;
|
||||
this.pickupServiceTime = builder.pickupServiceTime;
|
||||
|
|
@ -302,6 +321,7 @@ public class Shipment extends AbstractJob {
|
|||
this.deliveryLocation_ = builder.deliveryLocation_;
|
||||
this.deliveryTimeWindows = builder.deliveryTimeWindows;
|
||||
this.pickupTimeWindows = builder.pickupTimeWindows;
|
||||
this.priority = builder.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -409,5 +429,14 @@ public class Shipment extends AbstractJob {
|
|||
return name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get priority of shipment. Only 1 = high priority, 2 = medium and 3 = low are allowed.
|
||||
* <p>
|
||||
* Default is 2 = medium.
|
||||
*
|
||||
* @return priority
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue