This forum is read-only now. Please use Forum 2 for new posts

xml No replies possible in the archive
UEFA draws - algorithm
Author: crabik
Date: 03-08-2013, 04:56
I'd like to recreate algorithm UEFA uses for their draws. I'm especially interested in the technique they use to ensure no two teams from the same country meet. It's not hard to come up with a solution that works most of the time but it's hard if you want it to work all the time unless you have a lot of raw power to test all the possible combinations.

Can anyone explain how they do that?

I'm a bit afraid it's not simple math and it probably requires a lot of skill in combinatorics to crack it.

Re: UEFA draws - algorithm
Author: simonk
Date: 03-08-2013, 11:30
Edited by: simonk
at: 03-08-2013, 11:32
Which round do you mean?

Re: UEFA draws - algorithm
Author: crabik
Date: 03-08-2013, 14:28
All of them but group stages interest me the most.

Re: UEFA draws - algorithm
Author: amirbachar
Date: 03-08-2013, 17:55
Edited by: amirbachar
at: 03-08-2013, 17:56
They are obviously ensure no two teams from the same country meet even a few balls later.
This can be done using backtracking. You don't need to check all possible permutation - just make sure you have one valid permutation for every team currently drawn.

Re: UEFA draws - algorithm
Author: crabik
Date: 04-08-2013, 12:05
OK, then it goes like this:

you can place teams from the first pot to groups without checking anything. After that whenever they draw a team they check if there is at least one solution for a particular group, if there is the team can be drawn to this group, if there isn't they don't put this group into the mix.

They check it using backtracking. They probably do it by placing every team that hasn't been drawn yet one by one to the first possible group using just their coefficient and country without looking at anything else. When they reach a dead end with one of the teams they backtrack and place the previous team to a second possible group and continue, when there isn't a next possible group they backtrack even more.

On a bad day they'll only run through all the invalid groupings + a couple valid ones. Am I on the right way?

Re: UEFA draws - algorithm
Author: amirbachar
Date: 04-08-2013, 22:45
Yes, that's pretty much what they do.

Re: UEFA draws - algorithm
Author: MudHen
Date: 06-08-2013, 07:21
@crabik

Even in the first pot you have to take into account that only half of the teams from one country can be on the same half of the big table. If a country has four teams, two of them will be in group A-D and the other two in E-H.
Also, you have to take into consideration TV pairings. For example, Real and Barca will always be in opposite halves. The problem is that these pairings are known to the general public only hours before the draws, if at all.

Re: UEFA draws - algorithm
Author: hrishi
Date: 12-11-2013, 15:39
But the draw is held live on television and in the 2 years that I have watched it, I have not seen any mistakes or backtracking. Lets consider the following scenario:
Groups A,B,C,D,E,G are all done and Groups F and H stand as follows:
F- Arsenal,Schalke,PSG
H- Chelsea,Basel, Dortmund
with Galatasaray and Marseille left.

If its Gala's turn first, does it mean that they will automatically go into Group F as Marseille and PSG belong to the same association?

Re: UEFA draws - algorithm
Author: hrishi
Date: 12-11-2013, 15:45
@MudHen

If television pairings were considered, does it mean that when Man City was drawn, it had no chance of being in Barca's group or Porto's group as that would have put 3 English teams in Groups E-H?

Re: UEFA draws - algorithm
Author: MalcolmW
Date: 12-11-2013, 17:16
In a word - yes.