public ActionResult Upload(HttpPostedFileBase upload)
        {
            string FileFormat = "";

            if (upload != null)
            {
                // получаем имя файла
                string fileName = System.IO.Path.GetFileName(upload.FileName);
                // сохраняем файл в папку Files в проекте
                FuzzyKnowledgeBase FKB = new FuzzyKnowledgeBase();
                FKB.ListOfRule.Clear();
                FKB.ListVar.Clear();
                upload.SaveAs(Server.MapPath("~/Files/" + fileName));
                HttpContext.Response.Cookies["FileName"].Value = fileName;
                FileFormat = FileHelper.CheckFileFormat(fileName);
                if (FileFormat == "txt")
                {
                    return(RedirectToAction("ReadyForms", "Сonclusion", new { FileName = fileName }));
                }
                else if (FileFormat == "xls")
                {
                    ExelReader.ReadFromXLS(upload.FileName);
                    K_means k       = new K_means(ExelReader.ElementsMulti, null, ExelReader.ClusterCount, ExelReader.ElementsMatrix);
                    double  epsilon = 0.05;
                    k.Clustering(ExelReader.ClusterCount, epsilon);
                    k.FindRulesModelTypeMamdani(ExelReader.NameOfLinguisticVariables, ExelReader.ValueIntervalTerm, ExelReader.NameOfTerms, ExelReader.countColumnData, ExelReader.NumbersOfZonesOneLP, ExelReader.counterFoRowDataFromFile, "Трикутна", ExelReader.WeightOfTerms, FKB);
                    k.GausFunction(ExelReader.countColumnData, FKB);
                    FKBHelper.WithRullToVar(FKB);
                    FKBHelper.Save_BNZ(FKB, Server.MapPath("~/Files/BNZauto.txt"));
                    return(RedirectToAction("ReadyForms", "Сonclusion", new { FileName = "BNZauto.txt" }));
                }
            }
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public void ComputeTest()
        {
            List <Pointer> pointers = new List <Pointer>()
            {
                new  Pointer()
                {
                    X = 1, Y = 21, Z = 0
                },
                new  Pointer()
                {
                    X = 12, Y = 23, Z = 0
                },
                new  Pointer()
                {
                    X = 10, Y = 2, Z = 0
                },
                new  Pointer()
                {
                    X = 3, Y = 10, Z = 0
                },
                new  Pointer()
                {
                    X = 13, Y = 12, Z = 0
                },
                new  Pointer()
                {
                    X = 4, Y = 15, Z = 0
                },
                new  Pointer()
                {
                    X = 9, Y = 6, Z = 0
                },
                new  Pointer()
                {
                    X = 21, Y = 8, Z = 0
                },
                new  Pointer()
                {
                    X = 11, Y = 6, Z = 0
                },
                new  Pointer()
                {
                    X = 21, Y = 9, Z = 0
                },
            };
            K_means kmeans = new K_means(pointers);

            kmeans.Compute(3);
        }
Beispiel #3
0
        public static ClusteringResult Kmeans(IMathSet mathSet, ClusteringOptions options)
        {
            if (mathSet != null)
            {
                if (options.ClusterCount <= mathSet.RowsCount)
                {
                    switch (options.Mode)
                    {
                    case ModeType.SINGLETHREADED:
                        return(K_means.Singlethreaded(mathSet, options));

                    case ModeType.MULTITHREADED:
                        return(K_means.Multithreaded(mathSet, options));

                    default:
                        throw new ArgumentException("был выбран неприемлемый параметр из enum AlgoritmType");
                    }
                }
                throw new ArgumentException("количество точек с данными в input Set должно быть больше или равно количества кластеров в options");
            }
            throw new ArgumentNullException("входной набор данных inputSet равен null");
        }