Esempio n. 1
0
        public void GetRandomCases_File()
        {
            exp_random_cases.Clear();
            exp_random_cases_nonstandrize.Clear();
            Case        Max_Mean = Db.get_Case_data(standrize_table, -2);
            Case        Min_Sd   = Db.get_Case_data(standrize_table, -3);
            List <Case> templist = new List <Case>();

            templist = Db.read_file();


            if (templist.Count != 0)
            {
                for (int i = 0; i < templist.Count; i++)
                {
                    exp_random_cases_nonstandrize.Add(templist[i]);
                    //  i have to put general seetings for normalization a
                    Case c = BestChoice.StandardizeCase(templist[i], Max_Mean, Min_Sd, standrize_type);
                    exp_random_cases.Add(c);
                }
            }
        }
Esempio n. 2
0
        //=========================================================================================
        public void GenerateRandomCases()
        {
            exp_random_cases.Clear();
            Case        Max_Mean = Db.get_Case_data(standrize_table, -2);
            Case        Min_Sd   = Db.get_Case_data(standrize_table, -3);
            Random      r        = new Random();
            List <Case> Cases    = Db.get_cases_condition(tablename, casename);

            for (int i = 0; i < 100; i++)
            {
                double x = 0;
                Case   c = new Case(0, Max_Mean.GetCaseName(), "");

                for (int j = 0; j < Max_Mean.GetFeatures().Count; j++)
                {
                    Feature max_f = (Feature)Max_Mean.GetFeatures()[j];
                    Feature min_f = (Feature)Min_Sd.GetFeatures()[j];
                    if (max_f.GetFeatureName() == "id")
                    {
                        x = (double)i;
                    }
                    else if (max_f.GetFeatureName() == "cluster")
                    {
                        x = -1;
                    }
                    else if (max_f.GetFeatureType() >= 5 && max_f.GetFeatureType() <= 9)// mstring, string, ordinal, categorical
                    {
                        int     k = r.Next(0, Cases.Count);
                        Feature f = (Feature)Cases[k].GetFeatures()[j];
                        c.AddFeature(max_f.GetFeatureName(), max_f.GetFeatureType(), f.GetFeatureValue(), max_f.GetWeight(), max_f.GetIsKey(), max_f.GetIsIndex(), max_f.GetFeatureUnit());
                        continue;
                    }
                    else if (max_f.GetFeatureType() == 1)// mstring, string, ordinal, categorical
                    {
                        int  k = r.Next(0, 2);
                        bool o = false;
                        if (k == 1)
                        {
                            o = true;
                        }
                        c.AddFeature(max_f.GetFeatureName(), max_f.GetFeatureType(), o, max_f.GetWeight(), max_f.GetIsKey(), max_f.GetIsIndex(), max_f.GetFeatureUnit());
                        continue;
                    }
                    else if (max_f.GetFeatureType() == 2)
                    {
                        int max = Convert.ToInt32(max_f.GetFeatureValue());
                        int min = Convert.ToInt32(min_f.GetFeatureValue());
                        x = r.Next(min, max + 1);
                    }
                    else
                    {
                        double max = Convert.ToDouble(max_f.GetFeatureValue());
                        double min = Convert.ToDouble(min_f.GetFeatureValue());
                        x = r.NextDouble(min, max + 0.05);
                        x = Math.Round(x, 1);
                    }

                    c.AddFeature(max_f.GetFeatureName(), max_f.GetFeatureType(), x, max_f.GetWeight(), max_f.GetIsKey(), max_f.GetIsIndex(), max_f.GetFeatureUnit());
                }
                exp_random_cases_nonstandrize.Add(c);
                //  i have to put general seetings for normalization
                exp_random_cases.Add(BestChoice.StandardizeCase(c, Max_Mean, Min_Sd, standrize_type));
            }
        }
Esempio n. 3
0
        private void button5_Click_1(object sender, EventArgs e)
        {
            statistics = new Statistics(mybestchoice.TableName, mybestchoice.CaseName);
            Case   Max_Mean = Db.get_Case_data(statistics.standrize_table, -2);
            Case   Min_Sd   = Db.get_Case_data(statistics.standrize_table, -3);
            string url      = "";

            System.IO.StreamReader reader          = null;
            OpenFileDialog         openFileDialog1 = new OpenFileDialog();
            ArrayList inputs = new ArrayList();

            // Set filter options and filter index.
            openFileDialog1.Filter      = "Text Files (.key)|*.key|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;

            openFileDialog1.Multiselect = true;

            // Call the ShowDialog method to show the dialog box.
            DialogResult userClickedOK = openFileDialog1.ShowDialog();

            // Process input if the user clicked OK.
            if (userClickedOK.Equals(DialogResult.OK))
            {
                url    = openFileDialog1.FileName;
                reader = File.OpenText(url);
                if (reader == null)
                {
                    System.Console.WriteLine("file open failed " + url);
                    return;
                }

                for (int i = 0; i < dataGV_CaseEntries.Rows.Count; i++)
                {
                    string s = reader.ReadLine();
                    dataGV_CaseEntries.Rows[i].Cells["UserEntry"].Value = s;
                    inputs.Add(s);
                }
                reader.Close();
            }



            Case _problem = new Case(0, mybestchoice.CaseName, "");

            _problem.AddFeature("id", FeatureType.TYPE_FEATURE_INT, 0, 1.0, false, false, "num");


            for (int i = 0; i < dataGV_CaseEntries.Rows.Count - 1; i++)
            {
                if (dataGV_CaseEntries.Rows[i].Cells["UserEntry"].Value.ToString() != "".ToString())
                {
                    _problem.AddFeature(
                        dataGV_CaseEntries.Rows[i].Cells["FeatureName"].Value.ToString().Trim(),
                        Token.GetType(dataGV_CaseEntries.Rows[i].Cells["FeatureType"].Value.ToString().Trim()),
                        dataGV_CaseEntries.Rows[i].Cells["UserEntry"].Value.ToString().Trim(),
                        Convert.ToDouble(dataGV_CaseEntries.Rows[i].Cells["FeatureWeight"].Value.ToString().Trim()),
                        Convert.ToBoolean(dataGV_CaseEntries.Rows[i].Cells["FeatureKey"].Value.ToString().Trim()),
                        Convert.ToBoolean(dataGV_CaseEntries.Rows[i].Cells["FeatureIndex"].Value.ToString().Trim()),
                        dataGV_CaseEntries.Rows[i].Cells["FeatureUnit"].Value.ToString().Trim());
                }
            }

            _problem.AddFeature("cluster", FeatureType.TYPE_FEATURE_INT, 0, 1.0, false, false, "num");
            statistics.exp_random_cases.Add(BestChoice.StandardizeCase(_problem, Max_Mean, Min_Sd, statistics.standrize_type));
            statistics.exp_random_cases_nonstandrize.Add(_problem);
            mybestchoice.Problem          = statistics.exp_random_cases_nonstandrize[0];
            mybestchoice.StandrizeProblem = statistics.exp_random_cases[0];
        }