Interface Timeable

All Known Subinterfaces:
Agent
All Known Implementing Classes:
Engine, GraphAgent, LongAgent, LongAgentTail, Model, StateMachine, Train

public interface Timeable
Interface containing convenience methods for recalculations between simulation time and simulation calendar dates. The recalculation is based on the two assumptions:
  • The zero simulation time corresponds to the specified begin date - an instance of LocalDateTime
  • The one unit of simulation time corresponds to the specified time unit - an instance of ChronoUnit
  • Author:
    Andrey Malykhanov
    • Method Summary

      Modifier and Type
      Method
      Description
      Returns the begin date, i.e.
      default double
      Converts the specified date of simulation calendar to the corresponding simulation time
      static double
      dateToTime(LocalDateTime date, LocalDateTime baseDate, ChronoUnit timeUnit)
      Converts the specified date of simulation calendar to the corresponding simulation time
      default double
      Converts the specified date of simulation calendar to the corresponding simulation time.
      default double
      day()
      Returns the duration of one day of simulation calendar in simulation time units.
      default double
      duration(ChronoUnit chronoUnit)
      Returns the estimated duration of the specified period unit in simulation time units.
      default double
      Returns the duration of one hour of simulation calendar in simulation time units
      default double
      Returns the duration of one minute of simulation calendar in simulation time units
      static Timeable
      of(LocalDateTime beginDate, ChronoUnit timeUnit)
      Returns an instance of Timeable with the specified begin date and time unit
      default double
      Returns the duration of one second of simulation calendar in simulation time units
      timeToDate(double time)
      Converts the specified simulation time to corresponding date of simulation calendar
      timeToDate(double time, LocalDateTime beginDate, ChronoUnit timeUnit)
      Converts the specified simulation time to corresponding date of simulation calendar
      Returns the simulation time unit, i.e.
      default double
      Returns the duration of one week of simulation calendar in simulation time units.
      wholeDays(double tillTime)
      Returns the list of LocalDateTime instances corresponding to instants having whole days between the time 0, inclusively, and the specified time, exclusively
      wholeDays(double beginTime, double endTime)
      Returns the list of LocalDateTime instances corresponding to instants having whole days between the specified simulation times
      wholeHours(double tillTime)
      Returns the list of LocalDateTime instances corresponding to instants having whole hours between the time 0, inclusively, and the specified time, exclusively
      wholeHours(double beginTime, double endTime)
      Returns the list of LocalDateTime instances corresponding to instants having whole hours between the specified simulation times
      wholeUnits(LocalDateTime beginDate, LocalDateTime endDate, ChronoUnit unit)
      Returns the list of LocalDateTime instances corresponding to instants having whole specified period units between the specified dates
    • Method Details

      • beginDate

        LocalDateTime beginDate()
        Returns the begin date, i.e. the simulation date that corresponds to zero simulation time
        Returns:
        simulation date that corresponding to zero simulation time
      • timeUnit

        ChronoUnit timeUnit()
        Returns the simulation time unit, i.e. period unit that corresponds to one unit of simulation time
        Returns:
        period unit that corresponds to one unit of simulation time
      • second

        default double second()
        Returns the duration of one second of simulation calendar in simulation time units
        Returns:
        duration of one second of simulation calendar in simulation time units
      • minute

        default double minute()
        Returns the duration of one minute of simulation calendar in simulation time units
        Returns:
        duration of one minute of simulation calendar in simulation time units
      • hour

        default double hour()
        Returns the duration of one hour of simulation calendar in simulation time units
        Returns:
        duration of one hour of simulation calendar in simulation time units
      • day

        default double day()
        Returns the duration of one day of simulation calendar in simulation time units. Duration of all days is always equal to 24 hours
        Returns:
        duration of one day of simulation calendar in simulation time units
      • week

        default double week()
        Returns the duration of one week of simulation calendar in simulation time units. Duration of any week is always equal to 7 days, or 7 * 24 = 168 hours
        Returns:
        duration of one week of simulation calendar in simulation time units
      • duration

        default double duration(ChronoUnit chronoUnit)
        Returns the estimated duration of the specified period unit in simulation time units. The duration is calculated according to the rules described in the comments to this JDK method: ChronoUnit.getDuration().

        Note that when expressing durations of long periods the following rules are used:

      • 1 week = 7.0 days
      • 1 month = 30.436875 days
      • 1 year = 365.2425 days
      • 1 decade = 10.0 years = 3652.425 days
      • Parameters:
        chronoUnit - specified period unit
        Returns:
        estimated duration of the specified period unit in simulation time units
      • timeToDate

        default LocalDateTime timeToDate(double time)
        Converts the specified simulation time to corresponding date of simulation calendar
        Parameters:
        time - specified simulation time. Can be zero, positive or negative. Must not be null or Double.NaN
        Returns:
        simulation date that corresponds to the specified simulation time
      • dateToTime

        default double dateToTime(LocalDateTime date)
        Converts the specified date of simulation calendar to the corresponding simulation time
        Parameters:
        date - specified simulation date
        Returns:
        simulation time that corresponds to the specified simulation date
      • dateToTime

        default double dateToTime(Date date)
        Converts the specified date of simulation calendar to the corresponding simulation time. The date is specified as instance of Date
        Parameters:
        date - specified simulation date
        Returns:
        simulation time that corresponds to the specified simulation date
      • dateToTime

        static double dateToTime(LocalDateTime date, LocalDateTime baseDate, ChronoUnit timeUnit)
        Converts the specified date of simulation calendar to the corresponding simulation time
        Parameters:
        date - specified simulation date
        baseDate - zero date, i.e. date corresponding to zero simulation time
        timeUnit - simulation time unit
        Returns:
        simulation time that corresponds to the specified simulation date
      • timeToDate

        static LocalDateTime timeToDate(double time, LocalDateTime beginDate, ChronoUnit timeUnit)
        Converts the specified simulation time to corresponding date of simulation calendar
        Parameters:
        time - specified simulation time. Can be zero, positive or negative. Must not be null or Double.NaN
        beginDate - zero date, i.e. date corresponding to zero simulation time
        timeUnit - simulation time unit
        Returns:
        simulation time that corresponds to the specified simulation date
      • wholeUnits

        default List<LocalDateTime> wholeUnits(LocalDateTime beginDate, LocalDateTime endDate, ChronoUnit unit)
        Returns the list of LocalDateTime instances corresponding to instants having whole specified period units between the specified dates
        Parameters:
        beginDate - begin date, inclusively
        endDate - end date, exclusively
        unit - instance of ChronoUnit specifying the period units of wholeness
        Returns:
        list of LocalDateTime instances corresponding to instants having whole specified period units
      • wholeHours

        default List<LocalDateTime> wholeHours(double beginTime, double endTime)
        Returns the list of LocalDateTime instances corresponding to instants having whole hours between the specified simulation times
        Parameters:
        beginTime - begin time, inclusively
        endTime - end time, exclusively
        Returns:
        list of LocalDateTime instances corresponding to instants having whole hours between the specified simulation times
      • wholeHours

        default List<LocalDateTime> wholeHours(double tillTime)
        Returns the list of LocalDateTime instances corresponding to instants having whole hours between the time 0, inclusively, and the specified time, exclusively
        Parameters:
        tillTime - specified time, exclusively
        Returns:
        list of LocalDateTime instances corresponding to instants having whole hours between the specified simulation times
      • wholeDays

        default List<LocalDateTime> wholeDays(double beginTime, double endTime)
        Returns the list of LocalDateTime instances corresponding to instants having whole days between the specified simulation times
        Parameters:
        beginTime - begin time, inclusively
        endTime - end time, exclusively
        Returns:
        list of LocalDateTime instances corresponding to instants having whole days between the specified simulation times
      • wholeDays

        default List<LocalDateTime> wholeDays(double tillTime)
        Returns the list of LocalDateTime instances corresponding to instants having whole days between the time 0, inclusively, and the specified time, exclusively
        Parameters:
        tillTime - specified time, exclusively
        Returns:
        list of LocalDateTime instances corresponding to instants having whole days between the specified simulation times
      • of

        static Timeable of(LocalDateTime beginDate, ChronoUnit timeUnit)
        Returns an instance of Timeable with the specified begin date and time unit
        Parameters:
        beginDate - specified begin date
        timeUnit - specified time unit
        Returns:
        instance of Timeable with the specified begin date and time unit