Exemple #1
0
        public void UpdateCounter_Counterの正常系テスト()
        {
            UpdateCounter counter = new UpdateCounter();

            counter.CountUp();
            counter.CountUp();
            counter.CountUp();

            Assert.AreEqual(counter.UpdateNum, 3);
            Assert.AreEqual(counter.UpdateRight, 3);
            Assert.AreEqual(counter.UpdateLeft, 0);

            counter.CountDown();
            counter.CountDown();
            counter.CountDown();

            Assert.AreEqual(counter.UpdateNum, 0);
            Assert.AreEqual(counter.UpdateRight, 3);
            Assert.AreEqual(counter.UpdateLeft, 0);

            counter.CountDown();
            counter.CountDown();
            counter.CountDown();

            Assert.AreEqual(counter.UpdateNum, -3);
            Assert.AreEqual(counter.UpdateRight, 3);
            Assert.AreEqual(counter.UpdateLeft, 3);

            counter.CountUp();
            counter.CountUp();
            counter.CountUp();

            Assert.AreEqual(counter.UpdateNum, 0);
            Assert.AreEqual(counter.UpdateRight, 3);
            Assert.AreEqual(counter.UpdateLeft, 3);
            //Assert.AreEqual(agent.Belief, agent.PriorBelief);

            //Assert.IsTrue(Math.Abs(agent.Belief - agent.PriorBelief) < 0.00001);
        }
        public virtual bool OpinionFormed(Candidate can, BlackWhiteSubject? Opinion, UpdateCounter counter)
        {
            //ImportanceLevelに依存

                //3つの条件の論理式

                //意見を決められたか
                bool determined = Opinion != null;

                //現在のより大きいか?
                bool bigger = can.ImportanceLevel >= ImportanceLevel;

                //この候補にとって十分な意見が来たか?
            /*  bool enoughUpd = counter.UpdateNum  > 0 ? //この場合わけをすべきか?
                         counter.UpdateRight >= can.JumpNumRight : //正だったらrightと比べる
                         counter.UpdateLeft  >= can.JumpNumLeft; //負だったらleftと比べる */

                bool enoughUpd =    counter.UpdateRight >= can.JumpNumRight 
                                 || counter.UpdateLeft  >= can.JumpNumLeft;//一番近いσを,超えられるか

                //意見を決められていて、候補の方が大きいか、 もしくは、十分な意見が来たか。
                return (determined && bigger) || enoughUpd;
        }
        public virtual void EstimateAwarenessRate(BlackWhiteSubject? Opinion, UpdateCounter counter){

            foreach (var can in Candidates)
            {
                //この候補は意見形成できるか?
                bool formed = OpinionFormed(can,Opinion,counter);
                //↑can.EstimateAwarenessRateに入れてしまってもいいが入れられない.結構依存が大きい OpinionFormedはImportaceLevelを使う

                //推定値を更新 //意見が更新できたか
                can.EstimateAwarenessRate(formed);

            }

            OnEstimationChanged(new EstimationEventArgs(Candidates));
        }