public void SetSubjectManager(SubjectManager subject_mgr) { this.MySubjectManager = subject_mgr; //受け取ったサブジェクトマネージャーをOSMにセット this.MyEnvManager = subject_mgr.OSM_Env; //OSMのEnvManagerに環境をセット this.MyEnvManager.AddEnvironment(this.MyAgentNetwork); //MyEnvManagerのEnvironmentAgentにエージェントネットワークをセット return; }
public RecordRound(int cur_round, List <Agent> agents, SubjectManager subject_manager) { this.Round = cur_round; this.MySubjectManager = subject_manager; this.AgentReceiveOpinionsInRound = new Dictionary <Agent, Vector <double> >(); //エージェントと受け取った意見の組 this.ReceiveOpinionsInRound = new Dictionary <Agent, Dictionary <Agent, Vector <double> > >(); //エージェントと上記の組の組 this.CorrectSizes = new List <int>(); this.IncorrectSizes = new List <int>(); this.UndeterSizes = new List <int>(); this.StepMessageSizes = new List <int>(); this.ActiveSensorSizes = new List <int>(); this.ActiveAgentSizes = new List <int>(); this.DeterminedSensorSizes = new List <int>(); this.SensorSizes = new List <int>(); this.CorrectSensorSizeRates = new List <double>(); this.NetworkSizes = new List <int>(); this.FinalSteps = new List <int>(); this.AverageWeight = new List <double>(); this.VarWeight = new List <double>(); this.AllOpinionSizes = new Dictionary <OpinionSubject, Dictionary <int, List <int> > >(); this.SimpsonsDs = new List <double>(); this.BetterSimpsonsDs = new List <double>(); this.CommunityList = new List <List <int> >(); this.BadCommunityList = new List <int>(); this.BadCommuintyCorrectSizes = new List <int>(); this.BadCommunityIncorrectSizes = new List <int>(); this.BadCommunityUndeterSizes = new List <int>(); this.NormalCommuintyCorrectSizes = new List <int>(); this.NormalCommunityIncorrectSizes = new List <int>(); this.NormalCommunityUndeterSizes = new List <int>(); foreach (var receive_agent in agents) //各ノードについて { var undeter_op = receive_agent.InitOpinion.Clone(); //意見をコピー undeter_op.Clear(); //意見を初期化(未形成状態) this.AgentReceiveOpinionsInRound.Add(receive_agent, undeter_op); //エージェントと初期意見の組を追加 var send_rec_op_in_round = new Dictionary <Agent, Vector <double> >(); //そのラウンド内のエージェントと送信_受信意見の組 foreach (var send_agent in receive_agent.GetNeighbors()) //receive_agentとリンクがつながっているエージェントを取得 { send_rec_op_in_round.Add(send_agent, undeter_op); //意見の送信相手と意見の値の組を追加 } if (receive_agent.IsSensor) { send_rec_op_in_round.Add(this.MySubjectManager.OSM_Env.EnvironmentAgent, undeter_op); //ノードがセンサなら.環境とセンサの組も追加 } this.ReceiveOpinionsInRound.Add(receive_agent, send_rec_op_in_round); //ノードとそのノードの意見送信の記録の組を追加 } foreach (var subject in this.MySubjectManager.Subjects) { var dim_dic = new Dictionary <int, List <int> >(); foreach (var dim in Enumerable.Range(0, subject.SubjectDimSize)) //0番から(意見数-1)番 { dim_dic.Add(dim, new List <int>()); } this.AllOpinionSizes.Add(subject, dim_dic); } }
public SubjectManager Generate(OpinionSubject opinion_subject, double dist_weight, int correct_dim, double sensor_weight, EnvDistributionEnum env_dis_mode, int malicious_dim = 0, double malicious_dist_weight = 0.0) { CustomDistribution env_dist = null; CustomDistribution env_malicious_dist = null; switch (env_dis_mode) { case EnvDistributionEnum.Turara: env_dist = new Turara_DistGenerator(opinion_subject.SubjectDimSize, dist_weight, correct_dim).Generate(); //maxとotherを計算して返す env_malicious_dist = new Turara_DistGenerator(opinion_subject.SubjectDimSize, malicious_dist_weight, malicious_dim).Generate(); //同上 break; case EnvDistributionEnum.Exponential: env_dist = new Exponential_DistGenerator(opinion_subject.SubjectDimSize, dist_weight, correct_dim).Generate(); env_malicious_dist = new Exponential_DistGenerator(opinion_subject.SubjectDimSize, malicious_dist_weight, malicious_dim).Generate(); break; case EnvDistributionEnum.Shitei: env_dist = new Shitei_DistGenerator(opinion_subject.SubjectDimSize, dist_weight, correct_dim).Generate(); env_malicious_dist = new Shitei_DistGenerator(opinion_subject.SubjectDimSize, malicious_dist_weight, malicious_dim).Generate(); break; } Debug.Assert(env_dist != null); //計算できてなかったらエラー Debug.Assert(env_malicious_dist != null); var subject_tv = new OpinionSubject("good_tv", 3); var subject_test = new OpinionSubject("test", opinion_subject.SubjectDimSize); var subject_company = new OpinionSubject("good_company", 2); double[] conv_array = { 1, 0, 0, 1, 1, 0 }; var conv_matrix = Matrix <double> .Build.DenseOfColumnMajor(2, 3, conv_array); //2*3の形にリシェイプ var osm_env = new OpinionEnvironment() .SetSubject(subject_test) .SetCorrectDim(correct_dim) //正しい次元 .SetMaliciousDim(malicious_dim) //間違った次元 .SetSensorWeight(sensor_weight) //センサウェイト .SetCustomDistribution(env_dist) .SetMaliciousCustomDistribution(env_malicious_dist); var subject_manager = new SubjectManager() //サブジェクトマネージャー生成 .AddSubject(subject_test) .RegistConversionMatrix(subject_tv, subject_company, conv_matrix) //オピニオンにサブジェクトマネージャーを登録.サブジェクトマネージャーに意見交換クラスとしてこれらの情報を登録 .SetEnvironment(osm_env); //環境をセット return(subject_manager); }
public AgentNetwork SetSubjectManager(SubjectManager subject_manager) { this.MySubjectManager = subject_manager; return(this); }
public void SetSubjectManager(SubjectManager subject_manager) { this.MySubjectManager = subject_manager; }