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 TypeMethodDescriptionboolean
addResource
(String resId, int priority) Checks whether theresId
is notnull
orempty
and thepriority
is not below or equal0
, then sets theAbstractResourceConstraint.maxPriority
topriority
.boolean
addResources
(List<String> ressIds, List<Integer> priorities) Checks if neither theressIds
nor thepriorities
arenull
orempty
and that they are the same size, then adds a resourceAbstractResourceConstraint.addResource(String, int)
for everyressIds
.int
Gets theAbstractResourceConstraint.maxPriority
.int
getPriority
(String resId) Gets the priority of the resource id.Gets an ArrayList of the resource ids.void
removeResource
(String resId) If theResource
that 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 theresId
is notnull
orempty
and thepriority
is not below or equal0
, then sets theAbstractResourceConstraint.maxPriority
topriority
.- Parameters:
resId
- the string resource idpriority
- the int priority- Returns:
- true, if was added
-
addResources
Checks if neither theressIds
nor thepriorities
arenull
orempty
and 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 theResource
that is to be removed does not have theAbstractResourceConstraint.maxPriority
, it is removed.Otherwise, the
priority
of theResource
is set to0
and theAbstractResourceConstraint.maxPriority
is set to thepriority
of one of the remainingResources
. Then theResource
with the givenresId
is 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
-