Exemple #1
0
        private void button13_Click_2(object sender, EventArgs e)
        {
            int c;

            double[] ranks;
            int      dG_With = 0;

            ahp_sol_no_clustering = new MyAHPModel(CriteriaArr.GetLength(0), mybestchoice.Cases.Count);
            ahp_sol_no_clustering.AddCriteria(CriteriaArr);
            ahp_sol_no_clustering.AddCriterionRatedChoices(ChoicesArr_Non);
            if (ahp_sol_no_clustering.CalculatedCriteria())
            {
                ranks = ahp_sol_no_clustering.CalculatedChoices(out c);
                if (c != -1)
                {
                    MessageBox.Show("عدم تناسق في تفضيلات البدائل المدخلة للمعيار رقم" + c.ToString());
                    return;
                }
            }

            else
            {
                MessageBox.Show("عدم تناسق في تفضيلات المعايير المدخلة");
                return;
            }



            dg_results_no_clustering.Columns.Add("SolutionID", "Solution ID");
            dg_results_no_clustering.Columns.Add("SolutionWeight", "Solution Weight");
            dg_results_no_clustering.Columns.Add("SolutionSim", "Solution Similarity");
            for (int i = 0; i < ranks.Length; i++)
            {
                dg_results_no_clustering.Rows.Add();
                dg_results_no_clustering.Rows[dG_With].Cells[0].Value = mybestchoice.Cases[i].GetFeature("id").GetFeatureValue().ToString();
                dg_results_no_clustering.Rows[dG_With].Cells[1].Value = Math.Round(ranks[i] * 100, 2);
                EuclideanSimilarity s    = new EuclideanSimilarity();
                List <Case>         sols = Db.get_cases_condition(mybestchoice.Tablename_Standardization, mybestchoice.CaseName);
                dg_results_no_clustering.Rows[dG_With].Cells[2].Value = Math.Round(s.Similarity(sols[i], mybestchoice.StandrizeProblem) * 100, 2);
                dG_With++;
            }

            dg_results_no_clustering.Sort(dg_results_no_clustering.Columns["SolutionWeight"], ListSortDirection.Descending);
        }
        private void button11_Click_1(object sender, EventArgs e)
        {
            // display


            int dG_NonR = 0;

            dG_Non.Columns.Clear();



            //dG_Non.Columns.Add("Porblem No ", "Porblem No  ");
            dG_Non.Columns.Add("SolNum", "Sol Num  ");
            dG_Non.Columns.Add("Weight  ", "Weight  ");
            dG_Non.Columns.Add("Sim  ", "Sim  ");



            List <Case> solutions = statistics.FindAlternative_WithClustering(statistics.exp_random_cases[problem_num]);

            // call method
            listBox1.Items.Add("Finding Alternatices by specifying best cluster");

            double[] ranks;
            int      cri = 0;
            Dictionary <int, double[, ]> choices;

            double[,] criteriaarr;

            MyAHPModel myahp = new MyAHPModel(statistics.count_citeria, solutions.Count);

            criteriaarr = GenerateComparison.CriteriaComparisonMatrix;
            myahp.AddCriteria(criteriaarr);



            if (myahp.CalculatedCriteria())
            {
                choices = GenerateComparison.Create_All_Criteria_Choice_Comparison_Array(solutions);
                myahp.AddCriterionRatedChoices(choices);
                ranks = myahp.CalculatedChoices(out cri);
                for (int i = 0; i < ranks.Length; i++)
                {
                    dG_Non.Rows.Add();
                    dG_Non.Rows[dG_NonR].Cells[0].Value = solutions[i].GetFeature("id").GetFeatureValue().ToString();
                    dG_Non.Rows[dG_NonR].Cells[1].Value = Math.Round(ranks[i] * 100, 2);
                    EuclideanSimilarity s = new EuclideanSimilarity();
                    dG_Non.Rows[dG_NonR].Cells[2].Value = Math.Round(s.Similarity(solutions[i], statistics.exp_random_cases[problem_num]) * 100, 2);
                    dG_NonR++;
                }
            }
            dG_Non.Sort(dG_Non.Columns[1], ListSortDirection.Descending);

            // display Criteria
            if (dG_Prob.Columns.Count == 0)
            {
                dG_Prob.Columns.Add("Criteria", " Criteria ");
                dG_Prob.Columns.Add("AHP", "AHP");
                dG_Prob.Columns.Add("FuzzyAHP", "Fuzzy AHP");
                for (int i = 1; i < solutions[0].GetFeatures().Count - 1; i++)
                {
                    dG_Prob.Rows.Add();
                    Feature f = (Feature)solutions[0].GetFeatures()[i];
                    dG_Prob.Rows[i - 1].Cells[0].Value = f.GetFeatureName().ToString();
                    dG_Prob.Rows[i - 1].Cells[1].Value = Math.Round(myahp.CriteriaWeights[i - 1] * 100, 2);
                }
            }
            else
            {
                for (int i = 1; i < solutions[0].GetFeatures().Count - 1; i++)
                {
                    Feature f = (Feature)solutions[0].GetFeatures()[i];
                    dG_Prob.Rows[i - 1].Cells[1].Value = Math.Round(myahp.CriteriaWeights[i - 1] * 100, 2);
                }
            }
            dG_Prob.AutoResizeColumns();
            dG_Prob.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            dG_Non.AutoResizeColumns();
            dG_Non.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }