Interface IConstraintResource
- All Superinterfaces:
IConstraint,Serializable
- All Known Implementing Classes:
AbstractResourceConstraint,BannedResourceConstraint,BindingResourceConstraint,ExcludingResourceConstraint,MandatoryResourceConstraint,PreferredResourceConstraint,UnPreferredResource,UnPreferredResourceConstraint
A
ConstraintResource is a Constraint that can be added to a INode which then sets that given IResource as a hard preferred Constraint for that
Node.
This interface provides methods to add and remove Resources to that
Constraint, inquire about their id and priority.
Implementation example:
CapacityResource resource =
new CapacityResource(
"Jack", 50.775346, 6.083887, maxWorkingTime, maxDistanceKmW, workingHours);
IConstraintResource jackMandatoryConstraint = new MandatoryResourceConstraint();
jackMandatoryConstraint.addResource("Jack", 10);
TimeWindowGeoNode aachen =
new TimeWindowGeoNode("Aachen", 50.775346, 6.083887, weeklyOpeningHours, visitDuration, 1);
aachen.addConstraint(jackMandConstraint);
this.addElement(aachen);
- Since:
- 07/01/2019
- Version:
- 13/08/2019
- Author:
- DNA
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddResource(String resId, int priority) Checks whether theresIdis notnulloremptyand thepriorityis not below or equal0, then sets theAbstractResourceConstraint.maxPrioritytopriority.booleanaddResources(List<String> ressIds, List<Integer> priorities) Checks if neither theressIdsnor theprioritiesarenulloremptyand that they are the same size, then adds a resourceAbstractResourceConstraint.addResource(String, int)for everyressIds.intGets theAbstractResourceConstraint.maxPriority.intgetPriority(String resId) Gets the priority of the resource id.Gets an ArrayList of the resource ids.voidremoveResource(String resId) If theResourcethat is to be removed does not have theAbstractResourceConstraint.maxPriority, it is removed.Methods inherited from interface com.dna.jopt.member.unit.condition.IConstraint
assessConstraint, getTitle, hasMembers, isHard, isSatisfied, setIsHard
-
Method Details
-
addResource
Checks whether theresIdis notnulloremptyand thepriorityis not below or equal0, then sets theAbstractResourceConstraint.maxPrioritytopriority.- Parameters:
resId- the string resource idpriority- the int priority- Returns:
- true, if was added
-
addResources
Checks if neither theressIdsnor theprioritiesarenulloremptyand that they are the same size, then adds a resourceAbstractResourceConstraint.addResource(String, int)for everyressIds.- Parameters:
ressIds- the list of string idspriorities- the list of integer priorities- Returns:
- true, if all were added
-
removeResource
If theResourcethat is to be removed does not have theAbstractResourceConstraint.maxPriority, it is removed.Otherwise, the
priorityof theResourceis set to0and theAbstractResourceConstraint.maxPriorityis set to thepriorityof one of the remainingResources. Then theResourcewith the givenresIdis removed.- Parameters:
resId- the string id of the resource to be removed
-
getResourceIds
Gets an ArrayList of the resource ids.- Returns:
- an arrayList with a set view of the keys contained in this map
-
getPriority
Gets the priority of the resource id.- Parameters:
resId- string of the resource id- Returns:
- the priority of the resource
-
getMaxPriority
int getMaxPriority()Gets theAbstractResourceConstraint.maxPriority.- Returns:
- the max priority
-
getResPriorityMap
-