zoukankan      html  css  js  c++  java
  • 第六次作业--结对编程第二次

    第六次作业--结对编程第二次

    成员: 504 非易 539 峻雄


    队友博客:http://www.cnblogs.com/Typhon/p/7669082.html


    Git:https://github.com/MeKChen/Software-Engineering/tree/master/DepStuMatch


    设计说明:

    接口设计

    //对输入文件的各种数据的解析
    void parseDepno(Json::Value& root, int i)
    {
    	string department_no = root["departments"][i]["department_no"].asString();
    	dept[i].dept_no = department_no;
    	dept[i].choose = 0;
    }
    
    void parseLimit(Json::Value& root, int i)
    {
    	int deplimit = root["departments"][i]["member_limit"].asInt();
    	dept[i].maxnum = deplimit;
    	dept[i].passnum = 0;
    }
    
    void parseDtags(Json::Value& root, int i)
    {
    	Json::Value dtags = root["departments"][i]["tags"];
    	int sizeofdtags = dtags.size();
    	for (int j = 0; j < sizeofdtags; j++)
    	{
    		string str = dtags[j].asString();
    		dept[i].tags.push_back(str);
    	}
    }
    
    void parseStuno(Json::Value& root, int i)
    {
    	string stu_no = root["students"][i]["student_no"].asString();
    	stu[i].stu_no = stu_no;
    	stu[i].bechoosen = 0;
    }
    
    void parseGpa(Json::Value& root, int i)
    {
    	double gpa = root["students"][i]["gpa"].asDouble();
    	stu[i].gpa = gpa;
    }
    
    void parseStags(Json::Value& root, int i)
    {
    	Json::Value stags = root["students"][i]["tags"];
    	int sizeofstags = stags.size();
    	for (int j = 0; j < sizeofstags; j++)
    	{
    		string str = stags[j].asString();
    		stu[i].tags.push_back(str);
    	}
    }
    
    void parseStuDept(Json::Value& root, int i)
    {
    	Json::Value adep = root["students"][i]["available_dep"];
    	int sizeofadep = adep.size();
    	for (int j = 0; j < sizeofadep; j++)
    	{
    		string str = adep[j].asString();
    		stu[i].dept_no.push_back(str);
    	}
    }
    

    内部实现设计


    匹配算法设计
    首先根据学生的的志愿情况(第几志愿),绩点,兴趣与部门标签等的符合情况部门对其有一个满意度打分,然后进行匹配,一个部门一个部门进行选择,倘若人满了则根据评分决定是否替换,以此类推。


    关键代码

    //部门对学生打分
    double score(Student stu, Dept dept, int pos)
    {
    	double points = 0;
    	points = points + 20 - (5 * pos);
    	points = points + stu.gpa * 5;
    	int tag = tagsnum(stu, dept);
    	points = points + 6 * (tag > 5 ? 5 : tag);
    	return points;
    }
    
    //匹配算法
    bool cmp(Student a, Student b)
    {
    	return a.stupoint > b.stupoint;
    }
    
    void matching(int ssize, int dsize)
    {
    	for (int t = 0; t < dsize; t++)
    	{
    		int total = 0;
    		for (int i = 0; i < ssize; i++)
    		{
    			for (int k = 0; k < stu[i].dept_no.size(); k++)
    				if (deptnum(stu[i].dept_no[k], dsize) == t && stu[i].flag == 0)
    				{
    					list[total].stu_index = i;
    					list[total].point = stu[i].stupoint;
    					total++;
    				}
    		}
    		sort(list, list + total);
    		for (int i = 0; i < dept[t].maxnum && i < total; i++)
    		{
    			int stu_index = list[i].stu_index;
    			v.push_back(pii(dept[t].dept_no, stu[stu_index].stu_no));
    			dept[t].choose = 1;
    			stu[stu_index].bechoosen = 1;
    		}
    	}
    }
    

    输入数据生成结果

    测试运行结果

    • 输出采用的是部门学生一对一的形式
    • 测试200位同学,20个部门的情况
    • 测试500位同学,30个部门的情况
    • 测试1000位同学,50个部门的情况
    • 测试5000位同学,100个部门的情况

    性能分析


    遇到的问题:

    • 卡了最久的还是匹配算法
    • 采用的方法是设置一个满意度得分,即每个学生对其所选的部门的一个评分,将选择第i个部门的学生以得分排列,选择前n个进入此部门,再考虑第i+1个部门。
    • 编码过程中遇到了问题,通过询问舍友的方式解决,主要还是对结构体中vector的应用不太理解
    • 编码能力不足,要不断提高

    对队友的评价:

    • 队友主要负责了博客的完成,在匹配算法上也给到了不错的建议

    PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟)
    Planning 计划 20 25
    Estimate 估计任务时间 30 30
    Development 开发 - -
    Analysis 需求分析 100 120
    Design 生成设计文档 - -
    Design Review 设计复审 - -
    Coding Standard 代码规范 45 60
    Design 具体设计 - -
    Coding 具体编码 120 160
    Code Review 代码复审 - -
    Test 测试 60 80
    Reporting 报告 45 60
    Test Repor 测试报告 - -
    Size Measurement 计算工作量 20 30
    Postmortem & Process Improvement Plan 事后总结, 并提出过程改进计划 25 30
    合计 465 595
  • 相关阅读:
    POJ 3252 Round Numbers
    HDU 1024 Max Sum Plus
    HDU 1024 Max Sum Plus Plus
    HDU 1698 Just a Hook
    HDU 1049 Climbing Worm
    HDU 3386 Reversi
    树状数组总结
    HDU 1556 Color the ball
    树形数组
    HDU 1188 敌兵布阵
  • 原文地址:https://www.cnblogs.com/kurisu/p/7673951.html
Copyright © 2011-2022 走看看