示例#1
0
        private void begin_Click(object sender, EventArgs e)
        {
            EnabledControls(true);
            relativeMajority = new RelativeMajority((int)alternatives_count.Value);
            clearWinner      = new ClearWinner();
            kopland          = new Kopland();
            simpson          = new Simpson();
            board            = new Board();

            for (int i = 0; i < (int)experts_count.Value; i++)
            {
                Expert expert = new Expert("Эксперт " + (i + 1), (int)alternatives_count.Value);
                experts.Add(expert);
            }
            relativeMajority.Experts = experts;
            current_expert_name.Text = experts[0].Name;

            for (int i = 0; i < (int)alternatives_count.Value; i++)
            {
                alternatives.Items.Add("Альтернатива " + (i + 1));
                relative_majority_dgv.Rows.Add(alternatives.Items[i].ToString(), "0", "0,00");
            }

            for (int i = 0; i < dgvs.Length; i++)
            {
                for (int j = 0; j < (int)experts_count.Value; j++)
                {
                    dgvs[i].Columns.Add("expert" + j, "Эксперт " + (j + 1));
                }
                dgvs[i].Rows.Add((int)alternatives_count.Value);
            }
        }
示例#2
0
        public void TestKoplandMethod()
        {
            int           alternatinves = 3;
            Kopland       kopland       = new Kopland();
            List <Expert> experts       = new List <Expert>();
            Expert        expert1       = new Expert("Эксперт 1", alternatinves);
            Expert        expert2       = new Expert("Эксперт 2", alternatinves);
            Expert        expert3       = new Expert("Эксперт 3", alternatinves);
            Expert        expert4       = new Expert("Эксперт 4", alternatinves);
            Expert        expert5       = new Expert("Эксперт 5", alternatinves);
            Expert        expert6       = new Expert("Эксперт 6", alternatinves);

            expert1.Preferences = new int[] { 2, 1, 3 };
            expert2.Preferences = new int[] { 3, 2, 1 };
            expert3.Preferences = new int[] { 1, 3, 2 };
            expert4.Preferences = new int[] { 2, 1, 3 };
            expert5.Preferences = new int[] { 2, 1, 3 };
            expert6.Preferences = new int[] { 2, 3, 1 };
            experts.AddRange(new Expert[] { expert1, expert2, expert3, expert4, expert5, expert6 });
            kopland.Experts = experts;

            Assert.AreEqual("Альтернатива 1", kopland.Execute());
        }