班級:軟件工程1916|Wgit
做業:團隊Github實戰訓練github
團隊名稱:SkyReach正則表達式
Github地址:Github地址算法
隊員學號 | 隊員姓名 | 這次活動任務 | 貢獻比例 |
---|---|---|---|
221600106 | 陳鴻 | 資料查詢,代碼審查 | 4% |
221600107 | 陳家豪 | 安排任務,撰寫博客,抽獎功能編碼 | 12% |
221600110 | 公孫駿傑 | 資料查詢,代碼審查 | 4% |
221600117 | 黃盛遠 | 文件數據格式化輸入,數據接口設計 | 26% |
221600118 | 李鴻斌 | 抽獎算法設計,抽獎功能編碼 | 23% |
221600120 | 李子琪 | UI設計與編碼 | 20% |
221600122 | 史雲天 | 文件數據格式化輸入,數據接口設計 | 11% |
本算法具備如下模式:編程
不過濾模式:剔除系統、助教、老師,全部參與抽獎的發言,都歸入開獎範圍。api
普通模式:每一個帳號只佔有一條有效抽獎信息。數組
深度模式數據結構
在普通模式的基礎上,爲了使發言更有意義,提升用戶活躍度:dom
隨機抽獎的算法:函數
咱們的抽獎算法基於LCG算法,LCG(linear congruential generator)線性同餘算法,是一個古老的產生隨機數的算法。
本算法有如下優勢:
本算法基於的LCG算法由如下參數組成:
參數 | m | a | c | X |
---|---|---|---|---|
性質 | 模數 | 乘數 | 加數 | 隨機數 |
做用 | 取模 | 移位 | 偏移 | 做爲結果 |
LCG算法是以下的一個遞推公式,每下一個隨機數是當前隨機數向左移動 log2 a 位,加上一個 c,最後對 m 取餘,使隨機數限制在 0 ~ m-1 內
從該式能夠看出,該算法因爲構成簡單,具備如下優勢:
代碼具體實現
public class Random { //LCG算法的實現 public final AtomicLong seed=new AtomicLong(); public final static long C = 1; public final static long A = 48271; public final static long M = (1L << 31) - 1; public Random(int seed){ this.seed.set(seed); } public Random(){ this.seed.set(System.nanoTime()); } public long nextLong(){ seed.set(System.nanoTime()); return (A *seed.longValue() + C) % M; } public int nextInt(int number){ return new Long( (A * System.nanoTime()/100+ C) % number).intValue(); } public int[] getLucky(int num){ Map<Integer,Integer> map=new HashMap<Integer,Integer>(); for(int i=0;i<100000;i++){ int ran=new Random().nextInt(num); if(map.containsKey(ran)){ map.put(ran, map.get(ran)+1); }else{ map.put(ran, 1); } } int []luck = new int[num]; Iterator iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); int key = (Integer)entry.getKey(); int value = map.get(key); luck[key]=value; } return luck; }
經過哈希表儲存從文本讀入的數據,對其進行有效發言斷定,以及有效發言數量的計算,從而對用戶中獎概率的改變。如下爲代碼實現:
public class Way { public static Way create(){ Way way=new Way(); return way; } //不過濾抽獎名單 public List<String> none(List<String> qqs,int num){ HashMap<String,Integer> map=new HashMap<String,Integer>(); int luck[]=new Random().getLucky(qqs.size()); for(int i=0;i<qqs.size();i++){ map.put(qqs.get(i), luck[i]); } List<Map.Entry<String,Integer>> list = new ArrayList<Map.Entry<String,Integer>>(map.entrySet()); Collections.sort(list,new Comparator<Map.Entry<String,Integer>>() { public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) { return -o1.getValue().compareTo(o2.getValue()); } }); list=list.subList(0, num); List<String> thenone=new ArrayList<String>(); for(Map.Entry<String,Integer> m:list){ thenone.add(m.getKey()); } return thenone; } //普經過濾抽獎名單 public List<String> common(HashMap<String, List<Record>> msgs,ProcessQQLog user,int num){ msgs=clearAssit(msgs,user); List<String> qqs=new ArrayList<>(msgs.keySet()); qqs=none(qqs,num); return qqs; } //深度過濾抽獎名單 public List<String> deep(HashMap<String, List<Record>> msgs,ProcessQQLog user,int num){ msgs=clearAssit(msgs,user); return none(msgRate(msgs,num),num); } //將助教及老師從開獎名單中刪除 public HashMap<String, List<Record>> clearAssit(HashMap<String, List<Record>> msgs,ProcessQQLog user){ Iterator iter = msgs.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String qq = (String)entry.getKey(); String name=user.getQQName(qq); if(name.contains("助教")||name.contains("老師")||qq.equals("10000")||qq.equals("1000008")){ iter.remove(); msgs.remove(qq); } } return msgs; } //對有效發言次數進行排序 有效發言次數越多中獎概率越大 public List<String> msgRate(HashMap<String, List<Record>> msgs,int num){ if(num<20) num*=2; HashMap<String,Integer> qqN=new HashMap<String,Integer>(); Iterator iter = msgs.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String qq = (String)entry.getKey(); List<Record> list = (List<Record>)entry.getValue(); qqN.put(qq, list.size()); } List<Map.Entry<String,Integer>> list = new ArrayList<Map.Entry<String,Integer>>(qqN.entrySet()); Collections.sort(list,new Comparator<Map.Entry<String,Integer>>() { public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) { return -o1.getValue().compareTo(o2.getValue()); } }); list=list.subList(0, num); List<String> themsg=new ArrayList<String>(); for(Map.Entry<String,Integer> m:list){ themsg.add(m.getKey()); } return themsg; } }
經過哈希表儲存從文本讀入的數據,對其進行有效發言斷定,以及有效發言數量的計算,從而對用戶中獎概率的改變。
組員 李子琪
困難
解決
組員 李鴻斌
困難
解決
組員 黃盛遠
困難
解決
組員 史雲天
困難
解決
組員 公孫駿傑
困難
解決
組員 陳鴻
困難
解決
組長 陳家豪
困難
解決
陳鴻
PSP2.1 | Pesonal SoftWare Process Stages | 預估耗時(分鐘) | 實際耗時(分鐘) |
---|---|---|---|
Planning | 計劃 | 10 | 12 |
Estimate | 估計這個任務須要多少時間 | 120 | 140 |
Development | 開發 | 220 | 230 |
Analysis | 需求分析(包括學習新技術) | 60 | 70 |
Design Spec | 生成設計文檔 | 30 | 40 |
Design Review | 設計複審 | 20 | 30 |
Coding Standard | 代碼規範(爲目前的開發制定合適的規範) | 0 | 0 |
Design | 具體設計 | 220 | 230 |
Coding | 具體編碼 | 0 | 0 |
Code Review | 代碼複審 | 0 | 0 |
Test | 測試(自我測試,修改代碼,提交修改) | 40 | 50 |
Reporting | 報告 | 30 | 40 |
Test Report | 測試報告 | 10 | 10 |
Size Measurement | 計算工做量 | ||
Postmortem&Process Improvement Plan | 過後總結,並提出過程改進計劃 | 30 | 30 |
合計 | 790 | 855 |
李子琪
PSP2.1 | Personal Software Process Stages | 預估耗時(分鐘) | 實際耗時(分鐘) |
---|---|---|---|
Planning | 計劃 | ||
• Estimate | • 估計這個任務須要多少時間 | ||
Development | 開發 | ||
• Analysis | • 需求分析 (包括學習新技術) | 10 | 20 |
• Design Spec | • 生成設計文檔 | 10 | 20 |
• Design Review | • 設計複審 | 20 | 25 |
• Coding Standard | • 代碼規範 (爲目前的開發制定合適的規範) | ||
• Design | • 具體設計 | 15 | 15 |
• Coding | • 具體編碼 | 100 | 120 |
• Code Review | • 代碼複審 | 10 | 15 |
• Test | • 測試(自我測試,修改代碼,提交修改) | 20 | 40 |
Reporting | 報告 | ||
• Test Report | • 測試報告 | 10 | 15 |
• Size Measurement | • 計算工做量 | 20 | 20 |
• Postmortem & Process Improvement Plan | • 過後總結, 並提出過程改進計劃 | 10 | 10 |
合計 | 225 | 300 |
李鴻斌
PSP2.1 | Personal Software Process Stages | 預估耗時(分鐘) | 實際耗時(分鐘) |
---|---|---|---|
Planning | 計劃 | ||
• Estimate | • 估計這個任務須要多少時間 | 180 | 190 |
Development | 開發 | ||
• Analysis | • 需求分析 (包括學習新技術) | 30 | 40 |
• Design Spec | • 生成設計文檔 | 10 | 10 |
• Design Review | • 設計複審 | 15 | 10 |
• Coding Standard | • 代碼規範 (爲目前的開發制定合適的規範) | 25 | 20 |
• Design | • 具體設計 | 15 | 10 |
• Coding | • 具體編碼 | 30 | 35 |
• Code Review | • 代碼複審 | 15 | 20 |
• Test | • 測試(自我測試,修改代碼,提交修改) | 30 | 25 |
Reporting | 報告 | ||
• Test Report | • 測試報告 | 20 | 20 |
• Size Measurement | • 計算工做量 | 10 | 10 |
• Postmortem & Process Improvement Plan | • 過後總結, 並提出過程改進計劃 | 20 | 30 |
合計 | 230 | 230 |
公孫駿傑
PSP2.1 | Personal Software Process Stages | 預估耗時(分鐘) | 實際耗時(分鐘) |
---|---|---|---|
Planning | 計劃 | ||
• Estimate | • 估計這個任務須要多少時間 | 10 | 10 |
Development | 開發 | ||
• Analysis | • 需求分析 (包括學習新技術) | 50 | 70 |
• Design Spec | • 生成設計文檔 | 30 | 50 |
• Design Review | • 設計複審 | 10 | 10 |
• Coding Standard | • 代碼規範 (爲目前的開發制定合適的規範) | 20 | 20 |
• Design | • 具體設計 | 60 | 60 |
• Coding | • 具體編碼 | 150 | 180 |
• Code Review | • 代碼複審 | 30 | 30 |
• Test | • 測試(自我測試,修改代碼,提交修改) | 20 | 20 |
Reporting | 報告 | ||
• Test Report | • 測試報告 | 20 | 20 |
• Size Measurement | • 計算工做量 | 10 | 10 |
• Postmortem & Process Improvement Plan | • 過後總結, 並提出過程改進計劃 | 40 | 40 |
合計 | 560 | 630 |
史雲天
PSP2.1 | Personal Software Process Stages | 預估耗時(分鐘) | 實際耗時(分鐘) |
---|---|---|---|
Planning | 計劃 | 20 | 10 |
• Estimate | • 估計這個任務須要多少時間 | 10 | 5 |
Development | 開發 | ||
• Analysis | • 需求分析 (包括學習新技術) | 60 | 50 |
• Design Spec | • 生成設計文檔 | 30 | 40 |
• Design Review | • 設計複審 | 20 | 10 |
• Coding Standard | • 代碼規範 (爲目前的開發制定合適的規範) | 40 | 30 |
• Design | • 具體設計 | 30 | 20 |
• Coding | • 具體編碼 | 180 | 240 |
• Code Review | • 代碼複審 | 20 | 30 |
• Test | • 測試(自我測試,修改代碼,提交修改) | 60 | 60 |
Reporting | 報告 | ||
• Test Report | • 測試報告 | 30 | 40 |
• Size Measurement | • 計算工做量 | 10 | 5 |
• Postmortem & Process Improvement Plan | • 過後總結, 並提出過程改進計劃 | 30 | 25 |
合計 | 540 | 565 |
黃盛遠
PSP2.1 | Personal Software Process Stages | 預估耗時(分鐘) |
---|---|---|
Planning | 計劃 | |
• Estimate | • 估計這個任務須要多少時間 | 180 |
Development | 開發 | |
• Analysis | • 需求分析 (包括學習新技術) | 10 |
• Design Spec | • 生成設計文檔 | 10 |
• Design Review | • 設計複審 | 15 |
• Coding Standard | • 代碼規範 (爲目前的開發制定合適的規範) | 5 |
• Design | • 具體設計 | 15 |
• Coding | • 具體編碼 | 60 |
• Code Review | • 代碼複審 | 15 |
• Test | • 測試(自我測試,修改代碼,提交修改) | 30 |
Reporting | 報告 | |
• Test Report | • 測試報告 | 20 |
• Size Measurement | • 計算工做量 | 10 |
• Postmortem & Process Improvement Plan | • 過後總結, 並提出過程改進計劃 | 20 |
合計 | 195 |
陳家豪
PSP2.1 | Personal Software Process Stages | 預估耗時(分鐘) | 實際耗時(分鐘) |
---|---|---|---|
Planning | 計劃 | 20 | 10 |
• Estimate | • 估計這個任務須要多少時間 | 10 | 5 |
Development | 開發 | ||
• Analysis | • 需求分析 (包括學習新技術) | 60 | 30 |
• Design Spec | • 生成設計文檔 | 30 | 40 |
• Design Review | • 設計複審 | 20 | 10 |
• Coding Standard | • 代碼規範 (爲目前的開發制定合適的規範) | 40 | 30 |
• Design | • 具體設計 | 30 | 20 |
• Coding | • 具體編碼 | 180 | 200 |
• Code Review | • 代碼複審 | 20 | 30 |
• Test | • 測試(自我測試,修改代碼,提交修改) | 60 | 60 |
Reporting | 報告 | ||
• Test Report | • 測試報告 | 30 | 40 |
• Size Measurement | • 計算工做量 | 10 | 5 |
• Postmortem & Process Improvement Plan | • 過後總結, 並提出過程改進計劃 | 30 | 25 |
合計 | 540 | 505 |
姓名 | 新增代碼(行) | 累計代碼(行) | 本週學習耗時(小時) | 累計學習耗時(小時) | 重要成長 |
---|---|---|---|---|---|
陳家豪 | 100 | 100 | 10 | 10 | 複習JAVA,學習LCG算法 |
李子琪 | 400 | 400 | 12 | 12 | 複習JAVAUI設計 |
黃盛遠 | 250 | 250 | 15 | 15 | 複習JAVA,學習使用哈希表 |
史雲天 | 100 | 100 | 8 | 8 | 複習JAVA,學習使用哈希表 |
李鴻斌 | 170 | 170 | 10 | 10 | 複習JAVA,學習LCG算法 |
公孫駿傑 | 50 | 50 | 7 | 7 | 複習JAVA |
陳鴻 | 50 | 50 | 7 | 7 | 複習JAVA |