创建时间表的算法

时间:2019-06-08 15:35:36

标签: algorithm language-agnostic np

我一直在想,是否有任何已知的创建时间表算法的解决方案。在我的项目中,具体来说是在不同的回合/区域之间平均划分字符列表的问题。

以下规则适用:

  • 创建尽可能多的回合,但不超过X个回合。
  • 如果可能的话,每个帐户都应在下一轮之后暂停一轮。
  • 如果可能的话,每个区域中每轮至少应有一个字符。
  • 每个拥有一个角色的帐户每个回合只能参加一个区域。

这里是一个例子:

+-----------+-------------+--------+
| Account   | Character   | Zone   |
+-----------+-------------+--------+
| AccountA0 | CharacterA1 | Zone01 |
|           | CharacterA2 | Zone01 |
|           | CharacterA3 | Zone03 |
+-----------+-------------+--------+
| AccountB0 | CharacterB1 | Zone01 |
|           | CharacterB2 | Zone02 |
|           | CharacterB3 | Zone03 |
+-----------+-------------+--------+
| AccountC0 | CharacterC1 | Zone03 |
|           | CharacterC2 | Zone03 |
|           | CharacterC3 | Zone03 |
+-----------+-------------+--------+
| AccountD0 | CharacterD1 | Zone02 |
|           | CharacterD2 | Zone02 |
|           | CharacterD3 | Zone01 |
+-----------+-------------+--------+
| AccountE0 | CharacterE1 | Zone01 |
|           | CharacterE2 | Zone02 |
|           | CharacterE3 | Zone03 |
+-----------+-------------+--------+
| AccountF0 | CharacterF1 | Zone01 |
|           | CharacterF2 | Zone02 |
|           | CharacterF3 | Zone03 |
+-----------+-------------+--------+

对于上述角色,以下排程最多可以进行6个回合:

+---------+-------------+-------------+-------------+
| Round   | Zone01      | Zone02      | Zone03      |
+---------+-------------+-------------+-------------+
| Round01 | CharacterA1 | CharacterB2 | CharacterC1 |
+---------+-------------+-------------+-------------+
| Round02 | CharacterD3 | CharacterE2 | CharacterF3 |
+---------+-------------+-------------+-------------+
| Round03 | CharacterA2 | CharacterD1 | CharacterB3 |
+---------+-------------+-------------+-------------+
| Round04 | CharacterE1 | CharacterF2 | CharacterC2 |
+---------+-------------+-------------+-------------+
| Round05 | CharacterB1 | CharacterD2 | CharacterA3 |
+---------+-------------+-------------+-------------+
| Round06 | CharacterF1 |             | CharacterC3 |
|         |             |             | CharacterE3 |
+---------+-------------+-------------+-------------+

遗传算法最适合这个项目吗?

1 个答案:

答案 0 :(得分:0)

我认为大多数此类调度问题都可以建模为约束满足问题,并且有许多constaint programming libraries可用于有效地找到解决方案。