Esempio n. 1
0
		public void DefaultDomain()
		{
			FuzzySet C = new TriangleClassifier(new string[]{"low", "high"});
			Assert.AreEqual(0.33333, Math.Round(C["low"].centroid(), 5), "Invalid low centroid");
			Assert.AreEqual(0.66667, Math.Round(C["high"].centroid(), 5), "Invalid high centroid");
			Assert.AreEqual(0.33333, Math.Round(C["high"].Domain.begin, 5), "Invalid high begin");
			Assert.AreEqual(1.0, Math.Round(C["high"].Domain.end, 5), "Invalid high end");
			Assert.AreEqual(0.0, Math.Round(C["low"].Domain.begin, 5), "Invalid low begin");
			Assert.AreEqual(0.66667, Math.Round(C["low"].Domain.end, 5), "Invalid low end");
		}
Esempio n. 2
0
		public void ZeroCross()
		{
			FuzzySet C = new TriangleClassifier(new string[]{"low", "high"}, cross: 0.0);
			Assert.AreEqual(0.33333, Math.Round(C["low"].centroid(), 5), "Invalid low centroid");
			Assert.AreEqual(0.66667, Math.Round(C["high"].centroid(), 5), "Invalid high centroid");
			Assert.AreEqual(0.5, Math.Round(C["high"].Domain.begin, 5), "Invalid high begin");
		}		
Esempio n. 3
0
		public void EdgeTrue()
		{
			FuzzySet C = new TriangleClassifier(new string[]{"low", "high"}, edge: true);
			Assert.AreEqual(0.0, Math.Round(C["low"].centroid(), 5), "Invalid low centroid");
			Assert.AreEqual(1.0, Math.Round(C["high"].centroid(), 5), "Invalid high centroid");
		}
Esempio n. 4
0
		public void OneClass()
		{			
			Assert.Throws(typeof(ArgumentException), delegate{FuzzySet C = new TriangleClassifier(new string[]{"low"});});
		}
Esempio n. 5
0
		public void AnotherDomain()
		{
			FuzzySet C = new TriangleClassifier(new string[]{"low", "high"}, begin: 10.0, end: 23.0);
			Assert.AreEqual(14.33333, Math.Round(C["low"].centroid(), 5), "Invalid low centroid");
			Assert.AreEqual(18.66667, Math.Round(C["high"].centroid(), 5), "Invalid high centroid");
		}
Esempio n. 6
0
        private void ok_btn_Click(object sender, RoutedEventArgs e)
        {
            Paragraph p;
            // Printing data
            Dictionary<string, string> labels = new Dictionary<string, string>();
            labels["p_v"] = "Политические возможности";
            labels["e_v"] = "Экономические возможности";
            labels["s_v"] = "Социальные возможности";
            labels["t_v"] = "Технические возможности";
            labels["p_u"] = "Политические угрозы";
            labels["e_u"] = "Экономические угрозы";
            labels["s_u"] = "Социальные угрозы";
            labels["t_u"] = "Технические угрозы";

            foreach (string key in data.Keys)
            {
                p = new Paragraph(new Run(labels[key]));
                p.FontSize = 16;
                p.FontWeight = System.Windows.FontWeights.Bold;
                FlowDoc.Blocks.Add(p);

                Table t = new Table();
                t.BorderThickness = new Thickness(1.0);
                t.BorderBrush = new SolidColorBrush();

                TableColumn tc;
                tc = new TableColumn();
                tc.Width = new GridLength(250);
                t.Columns.Add(tc);
                tc = new TableColumn();
                tc.Width = new GridLength(130);
                t.Columns.Add(tc);
                tc = new TableColumn();
                tc.Width = new GridLength(130);
                t.Columns.Add(tc);

                t.RowGroups.Add(new TableRowGroup());
                t.RowGroups[0].Rows.Add(new TableRow());
                TableRow currentRow = t.RowGroups[0].Rows[0];
                currentRow.FontWeight = System.Windows.FontWeights.Bold;
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Название показателя"))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Вес"))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Значение"))));

                foreach (Factor item in data[key])
                {
                    t.RowGroups[0].Rows.Add(new TableRow());
                    currentRow = t.RowGroups[0].Rows[t.RowGroups[0].Rows.Count-1];
                    currentRow.FontWeight = FontWeights.Normal;

                    // Add cells with content to the third row.
                    currentRow.Cells.Add(new TableCell(new Paragraph(new Run(item.name))));
                    currentRow.Cells.Add(new TableCell(new Paragraph(new Run(item.weight.ToString()))));
                    currentRow.Cells.Add(new TableCell(new Paragraph(new Run(item.value.ToString()))));
                }

                t.RowGroups[0].Rows.Add(new TableRow());
                currentRow = t.RowGroups[0].Rows[t.RowGroups[0].Rows.Count - 1];
                currentRow.FontWeight = FontWeights.Normal;

                // Add cells with content to the third row.
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Интегральная оценка"))));
                currentRow.Cells[0].ColumnSpan = 2;
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_WA(key).ToString()))));

                FlowDoc.Blocks.Add(t);
            }

            // PEST
            double res_p = _WA("p_v") - _WA("p_u");
            double res_e = _WA("e_v") - _WA("e_u");
            double res_s = _WA("s_v") - _WA("s_u");
            double res_t = _WA("t_v") - _WA("t_u");
            p = new Paragraph(new Run("PEST-анализ"));
            p.FontSize = 16;
            FlowDoc.Blocks.Add(p);
            p = new Paragraph(new Run(
                "Интегральная оценка политических факторов: " + res_p.ToString() + ". \n" +
                "Интегральная оценка экономических факторов: " + res_e.ToString() + ". \n" +
                "Интегральная оценка технических факторов: " + res_t.ToString() + ". \n" +
                "Интегральная оценка социальных факторов: " + res_s.ToString() + ". \n"
            ));
            p.FontSize = 12;
            FlowDoc.Blocks.Add(p);

            // SWOT

            double res_o = (_WA("p_v") + _WA("e_v") + _WA("s_v") + _WA("t_v")) / 4;
            res_t = (_WA("p_u") + _WA("e_u") + _WA("s_u") + _WA("t_u")) / 4;

            FuzzyCalcNET.Set.FuzzySet controller = new TriangleClassifier(new string[] { "I", "II", "III" }, edge: true);
            double res_w = 0.0;
            res_s = 0.0;
            double sum_s = 0.0;
            double sum_w = 0.0;
            foreach (string key in data.Keys)
            {
                foreach (Factor item in data[key])
                {
                    res_w += controller.find(item.value, "I") * item.weight;
                    sum_w += item.weight;
                    res_s += controller.find(item.value, "III") * item.weight;
                    sum_s += item.weight;
                }
            }

            if (sum_s == 0.0)
            {
                res_s = 0.0;
            }
            else
            {
                res_s /= sum_s;
            }

            if (sum_w == 0.0)
            {
                res_w = 0.0;
            }
            else
            {
                res_w /= sum_w;
            }

            p = new Paragraph(new Run("SWOT-анализ"));
            p.FontSize = 16;
            FlowDoc.Blocks.Add(p);
            p = new Paragraph(new Run(
                "Интегральная оценка сильных сторон (S): " + res_s.ToString() + ". \n\r" +
                "Интегральная оценка слабых сторон (W): " + res_w.ToString() + ". \n\r" +
                "Интегральная оценка возможностей (O): " + res_o.ToString() + ". \n\r" +
                "Интегральная оценка угроз (T): " + res_t.ToString() + ". \n\r\n\r" +
                "(SO): " + (res_s * res_o).ToString() + ". \n\r" +
                "(ST): " + (res_s * res_t).ToString() + ". \n\r" +
                "(WO): " + (res_w * res_o).ToString() + ". \n\r" +
                "(WT): " + (res_w * res_t).ToString() + ". \n\r"
            ));
            p.FontSize = 12;
            FlowDoc.Blocks.Add(p);

            p = new Paragraph(new Run("Выводы"));
            p.FontSize = 16;
            FlowDoc.Blocks.Add(p);
            p = new Paragraph(new Run(""));
            p.FontSize = 16;
            FlowDoc.Blocks.Add(p);

            ResultsTab.IsSelected = true;
        }