Esempio n. 1
0
 public Candidate(int JN, double IL, double AR = 0)
 {
     jumpNum         = JN;
     beliefUpdater   = new BeliefUpdater(IL);
     awarenessRate   = AR;
     determinedRound = new List <bool>();
 }
Esempio n. 2
0
 public Candidate(int JN, double IL, double AR = 0)
 {
     jumpNum = JN;
     beliefUpdater = new BeliefUpdater(IL);
     awarenessRate = AR;
     determinedRound = new List<bool>();
 }
Esempio n. 3
0
 public override void UpdateOpinion(BlackWhiteSubject sub, BeliefUpdater updater)
 {
     //自分の意見と同じ意見が来たら
     if (sub == BlackWhiteSubject.White && Belief >= Sigma ||
         sub == BlackWhiteSubject.Black && Belief <= 1 - Sigma)
     {
         base.UpdateOpinion(sub, new BeliefUpdater( 0.5)); //重要視度0で更新する。
     }
     else
     {
         base.UpdateOpinion(sub, updater);
     }
 }
Esempio n. 4
0
 public override void UpdateOpinion(BlackWhiteSubject sub, BeliefUpdater updater)
 {
     //自分の意見と同じ意見が来たら
     if (sub == BlackWhiteSubject.White && Belief >= Sigma ||
         sub == BlackWhiteSubject.Black && Belief <= 1 - Sigma)
     {
         base.UpdateOpinion(sub, new BeliefUpdater(0.5));  //重要視度0で更新する。
     }
     else
     {
         base.UpdateOpinion(sub, updater);
     }
 }
Esempio n. 5
0
        public virtual void UpdateOpinion(BlackWhiteSubject sub, BeliefUpdater updater)
        {
            thought.Belief = updater.updateBelief(sub, thought.Belief);


            //意見を変える際に、カウント
            if (sub == BlackWhiteSubject.White)
            {
                counter.CountUp();
            }
            else //if(sub == BlackWhiteSubject.Black)
            {
                counter.CountDown();
            }
        }
Esempio n. 6
0
        public virtual void UpdateOpinion(BlackWhiteSubject sub, BeliefUpdater updater)
        {
            thought.Belief = updater.updateBelief(sub, thought.Belief);

            ////Console.WriteLine("AAT: UpdateOpinion()");
            //意見を変える際に、カウント
            if (sub == BlackWhiteSubject.White)
            {
                counter.CountUp();
            }
            else //if(sub == BlackWhiteSubject.Black)
            {
                counter.CountDown();
            }
        }
        //候補集合を初期化
        public void BuildCandidate(int neighbourNum, IThought thought)//ご近所の数と初期重要視度を渡されることで候補を生成
        {
            if (neighbourNum <= 0)
            {
                return;
            }

            //Sigma=Thought   PriorBelief=Thought   updateFunc=BeliefUpdater
            lock (CandidateLock)
            {
                //ご近所の数
                int dn = neighbourNum;

                //ご近所の数の2倍だけ作成
                candidates = new Candidate[2 * dn];

                double sigmaRight = thought.SigmaRight;
                double sigmaLeft  = thought.SigmaLeft;

                double impLvl = 0.5;
                // Jumpnum = 3, 2, 1と調べていく.
                for (int l = dn; l >= 0; l--)
                {
                    //importance levelを上げていって,beliefがしきい値を超えたときその値を使う.
                    for (; impLvl <= 1; impLvl += 0.001)
                    {
                        if (BeliefUpdater.updateFunc(thought.PriorBelief, impLvl, l) > sigmaRight)
                        {
                            Candidate newcan = new Candidate(l, impLvl);

                            //この重要視度で、逆側に行くときは、何ステップでいけるのか?
                            double tmpBelief = thought.PriorBelief;
                            int    count     = 0;
                            do
                            {
                                tmpBelief = BeliefUpdater.updateFunc(tmpBelief, 1 - impLvl);//逆では1-impLvl
                                count++;
                            } while (!(tmpBelief <= sigmaLeft));

                            newcan.OtherJumpNum = count;

                            candidates[l - 1] = newcan;
                            break;
                        }
                    }
                }

                impLvl = 0.5;
                for (int l = dn; l >= 0; l--)
                {
                    for (; impLvl <= 1; impLvl += 0.001) //impLvl ∈ (0.5, 1.0)
                    {
                        if (BeliefUpdater.updateFunc(thought.PriorBelief, 1 - impLvl, l) < sigmaLeft)
                        {
                            //重要視度を決定
                            Candidate newcan = new Candidate(-l, impLvl);

                            //この重要視度で、逆側に行くときは、何ステップでいけるのか?
                            double tmpBelief = thought.PriorBelief;
                            int    count     = 0;
                            do
                            {
                                tmpBelief = BeliefUpdater.updateFunc(tmpBelief, impLvl); //1-impLvlの逆なのでimpLvl
                                count++;
                            } while (!(tmpBelief >= sigmaRight));                        //0.8を超えたら

                            newcan.OtherJumpNum = count;


                            candidates[l - 1 + dn] = newcan;

                            break;
                        }
                    }
                }
            }//lock
            CurrentCandidate = candidates.Last();

            OnEstimationChanged(new EstimationEventArgs(Candidates));

            OnCandidateChanged(new CandidateEventArgs(CurrentCandidate));
        }
Esempio n. 8
0
        //Viewのために計算
        private static IEnumerable<double> calcBeliefList(double prior,double sigma, BeliefUpdater updater)
        {
            //ImportanceLevelが変わったら実行
            //priorbeliefとupdaterがあればできる

            List<double> beliefList = new List<double>();

            //更新しないようなパラメータでは、無限ループになってしまう
            if (updater.ImportanceLevel == 0.5)
            {
                return beliefList;
            }

            double goright = prior;
            double goleft = prior;

            //初期値を目盛に追加
            beliefList.Add(prior);

            do{
                goright = updater.updateBelief(BlackWhiteSubject.White, goright);
                beliefList.Add(goright);
            } while(goright < sigma );//&& i < 5);

            do{
                goleft = updater.updateBelief(BlackWhiteSubject.Black, goleft);
                beliefList.Add(goleft);
            } while(goleft > (1-sigma)  );//&& i < 5);

            return beliefList;
        }