Interface IWorkingHours

All Superinterfaces:
Comparable<IDutyHours>, IDutyHours, Serializable
All Known Implementing Classes:
WorkingHours

public interface IWorkingHours extends IDutyHours
The interface IWorkingHours. WorkingHours are the schedule in which the work orders of a specific resources have to be performed. Through WorkingHours a resources can have a different schedule for each day, be allowed to stay over night and have its total working time limited.

IWorkingHours and IOpeningHours are both extend IDutyHours, however IWorkingHour does have improved functionality, IOpeningHours does not.

Implementation example:


 List<IWorkingHours> workingHours = new ArrayList<IWorkingHours>();
     workingHours.add(
         new WorkingHours(
             ZonedDateTime.of(2020, MAY, 6, 8, 0, 0, 0, ZoneId.of("Europe/Berlin")),
             ZonedDateTime.of(2020, MAY, 6, 17, 0, 0, 0, ZoneId.of("Europe/Berlin"))));
 
Since:
28/08/2018
Version:
07/10/2019
Author:
DNA
  • Method Details

    • getMaxHours

      double getMaxHours()
      Gets maximum number of hours a Resource is allowed to work per day in hours. By default it is not usable and the value is -1.
      Returns:
      the double maxHours.
    • getMaxDistanceKm

      double getMaxDistanceKm()
      Gets the WorkingHours.maxDistance, which is the maximal distance in km a Resource is allowed to travel without a IViolation per day.
      Returns:
      double maxDistance in km. By default it is not usable and the value is -1.
    • getIsAvailableForStay

      boolean getIsAvailableForStay()
      Gets if the Resource is allowed to do an overnight stay. The Node also needs INode.setIsStayNode(boolean) set to true so this function can be used.

      This method is specific for the set WorkingHours and can therefore be specific for certain days in the week (no overnight stays on Fridays.

      Returns:
      boolean, the default value is true.
    • setIsAvailableForStay

      void setIsAvailableForStay(boolean isAvailableForStay)
      Sets if the Resource is allowed for an overnight stay instead of returning to the starting location. The Node also needs INode.setIsStayNode(boolean) set to true so this function can be used.
      Parameters:
      isAvailableForStay - boolean, the default value is true.
    • setMaxWorkingTime

      void setMaxWorkingTime(Duration maxWorkingTime)
      Sets the maximum number of hours a Resource is allowed to work per day.
      Parameters:
      maxWorkingTime - the maximal working time
    • setMaxHours

      @Deprecated void setMaxHours(Duration maxWorkingTime)
      Deprecated.
      please use setMaxWorkingTime(Duration) instead
      Decrecated method

      Sets the WorkingHours.maxHours a Resource is allowed to work per day.

      Parameters:
      maxWorkingTime - the double to be set for maxHours
    • setMaxDistance

      void setMaxDistance(javax.measure.Quantity<javax.measure.quantity.Length> maxDistance)
      Sets the maximal distance that a Resource is allowed to travel per day, cannot be null.
      Parameters:
      maxDistance - the quantity, will be casted to kilometre
    • setIsClosedRoute

      void setIsClosedRoute(boolean isClosedRoute)
      Sets the Route to a closed Route. A closed Route is a Route where the Resource is going to its home afterwards. An open Route is a Route where the Resource is simply staying at the last Node if OverNightStay also has been activated or where the Resource has to travel home outside of the WorkingHours. The default value is true.
      Parameters:
      isClosedRoute - the boolean if the Route is a closed Route
      See Also:
    • isClosedRoute

      boolean isClosedRoute()
      Checks if the route is closed or not, the default value is false. A closed Route is a Route where the Resource is going to its home afterwards. An open Route is a Route where the Resource is simply staying at the last Node if OverNightStay also has been activated or where the Resource has to travel home outside of the WorkingHours. The default value is true.
      Returns:
      the boolean isClosedRoute
      See Also:
    • setLocalStayOutCycleDefinition

      void setLocalStayOutCycleDefinition(Duration cycle, LocalDate cycleStart)
      Sets the Duration of the cycle within which the maximum number of overnight stays are allowed and within which the minimum recovery time (WorkingHours without overnight stays) has to be observed. The recovery time is set in IResource.setStayOutCycleDefinition(Duration, LocalDate).

      Without setting the cycle the maximal number of overnight stays will not be refreshed and count for the full duration of the WorkingHours. The cycle can be applied to the local Resource which means it will stay the same for this Resource throughout the Optimization. If like here set locally it is only valid for this WorkingHours and the cycle can change depending on the dates or time in the week. It can for example be set that no overnight stays are allowed on Fridays.

      Parameters:
      cycle - duration of the cycle
      cycleStart - the localDate of the cycle start
    • getLocalStayOutCycle

      Optional<Duration> getLocalStayOutCycle()
      Gets the Duration of the potential local stayout cycle.

      For more information please see setLocalStayOutCycleDefinition(Duration, LocalDate).

      Returns:
      the duration of the local stayOutCycle
    • getLocalStayOutCycleStart

      Optional<LocalDate> getLocalStayOutCycleStart()
      Gets the start of the local stayout cycle.

      For more information please see setLocalStayOutCycleDefinition(Duration, LocalDate).

      Returns:
      the date of the localStayCycleStart
    • setLocalMaxRouteStartReductionTime

      boolean setLocalMaxRouteStartReductionTime(Duration maxRouteStartReductionTime, boolean isOnlyUsedForDriving)
      Sets the maximum time which the Resource can be expected to drive to the first Node in its private time.

      If the OpeningHours of a Node and the WorkingHours of a Resource start at 8 the driving time is an hour and the Resource's localMaxRouteStartReductionTime is 30 Minutes the Resource will start driving towards the Node at 7.30 (outside of its WorkingHours) and arrive there at 8.30.

      The Boolean defines whether the localMaxRouteStartReductionTime can only be used for driving or not and is usually set to true. The Resource can not work in the localMaxRouteStartReductionTime in that case.

      If like here set locally the localMaxRouteStartReductionTime is only valid for these specific WorkingHours.

      Parameters:
      maxRouteStartReductionTime - the duration of the maxRouteStartReductionTime
      isOnlyUsedForDriving - the boolean whether the time can only be used for driving
      Returns:
      false if reductionTime is null or negative
    • setLocalMaxRouteStartReductionTimePillar

      boolean setLocalMaxRouteStartReductionTimePillar(Duration maxRouteStartReductionTime, boolean isOnlyUsedForDriving)
      Sets the localMaxRouteStartReductionTime for IPillarNode. Overwrites the set localMaxRouteStartReductionTime and sets the new value for Pillars. If no localMaxRouteStartReductionTime has been set, sets the new value for Pillars only.

      For more information please see setLocalMaxRouteStartReductionTime(Duration, boolean).

      Parameters:
      maxRouteStartReductionTime - the duration of the localMaxStartReductionTimePillar
      isOnlyUsedForDriving - the boolean whether it is only used for driving
      Returns:
      false if reductionTime is null or negative
    • setLocalReductionTimeIsIncludedInWorkingTime

      void setLocalReductionTimeIsIncludedInWorkingTime(boolean isIncludedInTotalWorkingTime)
      Sets whether the localMaxRouteStartReductionTime is included in the WorkingHours. The default value is false. If false and setLocalMaxRouteStartReductionTime(Duration, boolean) is set to true the driving time to the first Node has to be done in the Resources private time

      For more information please see setLocalMaxRouteStartReductionTime(Duration, boolean).

      Parameters:
      isIncludedInTotalWorkingTime - the boolean whether reduction time is included in the WorkingHours
    • isLocalReductionTimeOnlyUsedForDriving

      Optional<Boolean> isLocalReductionTimeOnlyUsedForDriving()
      Checks whether the potentially set localMaxRouteStartReductionTime can only be used for driving, not for working. Per default this is set to true.

      For more information please see setLocalMaxRouteStartReductionTime(Duration, boolean)

      Returns:
      the checked status or an empty Optional if no localMaxRouteStartReductionTime has been set
    • isLocalReductionTimeOnlyUsedForDrivingPillar

      Optional<Boolean> isLocalReductionTimeOnlyUsedForDrivingPillar()
      Checks whether the potentially set localMaxRouteStartReductionTime for IPillarNode can only be used for driving, not for working. Per default this is set to true.

      For more information please see setLocalMaxRouteStartReductionTime(Duration, boolean) and setLocalMaxRouteStartReductionTimePillar(Duration, boolean).

      Returns:
      the checked status or an empty Optional if no localMaxRouteStartReductionTime has been set
    • isLocalReductionTimeIncludedInWorkingTime

      Optional<Boolean> isLocalReductionTimeIncludedInWorkingTime()
      Checks whether the localMaxRouteStartReductionTime is included in the WorkingHours. The default value is false. If false and setLocalMaxRouteStartReductionTime(Duration, boolean) is set to true the driving time to the first Node has to be done in the Resources private time

      For more information please see setLocalMaxRouteStartReductionTime(Duration, boolean).

      Returns:
      the status of an empty Optional if no localMaxRouteStartReductionTime has been set
    • getLocalMaxRouteStartReductionTimeMillis

      Optional<Long> getLocalMaxRouteStartReductionTimeMillis()
      Gets the localMaxRouteStartReductionTime in milliseconds.

      For more information please see setLocalMaxRouteStartReductionTime(Duration, boolean).

      Returns:
      the status or an empty optional if no localMaxRouteStartReductionTime has been set
    • getLocalMaxRouteStartReductionTimeMillisPillar

      Optional<Long> getLocalMaxRouteStartReductionTimeMillisPillar()
      Gets the localMaxRouteStartReductionTime for IPillarNode in milliseconds.

      For more information please see setLocalMaxRouteStartReductionTimePillar(Duration, boolean) and setLocalMaxRouteStartReductionTime(Duration, boolean).

      Returns:
      the status or an empty optional if no localMaxRouteStartReductionTime has been set
    • setLocalFlexTime

      boolean setLocalFlexTime(Duration idleTimeReductionTime)
      Sets the amount of time a Resource can be expected to start working later and stay longer at work if needed.

      If the first Node is at 11, the Resources WorkingHours started at 8 and the localFlexTime is set to 3 hours, the Resource starts working at 11 and has to stay 3 hours longer at work than usual. If the localFlexTime in the above example is set to 2 hours, the Resource will be idle from 10-11 but it is considered working time.

      Parameters:
      idleTimeReductionTime - the duration of the idle time reduction time
      Returns:
      true if the setting was accepted
    • getLocalFlexTimeMillis

      Optional<Long> getLocalFlexTimeMillis()
      Gets the localFlexTime in milliseconds.

      For more information please see setLocalFlexTime(Duration).

      Returns:
      the long local flex time in milliseconds, an empty Optional if no localFlexTime has been set
    • setLocalMaxFreePostWorkDrivingTerminationTime

      boolean setLocalMaxFreePostWorkDrivingTerminationTime(Duration postWorkingHourTimeReductionTime)
      Sets the amount of time the Resource can be expected to drive home to its starting location in its free time.

      If returning from the last Node to the starting location takes 1 hour and the freePostWorkDrivingTerminationTime is set to 40 minutes, those 40 minutes of the drive home are considered private time.

      This method sets the local free post work driving termination time locally. Therefore different times can be set for different WorkingHours. If the time should be valid for all the WorkingHours of a Resource please use IResource.setMaxFreePostWorkDrivingTerminationTime(Duration).

      Parameters:
      postWorkingHourTimeReductionTime - the duration free time that needs to be used to drive home
      Returns:
      true if the setting was accepted
    • setLocalMaxFreePostWorkDrivingTerminationTime

      boolean setLocalMaxFreePostWorkDrivingTerminationTime(Duration postTimeReductionTime, boolean onlyApplyOnOvertime)
      Sets the local max free post work driving termination time. If onlyApplyOnOvertime is true, the post driving time is only utilized if the route shows overtime. Moreover, the maximal utilized time is the overtime itself (or, if lower, the postWorkingHourTimeReductionTime).
      Parameters:
      postTimeReductionTime - the post time reduction time
      onlyApplyOnOvertime - the only apply on overtime
      Returns:
      true, if successful
    • isLocalOnlyApplyFreePostWorkDrivingOnOvertime

      Optional<Boolean> isLocalOnlyApplyFreePostWorkDrivingOnOvertime()
    • getLocalMaxFreePostWorkDrivingTerminationTimeMillis

      Optional<Long> getLocalMaxFreePostWorkDrivingTerminationTimeMillis()
      Gets the freePostWorkDrivingTerminationTime in milliseconds.

      For more information please see setLocalMaxFreePostWorkDrivingTerminationTime(Duration).

      Returns:
      the value or an empty Optional if no freePostWorkDrivingTerminationTime has been set
    • setLocalMaxPillarAfterHoursTime

      boolean setLocalMaxPillarAfterHoursTime(Duration maxPillarEndOverTime)
      Sets the amount of time after WorkingHours within which a IPillarNode can be set. The Resources have to visit this Pillar even tough it is outside of WorkingHours.

      This method in only valid for a specific set of WorkingHours. If you want to set the same time for all the WorkingHours of a Pillar please use IResource.setMaxPillarAfterHoursTime(Duration)

      Parameters:
      maxPillarEndOverTime - the duration after WorkingHours within which a Pillar still has to be given service
      Returns:
      true if the setting was accepted
    • getLocalMaxPillarAfterHoursTime

      Optional<Long> getLocalMaxPillarAfterHoursTime()
      Gets the localMaxPillarAfterHoursTime of IPillarNode in milliseconds.

      For more information please see setLocalMaxPillarAfterHoursTime(Duration).

      Returns:
      the long localMaxPillarAfterHoursTime
    • copy

      Returns a copy of WorkingHours(this.getBegin(), this.getEnd(), this.getZoneId()) and invokes WorkingHours.takeOverProperties(com.dna.jopt.member.unit.hours.IWorkingHours, com.dna.jopt.member.unit.hours.IWorkingHours) to also copy the properties.
      Specified by:
      copy in interface IDutyHours
      Returns:
      a copy of the WorkingHours
    • addConstraint

      void addConstraint(IWorkingHoursLevelConstraint wohLevelConstraint)
      Adds a Constraint to the WorkingHours so only Resources with that specific Qualification will be able to serve the Nodes to which those WorkingHours are applied.

      For examples see UKPostCodeQualification and UKPostCodeConstraint

      Parameters:
      wohLevelConstraint - the iWorkingHoursLevelConstraint to add to the workingHours
    • addConstraint

      void addConstraint(IMultiWorkingHoursLevelConstraint wohLevelConstraint)
    • getMultiConstraints

      List<IMultiWorkingHoursLevelConstraint> getMultiConstraints()
    • getConstraints

      Gets the Constraints set on the IResource. The Resource can only work on Nodes within within the range of its Constraint.

      An example of its implementation is UKPostCodeConstraint.

      Returns:
      the workingHours constraints
    • addNodeColorCapacity

      void addNodeColorCapacity(NodeColorCapacityItem item)
      Adds a certain INodeColor to the Resource. This way can be made sure that Nodes with a certain Color are not overrepresented and can be used for white space generation.

      Implementation example:

      
       double preventivePercent = 0.2;
           double contractorPercent = 0.5;
           double breakfixPercent = 0.7;
      
           workingHours.forEach(wh -> {
             wh.addNodeColorCapacity(new NodeColorCapacityItem(NodeColors.PREVENTIVE,preventivePercent));
             wh.addNodeColorCapacity(new NodeColorCapacityItem(NodeColors.BREAKFIX,breakfixPercent));
             wh.addNodeColorCapacity(new NodeColorCapacityItem(NodeColors.CONTRACTOR,contractorPercent));
             }
       
      Parameters:
      item - the nodeColorCapacityItem
      See Also:
    • getColorCapacityItemByColorCode

      Optional<NodeColorCapacityItem> getColorCapacityItemByColorCode(int colorCode)
      Gets the NodeColorCapacityItem which limit the amount of Color coded Nodes a Resource can give service to. This way can be made sure that Nodes with a certain Color are not overrepresented and can be used for white space generation.
      Parameters:
      colorCode - the int code of the color
      Returns:
      the NodeColorCapacityItem or an empty Optional if no colorCapaciy has been set.
      See Also:
    • isNodeColorCodingInUse

      boolean isNodeColorCodingInUse()
      Checks if any INodeColor has been set through the use of a NodeColorCapacityItem.
      Returns:
      true if this is the case
    • getPresentColorCodes

      Set<Integer> getPresentColorCodes()
      Gets the INodeColor that are in use.
      Returns:
      the Color codes
      See Also:
    • getNodeColorCapacityMap

      Map<Integer,NodeColorCapacityItem> getNodeColorCapacityMap()
      Gets the a Map of the NodeColorCapacity. For more information please see INodeColor and NodeColorCapacityItem.
      Returns:
      the map of colorCapacity
    • addQualification

      void addQualification(IQualification qualification)
      Adds a IQualification to the IWorkingHours, which means that by adding a IConstraint to the INode, they are limited to which Nodes they can give service.
      Parameters:
      qualification - the IQualification that is to be added
    • getQualifications

      Map<Class<? extends IQualification>,IQualification> getQualifications()
      Gets the IQualification of the IWorkingHours.
      Returns:
      the node qualifications
      See Also:
    • setResourceDepot

      void setResourceDepot(IResourceDepot depot)
    • getResourceDepot

      Optional<IResourceDepot> getResourceDepot()
    • setStartTimeHook

      boolean setStartTimeHook(Duration routeStartTimeHookDuration)
    • getRouteStartShiftMillisHook

      Optional<Long> getRouteStartShiftMillisHook()
    • hasHook

      boolean hasHook()
    • addConnectionHook

      boolean addConnectionHook(ReducedNodeEdgeConnectorItem item)
    • getConnectionHook

      Optional<ReducedNodeEdgeConnectorItem> getConnectionHook(String toId)
    • getConnectionHooks

    • setConnectionHooks

      boolean setConnectionHooks(Map<String,ReducedNodeEdgeConnectorItem> map)