Java Team Scheduling Algorithm

D

dlemmermann

Hi there,

does anyone know of an open-source algorithm for "Team Scheduling"? I
want to
create a little demo of a Swing framework that I developed. In this
demo I want to
simulate a soccer / football league where 18 teams play against each
other. The
matches take place on a total of 34 weekends. Each team plays each
other team
twice, once at home, once away.

At first I thought this could be solved easily with two nested "for"
loops but it turns
out to be more complicated than that. Especially placing the matches
onto those
34 days without any team playing twice on the same day.

If anyone knows of a solution for this scenario, please let me know. I
tried solving
this myself but ended up with a couple of nods in my brain.

Regards,

Dirk

P.S.: no, I am not a student who needs help with his homework.
Unfortunately I
am too old for that (38 this weekend :-( ) To confirm look at
http://www.dlsc.com
 
D

Daniel Dyer

Hi there,

does anyone know of an open-source algorithm for "Team Scheduling"? I
want to
create a little demo of a Swing framework that I developed. In this
demo I want to
simulate a soccer / football league where 18 teams play against each
other. The
matches take place on a total of 34 weekends. Each team plays each
other team
twice, once at home, once away.

At first I thought this could be solved easily with two nested "for"
loops but it turns
out to be more complicated than that. Especially placing the matches
onto those
34 days without any team playing twice on the same day.

If anyone knows of a solution for this scenario, please let me know. I
tried solving
this myself but ended up with a couple of nods in my brain.

The problem can be slightly simplified if you ignore the home/away
requirement. The second part of the season can be the same as the first
part but with the teams switched.

This leaves you with 17 dates on each of which there must be 9 fixtures,
with each team playing once on each date.

Firstly generate all of the required matches for the season (ignoring who
is at home). This is the set of all combinations of length 2 from a set
of 18 elements.

This will give you 153 pairs of teams that you need to divide into 17
separate pots ensuring that each team only appears once in each pot.

I'm not sure of the best way to do this, but I think the following
approach should work reasonably well (although somebody else can probably
suggest a more efficient way of doint it):

Firstly shuffle the list of 153 pairs (assuming you don't want the
fixtures to be predictable). Then take each pair in turn and allocate it
to the first available pot (fixture date) in which neither team is already
present. I haven't tried it, but I think this should give you what you
need.

Once you've done this you can just duplicate the fixtures for the second
half of the season, switching the home and away teams for each match.

Dan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top