示例#1
0
文件: PNUXML.cs 项目: adam-norman/PNU
 private void CheckStopLevel()
 {
     if (chkShowCurrentLevel.Checked)
     {
         SetText("Current Level=" + CurrentLevel.ToString() + "  With only " + NotUniqueSetsPrevLevel.Count + " Not Unique Starting sets  were found in level" + (CurrentLevel - 1).ToString() + " and nonesense sets=" + NrOfNonesenseSets.ToString() + " with percentage=" + (100 * (double)NrOfNonesenseSets / (double)NotUniqueSetsPrevLevel.Count).ToString() + "  At Time:" + DateTime.Now.ToString() + Environment.NewLine);
         System.Diagnostics.Debug.Write("Current Level=" + CurrentLevel.ToString() + "  With only " + NotUniqueSetsPrevLevel.Count + " Not Unique Starting sets  were found in level" + (CurrentLevel - 1).ToString() + " and nonesense sets=" + NrOfNonesenseSets.ToString() + " with percentage=" + (100 * (double)NrOfNonesenseSets / (double)NotUniqueSetsPrevLevel.Count).ToString() + "  At Time:" + DateTime.Now.ToString() + Environment.NewLine);
         NrOfNonesenseSets = 0;
     }
     PublicNotUniq.Clear();
     tmpNUList = (ArrayList)NotUniqueSetsPrevLevel.Clone();
     NrOfNotUniqueThatWillBeChecked = 0;
     NotUniqueSetsPrevLevel.Clear();
     for (int k = 0; k < tmpNUList.Count; k++)
     {
         List <NotUniqueSet> temp = new List <NotUniqueSet>();
         PublicNotUniq.Add(temp);
         ArrayList tt = new ArrayList();
         PublicUniq.Add(tt);
     }
     Parallel.For(0, tmpNUList.Count, new ParallelOptions {
         MaxDegreeOfParallelism = 32
     }, i =>
     {
         //for (int i = 0; i < tmpNUList.Count; i++)
         //{
         NotUniqueSet pl1        = (NotUniqueSet)tmpNUList[i];
         ArrayList OldSetIndices = (ArrayList)pl1._NotUniqueSetIndexes.Clone();
         for (int j = SkipperListComplement.IndexOf(pl1._NotUniqueSet[pl1._NotUniqueSet.Count - 1]) + 1; j < SkipperListComplement.Count; j++)
         {
             pl1._NotUniqueSet.Add(SkipperListComplement[j]);
             pl1._NotUniqueSetIndexes = (ArrayList)OldSetIndices.Clone();
             IsUnique(pl1, i);
             pl1._NotUniqueSet.RemoveAt(pl1._NotUniqueSet.Count - 1);
         }
         tmpNUList[i] = null;
     });
 }
示例#2
0
文件: PNUXML.cs 项目: adam-norman/PNU
        public void IsUnique(NotUniqueSet CurrentSetPositions, int threadID)
        {
            if (HasSubsumtions_Traditional(CurrentSetPositions._NotUniqueSet))
            {
                TotalPartialReduct++;
                return;
            }
            ArrayList PassedSetRowIndices = new ArrayList();
            ArrayList allListInterSection = new ArrayList();

            if (CurrentLevel > 1)
            {
                int           NewAddedFeature = (int)CurrentSetPositions._NotUniqueSet[CurrentSetPositions._NotUniqueSet.Count - 1];
                FeatureValues fv = DsMeta[NewAddedFeature];
                PassedSetRowIndices.Add((ArrayList)fv.RowsIndices.Clone());
                PassedSetRowIndices.Add((ArrayList)CurrentSetPositions._NotUniqueSetIndexes.Clone());
                ArrayList OldSetIndices = (ArrayList)CurrentSetPositions._NotUniqueSetIndexes.Clone();
                allListInterSection = fnGetIntersection1(PassedSetRowIndices);
                CurrentSetPositions._NotUniqueSetIndexes = (ArrayList)allListInterSection.Clone();
                if (allListInterSection.Count == OldSetIndices.Count)
                {
                    NrOfNonesenseSets++;
                    TotalNoneSense++;
                    return;
                }
            }
            else
            {
                FeatureValues fv = DsMeta[(int)CurrentSetPositions._NotUniqueSet[0]];
                allListInterSection.AddRange(fv.RowsIndices);
                CurrentSetPositions._NotUniqueSetIndexes = allListInterSection;
            }
            int    c = 1;
            string t = Dataset.Categories[Int32.Parse(allListInterSection[0].ToString())].ToString();

            for (int k = 1; k < allListInterSection.Count; k++)
            {
                if (t != Dataset.Categories[Int32.Parse(allListInterSection[k].ToString())].ToString())
                {
                    c++;
                    break;
                }
            }
            double MaxClassCount = ClassesCounterTmp.Max();

            if (c == 1)
            {
                TotalUnique++;
                FeatureValues fv = new FeatureValues();
                fv.UnkSet      = (ArrayList)CurrentSetPositions._NotUniqueSet.Clone();
                fv.RowsIndices = (ArrayList)allListInterSection.Clone();
                PublicUniq[threadID].Add(fv);
                if (CurrentLevel == 1)
                {
                    SkipperListComplement.Remove(CurrentSetPositions._NotUniqueSet[0]);
                    if (SkipperListComplement.Count > 0)
                    {
                        LastFeature = (int)SkipperListComplement[SkipperListComplement.Count - 1];
                    }
                }
                return;
            }

            // not unique Handling
            TotalNotUnique++;
            if (!CurrentSetPositions._NotUniqueSet.Contains(LastFeature))
            {
                NotUniqueSet nus = new NotUniqueSet();
                nus._NotUniqueSet        = (ArrayList)CurrentSetPositions._NotUniqueSet.Clone();
                nus._NotUniqueSetIndexes = (ArrayList)allListInterSection.Clone();
                PublicNotUniq[threadID].Add(nus);
                NrOfNotUniqueThatWillBeChecked++;
            }
            //end
        }
示例#3
0
文件: PNUXML.cs 项目: adam-norman/PNU
        public void PowerSet()
        {
            for (int k = 0; k < SkipperListComplement.Count; k++)
            {
                List <NotUniqueSet> temp = new List <NotUniqueSet>();
                PublicNotUniq.Add(temp);
                ArrayList tt = new ArrayList();
                PublicUniq.Add(tt);
            }
            TotalNotUnique = TotalNotUnique + (PublicUniq.Count - 1) - TotalUnique;
            CurrentLevel   = 1;
            ArrayList AllFeaturesFirstLevel = (ArrayList)SkipperListComplement.Clone();

            foreach (int f in AllFeaturesFirstLevel)
            {
                InitSetlist.Clear();
                InitSetlist.Add(f);
                NotUniqueSet nus = new NotUniqueSet();
                nus._NotUniqueSet = (ArrayList)InitSetlist.Clone();
                IsUnique(nus, 0);
            }

            for (int thread = 0; thread < PublicUniq.Count; thread++)
            {
                ArrayList Threadlst = PublicUniq[thread];
                foreach (FeatureValues fv in Threadlst)
                {
                    LstOfUniqueSets.Add(fv.UnkSet);
                    int index = LstOfUniqueSets.Count - 1;
                    htOc.Add(index, fv.RowsIndices.Count);
                    foreach (int r in fv.RowsIndices)
                    {
                        LstOfRowsFeaturesSetsIDs[r].Add(index);
                    }
                }
            }
            PublicUniq.Clear();
            NotUniqueSetsPrevLevel.Clear();
            for (int i = 0; i < PublicNotUniq.Count; i++)
            {
                for (int j = 0; j < PublicNotUniq[i].Count; j++)
                {
                    NotUniqueSetsPrevLevel.Add((NotUniqueSet)PublicNotUniq[i][j]);
                }
            }


            CurrentLevel++;
            while (WorkMood())//SkipperListComplement.Count && NotUniqueSetsPrevLevel.Count > 0  )
            {
                CheckStopLevel();
                CurrentLevel++;

                for (int thread = 0; thread < PublicUniq.Count; thread++)
                {
                    ArrayList Threadlst = PublicUniq[thread];
                    foreach (FeatureValues fv in Threadlst)
                    {
                        LstOfUniqueSets.Add(fv.UnkSet);
                        int index = LstOfUniqueSets.Count - 1;
                        htOc.Add(index, fv.RowsIndices.Count);
                        foreach (int r in fv.RowsIndices)
                        {
                            LstOfRowsFeaturesSetsIDs[r].Add(index);
                        }
                    }
                }
                PublicUniq.Clear();
                NotUniqueSetsPrevLevel.Clear();
                for (int i = 0; i < PublicNotUniq.Count; i++)
                {
                    for (int j = 0; j < PublicNotUniq[i].Count; j++)
                    {
                        NotUniqueSetsPrevLevel.Add((NotUniqueSet)PublicNotUniq[i][j]);
                    }
                }
            }
        }