有一家公司组织了一个研讨会,将有 60 名学员参加。公司计划将参与者分成10组,每组6名学员。每位受训者都被事先要求选择他们想与之合作的其他 5 名受训者。这五个中的每一个都具有相同的权重。问题是我们如何将参与者分组,以便优化总体满意度。
问问题
124 次
1 回答
-1
让我举一个 OPL 中 CPLEX 中的 CPO 的小示例:
//There’s a company organising a seminar, where 60 trainees will attend.
//The company plans to divide the participants into 10 groups, each of 6 trainees.
//Each of the trainees was asked beforehand to choose 5 other trainees they would like to work with.
//And each of the five is weighted equally.
//The problem is how we can assign the participants into groups so that the total satisfaction could to optimised.
using CP;
execute
{
cp.param.timelimit=20;
}
int nbTrainees=60;
int nbGroups=10;
int nbWishes=5;
int sizeGroup=nbTrainees div nbGroups;
range trainees=1..nbTrainees;
range groups=1..nbGroups;
range likes=1..nbWishes;
// let us start with the nbWishes next trainees
int wishes[t in trainees][w in likes]=(t+w-1) mod nbTrainees+1;
assert forall(t in trainees,w in likes) wishes[t][w] in trainees;
assert forall(t in trainees,w in likes) wishes[t][w] != t;
// a gievn trainee belongs to a given group ?
dvar boolean x[trainees][groups];
dvar int satisfaction;
maximize satisfaction;
subject to
{
// trainees belong to one and only one group
forall(t in trainees) sum(g in groups) x[t][g]==1;
// group size
forall(g in groups) sum(t in trainees) x[t][g]==sizeGroup;
// satisfaction formula
satisfaction==sum(t in trainees,w in likes,g in groups) ((x[t][g]*x[wishes[t][w]][g]));
}
{int} team[g in groups]={ i | i in trainees : x[i][g]==1};
execute
{
writeln(team);
}
于 2018-10-31T09:52:52.133 回答