Round Robin Tournament Scheduling

Balance Pool Seeds In Quadrants of Bracket

cblaze22 · 23 · 16955

cblaze22

  • Junior Member
  • **
    • Posts: 33
Reply #15 on: August 16, 2013, 12:25:34 PM
So no sequence to get A matched with E unless I specifically place them together?  I also wouldnt want A1 and B1 in the same quadrant.  They should be seperate.
« Last Edit: August 16, 2013, 12:26:46 PM by cblaze22 »


cblaze22

  • Junior Member
  • **
    • Posts: 33
Reply #16 on: August 18, 2013, 05:53:10 PM
I think I figured it out.  I can generate a sequence with an algorithm to get

1, 8,      4,      5,      2,      7,      3,      6

Which turns out to be

18  AH  1 2 3 4
45  DE  4 3 2 1

27  BG  2 1 4 3
36  CF  3 4 1 2  

If I take the diagnal as the matchup, or reverse the bottom rows, then I get the correct matchups.  Just need to make this dynamic and make sure it works for other values.


cblaze22

  • Junior Member
  • **
    • Posts: 33
Reply #17 on: August 19, 2013, 02:41:19 PM
Would this setup work for a pool that has a different number of participants? So H has 5 participants instead of 4, would the latin square setup still work?


cblaze22

  • Junior Member
  • **
    • Posts: 33
Reply #18 on: August 19, 2013, 06:17:42 PM
I think I got the extra seed in a pool.  I am trying to generate a 8x8 using code.

What is the best way to generate

18452736
81547263
45183627
54816372

and make it dynamic for other latin square sizes.  I am using C# to do this.
« Last Edit: August 19, 2013, 06:18:03 PM by cblaze22 »


cblaze22

  • Junior Member
  • **
    • Posts: 33
Reply #19 on: August 19, 2013, 06:56:49 PM
I came up with this and generates my results.  The maxpositions is the matchups, so 18452736.  I just need it to be more dynamic, since the pattern could get larger or smaller.  You mentioned recursion, but is there a formula I could use to build up this latin square.

I posted this question here also, http://stackoverflow.com/questions/18326126/latin-square-algorithm-with-certain-pattern-for-bracket-play

Code: [Select]
public int[,] GetLatinSquare(List<int?> maxPositions)
        {
            var n = maxPositions.Count();

            var latinSquare = new int[n, n];

            for (int i = 0; i < n; i++)
            {
                var maxPosition = maxPositions[i];
                if (maxPosition != null)
                {
                    latinSquare[0, i] = maxPosition.Value;
                }
            }

            for (var i = 0; i < n; i = i+2)
            {
                latinSquare[1, i] = latinSquare[0, i + 1];
                latinSquare[1, i + 1] = latinSquare[0, i];
            }

            for (var i = 0; i < n; i = i + 4)
            {
                latinSquare[2, i] = latinSquare[0, i + 2];
                latinSquare[2, i + 1] = latinSquare[0, i + 3];
                latinSquare[2, i + 2] = latinSquare[0, i + 0];
                latinSquare[2, i + 3] = latinSquare[0, i + 1];
            }

            for (var i = 0; i < n; i = i + 2)
            {
                latinSquare[3, i] = latinSquare[2, i + 1];
                latinSquare[3, i + 1] = latinSquare[2, i];
            }

            return latinSquare;
        }
« Last Edit: August 19, 2013, 10:40:31 PM by cblaze22 »


Ian Wakeling

  • Forum Moderator
  • God Member
  • *****
    • Posts: 1140
Reply #20 on: August 20, 2013, 01:24:51 AM
I don't think that you have understood Reply #8 above, which explains how you can start with the order 2 square:

1 2
2 1

and repeatedly double the order to obtain a square as large as you want. At each doubling stage, all entries in the old square are replaced by a 2x2 square, so the new square will have double the number of rows and columns compared to the old.  Each distinct entry in the old square is replaced by a different 2x2 square.  In reply #8, I give all 4 2x2 squares (S1 to S4) that you need to convert the 4x4 square into the 8x8 square.  S1 to S4 are simply the 2x2 square above, where the '1's has been replaced by one member of a seed pair (say 3) and the 2s have been replaced by the other member of the seed pair (say 6).  The whole thing could be implemented recursively if you want.  But note that if you want to go straight to a suitable square of order n, then you could start by using the MOD algorithm to get to an order n/2 square and then double it's size as detailed (will not be the same square as the recursive approach but it will have the properties that you want).  Does that help?

BTW, I have never used any flavour of C, so I have not tried to understand your code, so my apologies if I am missing something here.
« Last Edit: August 20, 2013, 01:27:13 AM by Ian »


cblaze22

  • Junior Member
  • **
    • Posts: 33
Reply #21 on: August 20, 2013, 12:43:55 PM
I figured it out with your help.  Without you I probably would of never got this done.  Final product below.


Code: [Select]
       public int[,] GetLatinSquare(List<int> maxPositions)
        {
            var n = maxPositions.Count();

            var latinSquare = new int[n, n];

            // Initialize Pattern
            for (int i = 0; i < n; i++)
            {
                latinSquare[0, i] = maxPositions[i];
            }

            var start = 0;
            var startIndex = 1;

            // Start Processing Squares Starting with 2x2
            while ((start = Convert.ToInt32(Math.Pow(2, startIndex))) <= n)
            {
                startIndex++;

                for (int row = 0; row < start/2; row++)
                {
                    var startRow = row;
                    var endRow = start - row - 1;

                    for (var i = 0; i < n; i = i + start)
                    {
                        var startColumn = i;
                        var endColumn = i + start - 1;
                        var columns = endColumn - startColumn + 1;

                        for (var column = 0; column < columns; column++)
                        {
                            latinSquare[endRow, startColumn] = latinSquare[startRow, endColumn];
                            endColumn--;
                            startColumn++;
                        }
                    }
                }
            }

            return latinSquare;
        }


aprens

  • Newbie
  • *
    • Posts: 1
Reply #22 on: January 03, 2022, 08:26:30 AM
Hi Ian, this post is interesting. How can i apply latin square for this situation?

6 pools and advance top 2 of each pool.

1A 2A
1B 2B
1C 2C
1D 2D

1E 2E
1F 2F

Games should be (in this order):

1A - BYE (no team)
2B - 2C
1D - BYE
1E - 2F
1B - BYE
2A - 2D
1D - BYE
1F - 2E

Thanks.