lundi 30 mars 2015

Algorithm for conditioned migration

Literal description of the problem:


Given a number of schools, each school holds a number of teachers according to its needs. At the end of the scholar year, some teachers ask for changing their positions (schools where they're currently teaching) according to an ordered list (i.e: change me to school1, if not possible, school2, if not possible school3, etc..) Remembering that each school must have EXACTLY the number of teachers it needs (not more, not less).


Each teacher has an importance number that is unique, so that if two or more teachers ask for the same school at the same time, the one having the higher importance number will get the desired school.


if we are unable to migrate one or more teachers following his list, then we keep him at his initial school answering: "sorry, your demand is affordable for this year"


How can we afford this "migration" ?


(p.s: by "afford" I mean change the position of each teacher to the best (best according to his list) desired school.




I/ Algebraic modeling of the problem


Given E={e1..en}, n>=0, a set of positive integers (e for entity)


Given L={l1..lm}, m>=0, a set of positive integers (l for location)


Given P:E --> L , a function. (P for position)


Given C:L --> IN*, a function. (C for capacity)


Given U:L --> IN, a function. (U for used) defined by: U(l)=card({e/P(e)=l})


Given A:L --> IN, a function. (A for available) defined by: C(l)=A(l)+U(l) for any l in L.


Let D:E --> L^k, where 0 < k <= m, D(e)=(l1,l2,..li) a function (D for destinations)


(That is, each entity has an ordered non-empty list of locations (destinations) willing to move to).


Let I:E --> IR+, a bijection (I for Importance). (That is, each entity has a unique importance number I(e))


II/Rules of Migration:


The asked task, is to find out the new P' function (Positioning) that affords the following:


1- P'(e) belongs to {l1,l2,..,li} where (l1,l2,..,li)=D(e)


2- If we P'(e)=ls and P'(e)=lt are two possible solutions, where D(e) = (l1,...,ls,...,lt,...,li), then we must keep the solution that matches the destinations' order (i.e ls in this case) and exclude the other one)


3-If A(l) = 1 and P'(e1)=l and P'(e2)=l are two possible solutions, where I(e1)>I(e2) then we must keep the solution that matches the importance's order (i.e in this case P'(e1)=l) and exclude the other one.


4- If none of the desired destinations is possible, then P'(e)=P(e)


Aucun commentaire:

Enregistrer un commentaire