【发布时间】:2015-12-08 06:29:18
【问题描述】:
我是答案集编程的初学者。我想将所有学生分组到不同的组中,这样: 1. 每组有 3 到 4 名学生 2. 没有两个互不喜欢的学生在同一个小组。 3. 我们不能将同一个学生分配到不同的组。
我写过这样的:
%suppose there are total 6 students
student(1..6).
%suppose there are 2 groups
group(1..2).
%1 and 4 like each other, 4 and 5 dislike each other
dislike(1,4). dislike(5,4).
% each group has 3 to 4 students
:- group(G), #count {S : in(S,G)} < 3.
:- group(G), #count {S : in(S,G)} > 4.
我已经添加了每个组可以包含多少学生的约束,但不知道如何满足其他两个条件。
您的帮助将不胜感激。谢谢。
【问题讨论】:
标签: answer-set-programming clingo gringo