public interface IConstraintResource extends IConstraint
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);
Modifier and Type | Method and Description |
---|---|
boolean |
addResource(String resId,
int priority)
Checks whether the
resId is not null or empty and the priority
is not below or equal 0 , then sets the AbstractResourceConstraint.maxPriority to priority . |
boolean |
addResources(List<String> ressIds,
List<Integer> priorities)
Checks if neither the
ressIds nor the priorities are null or empty and
that they are the same size, then adds a resource AbstractResourceConstraint.addResource(String, int)
for every ressIds . |
int |
getMaxPriority()
Gets the
AbstractResourceConstraint.maxPriority . |
int |
getPriority(String resId)
Gets the priority of the resource id.
|
List<String> |
getResourceIds()
Gets an ArrayList of the resource ids.
|
Map<String,Integer> |
getResPriorityMap() |
void |
removeResource(String resId)
If the
Resource that is to be removed does not have the AbstractResourceConstraint.maxPriority , it is removed. |
assessConstraint, getTitle, hasMembers, isHard, isSatisfied, setIsHard
boolean addResource(String resId, int priority)
resId
is not null
or empty
and the priority
is not below or equal 0
, then sets the AbstractResourceConstraint.maxPriority
to priority
.resId
- the string resource idpriority
- the int priorityboolean addResources(List<String> ressIds, List<Integer> priorities)
ressIds
nor the priorities
are null
or empty
and
that they are the same size, then adds a resource AbstractResourceConstraint.addResource(String, int)
for every ressIds
.ressIds
- the list of string idspriorities
- the list of integer prioritiesvoid removeResource(String resId)
Resource
that is to be removed does not have the AbstractResourceConstraint.maxPriority
, it is removed.
Otherwise, the priority
of the Resource
is set to 0
and the AbstractResourceConstraint.maxPriority
is set to the priority
of one of the remaining Resources
. Then the Resource
with the given resId
is removed.
resId
- the string id of the resource to be removedList<String> getResourceIds()
int getPriority(String resId)
resId
- string of the resource idint getMaxPriority()
AbstractResourceConstraint.maxPriority
.Copyright © 2017–2023 DNA Evolutions GmbH. All rights reserved.