群體決策應用

商圈分析模型

程式碼

using System; using System.Collections.Generic; using GroupDecisionEngine; using GroupDecisionModel; namespace GroupDecisionModel { class MainClass:DecisionModel2Level { public MainClass (int decisionScale) { this.decisionScale = decisionScale + 1; } // 給予決策方案亂數偏好 public void SetSolutionList () { List<Solution> SolutionList = new List<Solution> (); Random rnd = new Random (); SolutionList.Add (new Solution { Name = "甲商圈", Value = rnd.Next (1, this.decisionScale), Weight = 0.0d }); SolutionList.Add (new Solution { Name = "乙商圈", Value = rnd.Next (1, this.decisionScale), Weight = 0.0d }); SolutionList.Add (new Solution { Name = "丙商圈", Value = rnd.Next (1, this.decisionScale), Weight = 0.0d }); // 傳入給決策引擎 this.SetSolutionList (SolutionList); } // 給予參與人亂數權重 public void SetParticipantList () { List<Participant> ParticipantList = new List<Participant> (); Random rnd = new Random (); ParticipantList.Add (new Participant { Name = "張三豐", Value = rnd.Next (1, this.decisionScale), Weight = 0.0d }); ParticipantList.Add (new Participant { Name = "張無忌", Value = rnd.Next (1, this.decisionScale), Weight = 0.0d }); ParticipantList.Add (new Participant { Name = "殷素素", Value = rnd.Next (1, this.decisionScale), Weight = 0.0d }); ParticipantList.Add (new Participant { Name = "周芷若", Value = rnd.Next (1, this.decisionScale), Weight = 0.0d }); // 傳入給決策引擎 this.SetParticipantList (ParticipantList); } // 設定決策因子模型 public void SetFactorList () { List<Factor> FactorList = new List<Factor> (); // 首階決策因子 FactorList.Add (new Factor { LevelID = "1", Name = "環境" }); FactorList.Add (new Factor { LevelID = "2", Name = "經營" }); FactorList.Add (new Factor { LevelID = "3", Name = "消費" }); // 末階決策因子一 FactorList.Add (new Factor { LevelID = "1.1", Name = "交通便利" }); FactorList.Add (new Factor { LevelID = "1.2", Name = "商圈規模" }); FactorList.Add (new Factor { LevelID = "1.3", Name = "磁吸企業" }); FactorList.Add (new Factor { LevelID = "1.4", Name = "商圈適配" }); // 末階決策因子二 FactorList.Add (new Factor { LevelID = "2.1", Name = "潛在通路" }); FactorList.Add (new Factor { LevelID = "2.2", Name = "類似商品" }); FactorList.Add (new Factor { LevelID = "2.3", Name = "服務能力" }); FactorList.Add (new Factor { LevelID = "2.4", Name = "商品服務適配" }); // 末階決策因子三 FactorList.Add (new Factor { LevelID = "3.1", Name = "消費能力" }); FactorList.Add (new Factor { LevelID = "3.2", Name = "生活文化層次" }); FactorList.Add (new Factor { LevelID = "3.3", Name = "消費者屬性差異" }); FactorList.Add (new Factor { LevelID = "3.4", Name = "消費者適配" }); this.SetFactorList (FactorList); } // 給予參加人各階層亂數權重 protected override void SetFactorVoteByParticipant (String ParticipantName) { Random rnd = null; rnd = new Random (); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "1", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "2", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "3", rnd.Next (1, this.decisionScale)); rnd = new Random (); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "1.1", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "1.2", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "1.3", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "1.4", rnd.Next (1, this.decisionScale)); rnd = new Random (); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "2.1", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "2.2", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "2.3", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "2.4", rnd.Next (1, this.decisionScale)); rnd = new Random (); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "3.1", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "3.2", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "3.3", rnd.Next (1, this.decisionScale)); this.TradeCircle_FactorVotes.SetFactorVoteList ( ParticipantName, "3.4", rnd.Next (1, this.decisionScale)); } // 給予參加人決策方案亂數權重 protected override void SetGroupDecisionSolutionVoteByParticipant ( String ParticipantName) { Random rnd = null; // 給予決策方案末階因子亂數權重 // 針對每一個決策方案 foreach (String solutionName in this.TradeCircle_Solutions.GetSolutionNameList()) { rnd = new Random (); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "1.1", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "1.2", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "1.3", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "1.4", rnd.Next (1, this.decisionScale)); rnd = new Random (); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "2.1", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "2.2", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "2.3", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "2.4", rnd.Next (1, this.decisionScale)); rnd = new Random (); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "3.1", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "3.2", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "3.3", rnd.Next (1, this.decisionScale)); this.TradeCircle_SolutionVotes.SetSolutionVoteList ( ParticipantName, solutionName, "3.4", rnd.Next (1, this.decisionScale)); } } public static void Main (string[] args) { // 選用權重 Likter 5 尺度 // 選用二階決策因子模型 MainClass decisionModel = new MainClass (5); decisionModel.SetSolutionList (); decisionModel.SetParticipantList (); decisionModel.SetFactorList (); decisionModel.SetGroupDecisionFactorVote (); decisionModel.SetGroupDecisionSolutionVote (); decisionModel.CalcWeight (); // 輸出決策方案結果 foreach (SolutionDecision soluionDecision in decisionModel.GetOrderedDecisionList()) { Console.WriteLine ("{0}\t{1:N2}", soluionDecision.Name, soluionDecision.Weight); } // 顯示內部資料值 String maskTask = "000000"; if (args.Length > 0) { maskTask = args [0]; } // 輸出 JSON 格式控制陣列 Boolean[] taskControl = new Boolean[] { false, false, false, false, false, false }; for (int i = 0; i < Math.Min (5, maskTask.Length); i++) { if (maskTask.Substring (i, 1).Equals ("1")) { taskControl [i] = true; } } decisionModel.Output (Console.Out, taskControl); } } }

輸出結果