制定时间表

发布于 2024-09-27 19:05:48 字数 703 浏览 1 评论 0原文

所以..最近有人要求我为他们制定一个时间表,我同意了。当我坐下来做这件事时,我意识到这比我想象的要难。这只是一个4人轮班的时间表,无论是白天还是晚上。

我想到了这样的事情:

for Monday to Saturday {
  for(i=0;i<people.length;i++){
    if (person[i].available()){
      person.worksDay()
      person is now not available.
    }
  }

  for(i=0;i<people.length;i++){
    if (person[i].available()){
      person[i].worksNight()
      person[i] is now not available.
    }
  }
}

所以这个算法背后的想法是,每天,一个人被分配到白班或夜班。如果一个人刚刚轮班并且不在假期,那么他们就有空。这是周一到周六的时间。正如您可能会说的那样,给定人员 A、B、C、D,作业将如下所示(如果没有人在度假):

Mon A B
Tue C D
Wed A B
Th  C D
Fri A B
Sat C D

我猜这可行,但有点明显。问我的人想看到不同的选择。除了这个选项之外,是否还有更好的方法来查看更多内容?或者是否有一个程序可以为您执行此操作?

So.. someone recently asked me to make a timetable for them and I agreed. When I sat down to do it I realized it was harder than I thought. It's just a timetable to give shifts to 4 people for either day or night.

I thought of something like this:

for Monday to Saturday {
  for(i=0;i<people.length;i++){
    if (person[i].available()){
      person.worksDay()
      person is now not available.
    }
  }

  for(i=0;i<people.length;i++){
    if (person[i].available()){
      person[i].worksNight()
      person[i] is now not available.
    }
  }
}

So the idea behind this algorithm is that for each day, a person is assigned to a day or night shift. A person is available if they haven't JUST worked a shift and they aren't on holidays. It's for Monday to Saturday. As you can probably tell, given persons A,B,C,D the assignment would look like this (if no one is on holidays):

Mon A B
Tue C D
Wed A B
Th  C D
Fri A B
Sat C D

This works I guess but it's a bit obvious. The person who asked me wanted to see different options. Is there a better way about doing this to see more than just this option? Or is there even a program that does this for you?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老旧海报 2024-10-04 19:05:48

暴力破解是毫无意义的

使用Drools Planner、Choco、JGap、cpsolver等框架来解决给你的。其中一些框架(包括 Drools Planner)允许您轻松切换优化算法,并包含一些工具来确定最适合您的问题的算法。

Brute force is pointless.

Use a framework such as Drools Planner, Choco, JGap, cpsolver, ... to solve it for you. Some of those frameworks (including Drools Planner) allow you to easily switch optimization algorithms and include tools to determine the best one to use for your problem.

始终不够爱げ你 2024-10-04 19:05:48

一般来说,约束编程问题很复杂且难以编程。即使您的问题相当简单,您也可能需要下载一个工具来完成它。 Gnu 线性编程套件可能是最好的选择,它具有您可以使用的求解器和建模语言。我写了一篇关于调度的很长的文章一次

Constraint programming problems are complex and difficult to program in general. Even though your problem is fairly simple you may want to download a tool to do it. The Gnu Linear Programming Kit is probably the best option, it has a solver and a modeling language you can use. I wrote a really long post about scheduling one time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文