Interface IConstraintResource

All Superinterfaces:
IConstraint, Serializable
All Known Implementing Classes:
AbstractResourceConstraint, BannedResourceConstraint, BindingResourceConstraint, ExcludingResourceConstraint, MandatoryResourceConstraint, PreferredResourceConstraint, UnPreferredResource, UnPreferredResourceConstraint

public interface IConstraintResource extends IConstraint
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 Details

    • addResource

      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.
      Parameters:
      resId - the string resource id
      priority - the int priority
      Returns:
      true, if was added
    • addResources

      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.
      Parameters:
      ressIds - the list of string ids
      priorities - the list of integer priorities
      Returns:
      true, if all were added
    • removeResource

      void removeResource(String resId)
      If the 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.

      Parameters:
      resId - the string id of the resource to be removed
    • getResourceIds

      List<String> getResourceIds()
      Gets an ArrayList of the resource ids.
      Returns:
      an arrayList with a set view of the keys contained in this map
    • getPriority

      int getPriority(String resId)
      Gets the priority of the resource id.
      Parameters:
      resId - string of the resource id
      Returns:
      the priority of the resource
    • getMaxPriority

      int getMaxPriority()
      Gets the AbstractResourceConstraint.maxPriority.
      Returns:
      the max priority
    • getResPriorityMap

      Map<String,Integer> getResPriorityMap()