Esempio n. 1
0
        private static void WriteOrganization(string fileName, Dictionary <RoundBasket, Tournament> tournaments, Dictionary <string, Team> teams)
        {
            using (
                StreamWriter organizationFile =
                    new StreamWriter(string.Format("..\\..\\CategoryTxtOuput\\{0}-Organiser.txt", fileName)),
                organizationEntropy = new StreamWriter(string.Format("..\\..\\CategoryTxtOuput\\{0}-OrganiserEntropy.txt", fileName))
                )
            {
                var organisation = new Dictionary <RoundBasket, Organization>();

                foreach (var tournament in tournaments)
                {
                    var tournametOrganiser = tournament.Value.GetTournamentOrganiser();

                    organisation.Add(
                        tournament.Key,
                        new Organization(
                            tournametOrganiser,
                            teams[tournametOrganiser].Rounds[1].Basket,
                            teams[tournametOrganiser].Rounds[tournament.Key.Round].Basket,
                            tournament.Key.Round == 1 ? (int?)null : teams[tournametOrganiser].Rounds[tournament.Key.Round - 1].Basket
                            )
                        );
                }

                var maxBasket = tournaments.Max(t => t.Key.Basket);
                var maxRound  = tournaments.Max(t => t.Key.Round);

                for (var basket = 1; basket <= maxBasket; basket++)
                {
                    var basketLocal          = basket;
                    var allRoundOrganization = organisation.Where(t => t.Key.Basket == basketLocal);
                    foreach (var tournament in allRoundOrganization.OrderBy(t => t.Key.Round))
                    {
                        organizationFile.Write(
                            "{0} -  Hraje {2} mel poradat {4}\t",
                            tournament.Value.CurrentOrganiserName,
                            tournament.Key.Basket,
                            tournament.Value.CurrentBasketPlay,
                            tournament.Value.PreviousBasketPlay,
                            tournament.Value.DrawBasketOrganisation
                            );
                    }
                    organizationFile.WriteLine();
                }

                var entropyMinimalize = new EntropyMinimalize(maxBasket);

                for (var round = 1; round <= maxRound; round++)
                {
                    organizationEntropy.WriteLine(
                        "{0}\t{1}\t{2}",
                        round,
                        organisation.Where(t => t.Key.Round == round).Sum(t => t.Value.Entropy),
                        entropyMinimalize.MinEntropy(
                            organisation.Where(t => t.Key.Round == round).Select(t => t.Value.CurrentBasketPlay).ToList())
                        );
                }
            }
        }
Esempio n. 2
0
        private static void WriteOrganization(string fileName, Dictionary<RoundBasket, Tournament> tournaments, Dictionary<string, Team> teams)
        {
            using (
                StreamWriter organizationFile =
                    new StreamWriter(string.Format("..\\..\\CategoryTxtOuput\\{0}-Organiser.txt", fileName)),
                    organizationEntropy = new StreamWriter(string.Format("..\\..\\CategoryTxtOuput\\{0}-OrganiserEntropy.txt", fileName))
                )
            {
                var organisation = new Dictionary<RoundBasket, Organization>();

                foreach (var tournament in tournaments)
                {
                    var tournametOrganiser = tournament.Value.GetTournamentOrganiser();

                    organisation.Add(
                        tournament.Key,
                        new Organization(
                            tournametOrganiser,
                            teams[tournametOrganiser].Rounds[1].Basket,
                            teams[tournametOrganiser].Rounds[tournament.Key.Round].Basket,
                            tournament.Key.Round == 1 ? (int?) null : teams[tournametOrganiser].Rounds[tournament.Key.Round - 1].Basket
                            )
                        );
                }

                var maxBasket = tournaments.Max(t => t.Key.Basket);
                var maxRound = tournaments.Max(t => t.Key.Round);

                for (var basket = 1; basket <= maxBasket; basket++)
                {
                    var basketLocal = basket;
                    var allRoundOrganization = organisation.Where(t => t.Key.Basket == basketLocal);
                    foreach (var tournament in allRoundOrganization.OrderBy(t => t.Key.Round))
                    {
                        organizationFile.Write(
                            "{0} -  Hraje {2} mel poradat {4}\t",
                            tournament.Value.CurrentOrganiserName,
                            tournament.Key.Basket,
                            tournament.Value.CurrentBasketPlay,
                            tournament.Value.PreviousBasketPlay,
                            tournament.Value.DrawBasketOrganisation
                            );
                    }
                    organizationFile.WriteLine();
                }

                var entropyMinimalize = new EntropyMinimalize(maxBasket);

                for (var round = 1; round <= maxRound; round++)
                {
                    organizationEntropy.WriteLine(
                        "{0}\t{1}\t{2}",
                        round,
                        organisation.Where(t => t.Key.Round == round).Sum(t => t.Value.Entropy),
                        entropyMinimalize.MinEntropy(
                            organisation.Where(t => t.Key.Round == round).Select(t => t.Value.CurrentBasketPlay).ToList())
                        );
                }
            }
        }