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.
Asked
Active
Viewed 138 times
0
-
define total satisfaction please – juvian Oct 29 '18 at 18:49
-
if a trainee were assigned to work with another one who he/she liked (prefer) to, then 1 point is added to the satisfaction. if not, then 0. – Jørgen Andreasen Oct 29 '18 at 19:14
-
What have you tried so far? – GB supports the mod strike Oct 29 '18 at 23:18
1 Answers
-1
let me give you a small example with CPO within CPLEX in OPL:
//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);
}

Martijn Pieters
- 1,048,767
- 296
- 4,058
- 3,343

Alex Fleischer
- 9,276
- 2
- 12
- 15
-
Could you please explain a bit more about how come it is modulo operation here? int wishes[t in trainees][w in likes]=(t+w-1) mod nbTrainees+1; Thanks. – Jørgen Andreasen Oct 31 '18 at 20:00
-
This helped me enter values without too much effort: friends of 1 : 2,3,4,5,6 and firiends of 60 : 1,2,3,4,5 – Alex Fleischer Oct 31 '18 at 20:53
-
And how should I interpret x[t][g]*x[wishes[t][w]][g] in the optimisation function? I am quite confused about the latter part. – Jørgen Andreasen Nov 01 '18 at 19:50
-
x[t][g]*x[wishes[t][w]][g] is 1 iff both factors are 1 which mean trainee t is in group g and his friend wishes[t][w] is also in group g – Alex Fleischer Nov 02 '18 at 08:05