protected override void Subsumption(Population Pop)
        {
            Classifier Cl = null;

            foreach (Classifier C in this.CList)
            {
                if (C.CouldSubsume())
                {
                    if ((Cl == null) || (C.C.NumberOfSharp > Cl.C.NumberOfSharp) || ((C.C.NumberOfSharp == Cl.C.NumberOfSharp) && (Configuration.MT.NextDouble() < 0.5)))
                    {
                        Cl = C;
                    }
                }
            }

            if (Cl != null)
            {
                // 削除中にforeachできない
                List <Classifier> CL = new List <Classifier>();

                foreach (Classifier C in this.CList)
                {
                    if (Cl.IsMoreGeneral(C))
                    {
                        Cl.N += C.N;
                        // 削除Classifier登録
                        CL.Add(C);
                    }
                }

                foreach (Classifier C in CL)
                {
                    this.Remove(C);
                    Pop.Remove(C);
                }
            }
        }
        // 包摂
        protected override void Subsumption( Population Pop )
        {
            Classifier Cl = null;

            foreach( Classifier C in this.CList )
            {
                if( C.CouldSubsume() )
                {
                    if( ( Cl == null ) || ( C.C.NumberOfSharp > Cl.C.NumberOfSharp ) || ( ( C.C.NumberOfSharp == Cl.C.NumberOfSharp ) && ( Configuration.MT.NextDouble() < 0.5 ) ) )
                    {
                        Cl = C;//actionsetなかに最も一般的な分類子をClにする
                    }
                }
            }

            if( Cl != null )
            {
                // 削除中にforeachできない
                List<Classifier> CL = new List<Classifier>();

                foreach( Classifier C in this.CList )
                {
                    if( Cl.IsMoreGeneral( C ) )
                    {
                        SigmaNormalClassifier Snc_ko = (SigmaNormalClassifier)C;
                        SigmaNormalClassifier Snc_oya = (SigmaNormalClassifier)Cl;
                        //10の数字は適当 可変にするか? 1/10にする 10-7 あんまり変わらない
                        if (Cl.Kappa == 1 && Math.Abs(Cl.Epsilon - C.Epsilon) < 10 && Snc_ko.IsConvergenceEpsilon()
                            && Snc_oya.IsConvergenceEpsilon())//subsumption するやつの分散が小さい かつε収束時だけ subsumption
                        {
                            Cl.N += C.N;
                            // 削除Classifier登録
                            CL.Add(C);
                        }
                    }
                }

                foreach( Classifier C in CL )
                {

                    SigmaNormalClassifier SNC = ( SigmaNormalClassifier )Cl;
                    //Configuration.ESW.WriteLine( Configuration.T + "," + C.Exp + "," + Cl.C.state + "," + SNC.Epsilon_0 + "," + SNC.Epsilon + "," + SNC.Exp );
                    //if( C.C.state == "000###" | C.C.state == "001###" | C.C.state == "01#0##" | C.C.state == "01#1##" | C.C.state == "10##0#" | C.C.state == "10##1#" | C.C.state == "11###0" | C.C.state == "11###1" )
                    //    Configuration.ESW.WriteLine(Configuration.T + "," + Cl.C.state + "," + C.C.state + "," + Cl.Exp + "," + Cl.Epsilon + "," + Cl.Epsilon_0 + "," + C.Exp + "," + C.Epsilon + "," + C.Epsilon_0 + "," + ++Configuration.Count);
                    //this.Remove( C );
                    //Pop.Remove( C ); 9-7 chou subsumption した分類子見たい

                    if (C.C.state == "1000##" | C.C.state == "0100##" | C.C.state == "0010##" | C.C.state == "0001##"
                        | C.C.state == "1100##" | C.C.state == "0011##" | C.C.state == "1#00##" | C.C.state == "#100##"
                        | C.C.state == "001###" | C.C.state == "00#1##"|C.C.state=="1000##"|C.C.state=="0100##"|C.C.state=="0010##"
                        |C.C.state=="00#1##")
                    {
                        Configuration.ESW.WriteLine(Configuration.T + "," + Cl.C.state + "," +Cl.A+","+ C.C.state + ","+C.A+"," + Cl.Exp + "," + Cl.Epsilon + "," + Cl.Epsilon_0 + "," + C.Exp + "," + C.Epsilon + "," + C.Epsilon_0 + "," + ++Configuration.Count);
                    }
                    //if (C.C.state == "1#00##")
                    //{
                    //    SigmaNormalClassifier Snc = (SigmaNormalClassifier)C;

                    //    Configuration.Problem_1_00.WriteLine(Configuration.T + "," + Snc.C.state + "," + C.F + "," + C.Kappa + ","
                    //        + C.Epsilon + "," + C.Epsilon_0 + "," + C.N + "," + (Snc.IsConvergenceEpsilon() ? 1 : 0));
                    //}
                    this.Remove(C);
                    Pop.Remove(C);
                }
            }
        }
示例#3
0
        // 包摂
        protected override void Subsumption(Population Pop)
        {
            List <Classifier> copyActionSet = new List <Classifier>();

            foreach (Classifier classifier in CList)
            {
                copyActionSet.Add(classifier);
            }
            int N = copyActionSet.Count;

            //最大N回実行する
            //for (int i = 0; i < N; i++)
            //{
            #region subsume
            Classifier Cl = null;

            //actionsetなかに最も一般的な分類子をClにする
            foreach (Classifier C in copyActionSet)
            {
                if (C.CouldSubsume())
                {
                    if ((Cl == null) || (C.C.NumberOfSharp > Cl.C.NumberOfSharp) || ((C.C.NumberOfSharp == Cl.C.NumberOfSharp) && (Configuration.MT.NextDouble() < 0.5)))
                    {
                        Cl = C;
                    }
                }
            }

            if (Cl != null)
            {
                // 削除中にforeachできない

                List <Classifier> CL = new List <Classifier>();

                // 包摂された、削除したいClassifier C をCLに登録
                foreach (Classifier C in copyActionSet)
                {
                    if (Cl.IsMoreGeneral(C))
                    {
                        SigmaNormalClassifier Snc_ko  = (SigmaNormalClassifier)C;
                        SigmaNormalClassifier Snc_oya = (SigmaNormalClassifier)Cl;

                        // e0 の値を3位まで見る、近いものは差がないとみなす
                        var subsumer = Math.Round(Cl.Epsilon_0, 3);
                        var subsumed = Math.Round(C.Epsilon_0, 3);

                        if ((subsumer <= (subsumed + subsumer / 10)) &&
                            Snc_ko.IsConvergenceEpsilon() &&
                            Snc_oya.IsConvergenceEpsilon()
                            )
                        {
                            Cl.N += C.N;

                            CL.Add(C);
                        }
                    }
                }

                foreach (Classifier C in CL)
                {
                    SigmaNormalClassifier SNC = (SigmaNormalClassifier)Cl;


                    if (C.C.state[4] == '0' & C.C.state[7] == '1')    //"bath0 rehabi1"
                    {
                        Configuration.Problem.WriteLine(C.C.state + "," + Configuration.T + "," + C.P + "," + C.M + "," + C.Epsilon + "," + C.F + "," + C.N + "," + C.Exp + "," + C.Ts + "," + C.As + "," + C.Kappa + "," + C.Epsilon_0 + "," + C.St + "," + C.GenerateTime + ", in AS");
                    }

                    this.Remove(C);   //as から削除
                    Pop.Remove(C);    //pop から削除
                }

                //いまの最も一般化されたものを削除する
                //copyActionSet.Remove(Cl);
            }
            #endregion
            //}
        }
        // 包摂
        protected override void Subsumption( Population Pop )
        {
            Classifier Cl = null;

            foreach( Classifier C in this.CList )
            {
                if( C.CouldSubsume() )
                {
                    if( ( Cl == null ) || ( C.C.NumberOfSharp > Cl.C.NumberOfSharp ) || ( ( C.C.NumberOfSharp == Cl.C.NumberOfSharp ) && ( Configuration.MT.NextDouble() < 0.5 ) ) )
                    {
                        Cl = C;
                    }
                }
            }

            if( Cl != null )
            {
                // 削除中にforeachできない
                List<Classifier> CL = new List<Classifier>();

                foreach( Classifier C in this.CList )
                {
                    if( Cl.IsMoreGeneral( C ) )
                    {
                        Cl.N += C.N;
                        // 削除Classifier登録
                        CL.Add( C );
                    }
                }

                foreach( Classifier C in CL )
                {
                    this.Remove( C );
                    Pop.Remove( C );
                }
            }
        }
        protected override void Subsumption( Population Pop )
        {
            Classifier Cl = null;

            foreach( Classifier C in this.CList )
            {
                if( C.CouldSubsume() )
                {
                    if( ( Cl == null ) || ( C.C.NumberOfSharp > Cl.C.NumberOfSharp ) || ( ( C.C.NumberOfSharp == Cl.C.NumberOfSharp ) && ( Configuration.MT.NextDouble() < 0.5 ) ) )
                    {
                        Cl = C;
                    }
                }
            }

            if( Cl != null )
            {
                // 削除中にforeachできない
                List<Classifier> CL = new List<Classifier>();

                foreach( Classifier C in this.CList )
                {
                    if( Cl.IsMoreGeneral( C ) )
                    {
                        Cl.N += C.N;
                        // 削除Classifier登録
                        CL.Add( C );
                    }
                }

                foreach( Classifier C in CL )
                {
                    if(C.C.state=="1#00##")
                    {
                        SigmaNormalClassifier SNC = (SigmaNormalClassifier)C;

                        Configuration.Problem_1_00.WriteLine(Configuration.T + "," + SNC.C.state + "," + C.F + "," + C.Kappa + ","
                            + C.Epsilon + "," + C.Epsilon_0 + "," + C.N + "," + (SNC.IsConvergenceEpsilon() ? 1 : 0));
                    }

                    this.Remove( C );
                    Pop.Remove( C );
                }
            }
        }