Пример #1
0
        void DrawAATAgent(PaintEventArgs e, I_Agent agent, float r)
        {
            this.DrawNullAgent(e, agent, r);
            float r2      = r * 2;
            float r3      = r * 3;
            float r4      = r * 4;
            float r5      = r * 5;
            float r_outer = r3;
            var   algo    = this.MyOSM.MyAlgo as AAT_Algo;

            //目盛り作成
            if (algo.CandidateSetList != null)
            {
                var scale_list = algo.CandidateSetList[agent.NodeID].GetSelectCandidate().BeliefScaleList;

                this.MyPen        = (Pen)this.MyDrawSetting.BlackThinPen.Clone();
                this.MyPen.Width /= this.ViewScale;
                foreach (var scale in scale_list)
                {
                    e.Graphics.DrawLine(this.MyPen,
                                        r_outer / 3 * (float)Math.Cos(Math.PI * scale + Math.PI),
                                        r_outer / 3 * (float)Math.Sin(Math.PI * scale + Math.PI),
                                        r_outer / 2 * (float)Math.Cos(Math.PI * scale + Math.PI),
                                        r_outer / 2 * (float)Math.Sin(Math.PI * scale + Math.PI)
                                        );
                }
            }
        }
Пример #2
0
        public SingleCandidate(int can_index, I_Agent agent)
        {
            this.CanIndex         = can_index;
            this.CanWeight        = OpinionBeliefUpdater.GetWeightForScale(agent.InitBelief, agent.GreenSigma, agent.RedSigma, can_index);
            this.AwaCounts        = 0;
            this.AwaCurrentRounds = 0;

            this.BeliefScaleList = new List <double>();
            this.BeliefScaleList.Add(agent.InitBelief);

            var current_belief = agent.InitBelief;

            while (current_belief < agent.GreenSigma)
            {
                current_belief = OpinionBeliefUpdater.UpdateBelief(current_belief, CanWeight, InfoEnum.Green);
                this.BeliefScaleList.Add(current_belief);
            }

            current_belief = agent.InitBelief;
            while (current_belief > agent.RedSigma)
            {
                current_belief = OpinionBeliefUpdater.UpdateBelief(current_belief, CanWeight, InfoEnum.Red);
                this.BeliefScaleList.Add(current_belief);
            }
        }
Пример #3
0
        bool IsSmallerU(I_SingleCandidate other_can, I_Agent agent)
        {
            int req_u = Math.Abs(other_can.CanIndex);
            int obs_u = Math.Abs(agent.ReceiveGreenCounts - agent.ReceiveRedCounts);

            return((obs_u >= req_u) ? true : false);
        }
Пример #4
0
        bool IsEvsOpinionFormed(I_Agent agent, I_SingleCandidate select_can, I_SingleCandidate other_can)
        {
            bool evs1 = this.IsDetermined(agent) && this.IsBiggerWeight(select_can, other_can);
            bool evs2 = this.IsSmallerU(other_can, agent) && (other_can.CanWeight != select_can.CanWeight);

            return(evs1 || evs2);
        }
Пример #5
0
        bool IsEvsOpinionFormed(I_Agent agent, I_SingleCandidate select_can, I_SingleCandidate other_can, I_CandidateSet canset)
        {
            bool evs1 = this.IsChanged(agent) && this.IsBiggerWeight(select_can, other_can);
            bool evs2 = this.IsBigWeightOfReqU(other_can, agent, canset);

            return(evs1 || evs2);
        }
Пример #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            I_Agent i_Agent = db.I_Agent.Find(id);

            db.I_Agent.Remove(i_Agent);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #7
0
        public SingleSusceptCandidate(int can_index, double step_size, I_Agent agent)
        {
            this.CanIndex         = can_index;
            this.CanWeight        = Math.Abs(can_index * step_size);
            this.AwaCounts        = 0;
            this.AwaCurrentRounds = 0;

            this.BeliefScaleList = new List <double>();
        }
Пример #8
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Email")] I_Agent i_Agent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(i_Agent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(i_Agent));
 }
Пример #9
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Email")] I_Agent i_Agent)
        {
            if (ModelState.IsValid)
            {
                db.I_Agent.Add(i_Agent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(i_Agent));
        }
Пример #10
0
        public SusceptCandidateSet(I_Node node, I_Agent agent, double step_size)
        {
            this.NodeID = node.NodeID;
            this.SingleCandidateList = new List <I_SingleCandidate>();
            int max_index = Convert.ToInt32(0.5 / step_size);

            for (int can_index = 1; can_index <= max_index; can_index++)
            {
                this.SingleCandidateList.Add(new SingleSusceptCandidate(can_index, step_size, agent));
            }

            this.SetInitSelectCanIndex();
            this.SelectCanIndex = this.InitSelectCanIndex;
        }
Пример #11
0
        // GET: IAgent/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            I_Agent i_Agent = db.I_Agent.Find(id);

            if (i_Agent == null)
            {
                return(HttpNotFound());
            }
            return(View(i_Agent));
        }
Пример #12
0
        public CandidateSet(I_Node node, I_Agent agent)
        {
            this.NodeID = node.NodeID;
            this.SingleCandidateList = new List <I_SingleCandidate>();

            if (node.NeighborNodeIDList.Count == 0)
            {
                this.SingleCandidateList.Add(new SingleCandidate(1, agent));
            }

            for (int can_index = 1; can_index <= node.NeighborNodeIDList.Count; can_index++)
            {
                this.SingleCandidateList.Add(new SingleCandidate(can_index, agent));
                this.SingleCandidateList.Add(new SingleCandidate(-1 * can_index, agent));
            }
            this.SetInitSelectCanIndex();
            this.SelectCanIndex = this.InitSelectCanIndex;
        }
Пример #13
0
        bool IsBigWeightOfReqU(I_SingleCandidate other_can, I_Agent agent, I_CandidateSet canset)
        {
            int obs_u = Math.Abs(agent.ReceiveGreenCounts - agent.ReceiveRedCounts);

            if (obs_u <= 0)
            {
                obs_u = Math.Abs(canset.SingleCandidateList.OrderBy(can => can.CanWeight).Last().CanIndex);
            }

            if (obs_u > canset.SingleCandidateList.OrderBy(can => can.CanIndex).Last().CanIndex)
            {
                obs_u = Math.Abs(canset.SingleCandidateList.OrderBy(can => can.CanWeight).First().CanIndex);
            }

            double req_w   = canset.SingleCandidateList.Where(can => Math.Abs(can.CanIndex) == obs_u).Select(can => can.CanWeight).Min();
            double other_w = other_can.CanWeight;

            return((other_w >= req_w) ? true : false);
        }
Пример #14
0
        void UpdateAveAwaRates(int current_round, I_Agent agent, I_CandidateSet canset)
        {
            var select_can = canset.GetCandidate(canset.SelectCanIndex);

            foreach (var can in canset.SingleCandidateList)
            {
                var pre_counts = (current_round - 1) * can.AwaRate;

                if (this.IsEvsOpinionFormed(agent, select_can, can))
                {
                    can.AwaRate          = (pre_counts + 1) / current_round;
                    can.AwaCounts        = (int)pre_counts + 1;
                    can.AwaCurrentRounds = current_round;
                }
                else
                {
                    can.AwaRate          = (pre_counts + 0) / current_round;
                    can.AwaCounts        = (int)pre_counts + 0;
                    can.AwaCurrentRounds = current_round;
                }
            }
        }
Пример #15
0
 bool IsDetermined(I_Agent agent)
 {
     return((agent.Opinion != InfoEnum.Undeter) ? true : false);
 }
Пример #16
0
 bool IsChanged(I_Agent agent)
 {
     return((agent.Opinion != agent.InitOpinion) ? true : false);
 }
Пример #17
0
        void DrawNullAgent(PaintEventArgs e, I_Agent agent, float r)
        {
            float r2      = r * 2;
            float r3      = r * 3;
            float r4      = r * 4;
            float r5      = r * 5;
            float r_outer = r3;

            var my_opinion     = agent.Opinion;
            var my_belief      = (float)agent.Belief;
            var my_init_belief = (float)agent.InitBelief;
            var g_sigma        = (float)agent.GreenSigma;
            var r_sigma        = (float)agent.RedSigma;

            if (my_opinion == InfoEnum.Green)
            {
                this.MyDrawSetting.OpinionBrush.Color = this.MyDrawSetting.OpCorrectColor;
            }
            else if (my_opinion == InfoEnum.Red)
            {
                this.MyDrawSetting.OpinionBrush.Color = this.MyDrawSetting.OpIncorrectColor;
            }
            else if (my_opinion == InfoEnum.Undeter)
            {
                this.MyDrawSetting.OpinionBrush.Color = this.MyDrawSetting.OpUndeterColor;
            }

            //意見の円
            e.Graphics.FillEllipse(this.MyDrawSetting.OpinionBrush, -r_outer / 2, -r_outer / 2, r_outer, r_outer);

            //扇型を表示
            {
                float zeroDeg       = 180f;
                float sigmaLeftDeg  = (r_sigma * 180f + zeroDeg);
                float sigmaRightDeg = (g_sigma * 180f + zeroDeg);
                float sigmaSweepDeg = (g_sigma - r_sigma) * 180f;


                //e.Graphics.FillPie(this.MyDrawSetting.LightGrayBrush, -r_outer / 2, -r_outer / 2, r_outer, r_outer, zeroDeg, 180);
                //e.Graphics.FillPie(this.MyDrawSetting.GrayBrush, -r_outer / 2, -r_outer / 2, r_outer, r_outer, sigmaLeftDeg, sigmaSweepDeg);
                e.Graphics.FillPie(this.MyDrawSetting.OpinionBrush, -r_outer / 2, -r_outer / 2, r_outer, r_outer, sigmaLeftDeg, sigmaSweepDeg);
                e.Graphics.FillPie(this.MyDrawSetting.RedSigmaBlush, -r_outer / 2, -r_outer / 2, r_outer, r_outer, zeroDeg, r_sigma * 180f);
                e.Graphics.FillPie(this.MyDrawSetting.GreenSigmaBlush, -r_outer / 2, -r_outer / 2, r_outer, r_outer, sigmaRightDeg, r_sigma * 180f);
            }

            //外枠の円
            if (agent.IsSensor)
            {
                this.MyPen        = (Pen)MyDrawSetting.SensorPen.Clone();
                this.MyPen.Width /= this.ViewScale;
                //e.Graphics.DrawEllipse(this.MyPen, -r4 / 2, -r4 / 2, r4, r4);
                e.Graphics.DrawEllipse(this.MyPen, -r_outer / 2, -r_outer / 2, r_outer, r_outer);
            }
            else
            {
                this.MyPen        = (Pen)this.MyDrawSetting.PriorBeliefPen.Clone();
                this.MyPen.Width /= this.ViewScale;
            }

            e.Graphics.DrawEllipse(this.MyPen, -r_outer / 2, -r_outer / 2, r_outer, r_outer);

            //信念のmeter
            this.MyPen        = (Pen)this.MyDrawSetting.MeterPen.Clone();
            this.MyPen.Width /= this.ViewScale;
            e.Graphics.DrawLine(this.MyPen,
                                0,
                                0,
                                (float)0.5 * r3 * (float)Math.Cos(Math.PI * my_belief + Math.PI),
                                (float)0.5 * r3 * (float)Math.Sin(Math.PI * my_belief + Math.PI));


            //init belief
            this.MyPen        = (Pen)this.MyDrawSetting.InitMeterPen.Clone();
            this.MyPen.Width /= this.ViewScale;
            e.Graphics.DrawLine(this.MyPen,
                                (float)0.5 * r3 * (float)Math.Cos(Math.PI * my_init_belief + Math.PI),
                                (float)0.5 * r3 * (float)Math.Sin(Math.PI * my_init_belief + Math.PI),
                                (float)0.55 * r3 * (float)Math.Cos(Math.PI * my_init_belief + Math.PI),
                                (float)0.55 * r3 * (float)Math.Sin(Math.PI * my_init_belief + Math.PI)
                                );
        }