具有季节性行为的应用程序的时间表

Schedules for applications with seasonal behaviour

I 运行 涵盖一年多的离散事件模拟。所有事件都需要在第二个时间尺度上进行跟踪。
现在,我想根据时间表安排活动,计算加班时间,......最后将其与实际劳动时间进行比较。 我想是否有一种优雅的方法可以在 R 中实现调度,以便可以在一行代码中回答以下 tasks/questions:

在抽象层面上,假设所有 时间表或多或少按以下方式给出:

Name   Days_of_year     Available                             Time  
Name1  Jan-07 – Oct-18  Mon, Tues, Wed, Thurs, Fri, Sat, Sun  8:45 - 18:00  
Name2  Jan-01 – Dec-31  Mon, Tues, Wed, Thurs, Fri            20:00 - 7:00  

我不是在寻找像 "create an arry and somehow you get everything out of that" 这样明显的答案,而是在寻找 :

的实现

用例视图("schedule functions" 表示为 s_):

一些想法:

schedule计划工时:

s_interval $tzone   UTC
    $daysofyear 286 days        (Better alternative: format month-day e.g. Jan-07 – Oct-18) 
    $wday           Mon, Tues, ... Sun  (According to the start time of a shift/lecture...)
    $time           12 h            (Better alternative: format time span* e.g. 8:00 – 18:00. NOT period which results in hours)
    $overtime       0 h         (A priori, a schedule does not plan overtime)
    $idle           0 h         (A priori, a schedule only plans labor time)

schedule 当实时数据可用时:

s_interval$tzone    UTC
    $daysofyear 286 days                (Better alternative: format month-day e.g. Jan-07 – Oct-18) 
    $wday           c(Mon, Tues, Wed, ...)      (According to the start time of a shift/lecture...)
    $time           c(12 h, 1 h, 0.5 h, ...)        (Better alternative: format time span* e.g. 8:00 – 18:00. NOT period which results in hours)
    $overtime       c(2 h, 0 h, -1 h, ...)      total time = time + overtime. Array of lubridate intervals*?
    $idle           c(4 h, 8 h, 0h, ...)        pure working_time = time – idle + overtime. Array of lubridate intervals*?

* Use intervals not periods such that interval/dhours(1) possible.

如果 tzone 相同,我们可以计算例如

s_interval1 %+% s_interval2 =  
s_interval$tzone    UTC
    $daysofyear    286 days,            123 days        
    $wday           c(Mon, Tues, Wed, ...),     c(Sat, Sun)
    $time          c(12 h, 1 h, 0.5 h, ...),    c(-1 h, 2.5 h)
    $overtime      c(2 h, 0 h, -1 h, ...),      c(0 h, 5 h)
    $idle          c(4 h, 8 h, 0h, ...),        c(4 h, 8 h)

有关于此主题的相关帖子visualization of schedules with some interesting answers concerning timeline and gantt packages and how to filter dates。 然而,他们并不是很确定。

由于我是 R 的新手,我不知道如何以最好的方式开始这样的任务,并且理解像 lubridate 这样的包的结构是非常先进的...

我开发了一个包,它提供了所需的功能(甚至带有绘图)。目前,该包是私人的,但如果您有兴趣,请告诉我。