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

added skills to jobs

This commit is contained in:
oblonski 2014-06-28 23:22:32 +02:00
parent 64ed26e12e
commit 2cd2f54b27
6 changed files with 123 additions and 0 deletions

View file

@ -16,6 +16,10 @@
******************************************************************************/
package jsprit.core.problem.job;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import jsprit.core.problem.Capacity;
import jsprit.core.problem.solution.route.activity.TimeWindow;
import jsprit.core.util.Coordinate;
@ -67,6 +71,8 @@ public class Service implements Job {
protected Capacity capacity;
protected Set<String> skills = new HashSet<String>();
/**
* Constructs the builder.
*
@ -179,6 +185,11 @@ public class Service implements Job {
capacity = capacityBuilder.build();
return new Service(this);
}
public Builder addSkill(String string) {
skills.add(string.toLowerCase());
return this;
}
}
@ -196,6 +207,8 @@ public class Service implements Job {
private final TimeWindow timeWindow;
private final Capacity size;
private final Set<String> skills;
Service(Builder builder){
id = builder.id;
@ -205,6 +218,7 @@ public class Service implements Job {
timeWindow = builder.timeWindow;
type = builder.type;
size = builder.capacity;
skills = builder.skills;
}
@Override
@ -299,5 +313,24 @@ public class Service implements Job {
public Capacity getSize() {
return size;
}
/**
* Returns set of required skills. All skills are in lower case.
*
* @return
*/
public Set<String> getRequiredSkills() {
return Collections.unmodifiableSet(skills);
}
/**
* Returns true if this contains requiredSkill. Not case sensitive.
*
* @param requiredSkill
* @return
*/
public boolean requiresSkill(String requiredSkill){
return skills.contains(requiredSkill.toLowerCase());
}
}

View file

@ -1,5 +1,9 @@
package jsprit.core.problem.job;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import jsprit.core.problem.Capacity;
import jsprit.core.problem.solution.route.activity.TimeWindow;
import jsprit.core.util.Coordinate;
@ -53,6 +57,8 @@ public class Shipment implements Job{
private Capacity capacity;
private Set<String> skills = new HashSet<String>();
/**
* Returns new instance of this builder.
*
@ -230,6 +236,11 @@ public class Shipment implements Job{
return new Shipment(this);
}
public Builder addSkill(String string) {
skills.add(string.toLowerCase());
return this;
}
}
@ -252,6 +263,8 @@ public class Shipment implements Job{
private final TimeWindow pickupTimeWindow;
private final Capacity capacity;
private final Set<String> skills;
/**
@ -270,6 +283,7 @@ public class Shipment implements Job{
this.deliveryServiceTime = builder.deliveryServiceTime;
this.deliveryTimeWindow = builder.deliveryTimeWindow;
this.capacity = builder.capacity;
this.skills = builder.skills;
}
@Override
@ -386,5 +400,11 @@ public class Shipment implements Job{
return capacity;
}
public Set<String> getRequiredSkills() {
return Collections.unmodifiableSet(skills);
}
public boolean requiresSkill(String requiredSkill){
return skills.contains(requiredSkill.toLowerCase());
}
}