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

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

    成员: 539 峻雄 504 非易


    队友博客:http://www.cnblogs.com/kurisu/p/7673951.html


    Git:(自己的git登不上,这是队友的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++)
    	{
    		//dl(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个部门的情况

    性能分析


    遇到的问题:

    • 感觉有点迷,在想匹配算法的时候一脸懵逼
    • 后来跟大佬讨论后,本来采用的是采用满意度打分的设置,然后学生排队,部门的坑位满了之后新来的学生和最低分的人比较,高的就替换,低的话就进下一轮,后来换了种方式,在保留满意度打分的情况下采取了上面的算法
    • 但是代码能力还是需要提高,弄懂了原理具体怎么敲还是无从下手
    • 代码这一块感觉短时间内还是无法迅速进步,要慢慢来,多练习

    对队友的评价:

    • 这次的代码大部分由队友完成,紧紧抱住大腿,给大佬递茶。

    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
  • 相关阅读:
    201671010447杨露露 实验三作业互评与改进
    实验一:通读构建之法之后提出的相关问题
    实验十四 团队项目评审&课程学习总结
    201671010452 实验四附加实验 项目互评
    201671010452 周海瑞 《英文文本统计分析》结对项目报告
    201671010452周海瑞 词频统计软件项目报告
    201671010452周海瑞 实验三作业互评与改进报告
    读《构建之法》后的疑惑
    《JavaScript DOM 编程艺术》(第二版)读书笔记(四)
    《JavaScript DOM 编程艺术》(第二版)读书笔记(二)
  • 原文地址:https://www.cnblogs.com/Typhon/p/7669082.html
Copyright © 2011-2022 走看看