- 无标题文档
查看论文信息

中文题名:

 面向MicroPython开源硬件的程序自动测评系统研究    

姓名:

 曾子龙    

保密级别:

 公开    

论文语种:

 中文    

学科代码:

 081202    

学科专业:

 计算机软件与理论    

学生类型:

 硕士    

学位:

 工学硕士    

学位类型:

 学术学位    

学位年度:

 2019    

校区:

 北京校区培养    

学院:

 教育学部    

研究方向:

 图形化编程与程序自动测评    

第一导师姓名:

 傅骞    

第一导师单位:

 北京师范大学教育学部    

提交日期:

 2019-06-25    

答辩日期:

 2019-06-05    

外文题名:

 Research on Automatic Program Evaluation System for Open Source Hardware in MicroPython Environment    

中文关键词:

 程序自动测评 ; MicroPython 开源硬件 ; 模拟器 ; 有限状态机 ; 程序语义分析    

中文摘要:
随着编程教育的推广,面向MicroPython开源硬件的编程课程逐渐在中小学普及开展。MicroPython开源硬件指的是一类能运行Python的开源单片机板卡。面向MicroPython开源硬件的编程指的是通过编写程序来控制MicroPython开源单片机板卡,以观察程序的效果。在师资有限的情况下,老师评判大量的程序作业变得愈发困难。为了大规模地开展面向MicroPython开源硬件的编程教育,程序自动测评系统变得愈发重要。 现有主流的程序自动测评系统,基本上是以程序动态分析为基础进行设计和开发的。程序动态分析方法是比较待测试程序和正确答案在相同输入的情况下,输出是否相同。面向MicroPython开源硬件的程序需要上传到对应的板卡上才能观察结果,并且结果有着很强的时序特征,程序的效果不能只关注最后的运行结果,而需要关注整个运行过程的状态。由于计算机无法获取、表征这类程序运行的状态,故无法直接利用现有的程序动态分析方法对其进行测评。因此,本文提出了一种新的程序动态分析方法——基于模拟器有限状态机相似度的程序自动测评方法,同时提出了一种程序静态分析方法——基于语义分析的程序自动测评方法,综合两种方法实现了面向MicroPython开源硬件的程序自动测评系统。文章主要包括以下研究内容: (1)研究并实现了一种能够表征程序运行时有限状态机的MicroPython硬件模拟器。模拟器仿真了MicroPython硬件的输入、输出、显示器、执行器等功能。为了同时支持仿真和测评,提出一种基于抽象语法树的源程序改写方法,实现了仿真与测评两套运行时无缝切换。同时,实现了一套实时响应外部输入框架用于保证程序测评的完备性。针对程序运行状态无法表示的问题,提出一种以功能粒度表征程序运行时有限状态机的方法。 (2)从程序动态分析的角度提出一种基于模拟器有限状态机相似度的程序自动测评方法。关联程序得分与模拟器有限状态机相似度,将计算单维时间序列相似度的动态时间弯曲算法(DTW)扩展至多维时间序列,并融合字符串最短编辑距离,有效地计算了模拟器有限状态机相似度。同时,为了解决同一程序多次执行所耗时间有所不同导致有限状态机不唯一的问题,提出了一种基于自定义时钟的方法来替代系统时钟,保证有限状态机唯一性。实验从程序自动测评系统的两个运用场景出发,验证了该测评方法在判断程序对错和根据程序优劣预估程序得分上的有效性。 (3)从程序静态分析的角度提出一种基于语义分析的程序自动测评方法。细化并抽取了基于MicroPython程序语法的基础特征、语句特征、数据依赖特征和逻辑控制结构特征,同时,提出了一种基于抽象语法树编辑距离的特征,并通过指定不同节点的操作代价函数,优化了面向抽象语法树的、计算树编辑距离的zhang-shasha算法。将上述抽取的特征用于三种模型的训练,比较不同模型的效果差异,选取最优模型。实验从程序自动测评系统的两个运用场景出发,验证了该测评方法在判断程序对错和根据程序优劣预估程序得分上的有效性,并将该方法与基于模拟器有限状态机相似度的程序自动测评方法进行对比。 (4)设计和实现面向MicroPython开源硬件的程序自动测评系统。系统从实际需求出发,在练习场景下,使用基于模拟器有限状态机相似度的程序自动测评方法来判断程序对错;在考试场景下,使用基于语义分析的程序自动测评方法来根据程序优劣预估得分。系统采用B/S架构模式,通过将模拟器架设在前端,减轻了服务端压力。系统集在线编程、硬件仿真、在线出题、实时测评为一体,极大地降低了人工评分的成本。 本文以面向MicroPython开源硬件的程序自动测评方法为核心,在理论研究和系统集成两个方面做了相应的探索,一方面综合使用程序动态分析和程序静态分析两种测评方法为面向硬件的程序自动测评提供一定的借鉴,另一方面也为自动测评系统提供一种新颖的架构实现方式。
外文摘要:
With the development of programming education, more and more programming courses adopt MicroPython open source hardware in K-12 area. MicroPython open source hardware includes several open-sourced single-chip microcomputers (SCM) that support MicroPython compiler. And programming oriented to MicroPython open source hardware is to control the open-sourced SCM and accessory hardware by programming. Because of the lack of teacher, it's too difficult to evaluate the correctness of many programs. In order to populate MicroPython open source hardware in K-12 programming courses, it's of vital importance to develop an automatic program evaluation system for it. The existing automatic program evaluation systems are mostly based on program dynamic analysis, which compares the output of correct program with the program needed to evaluate. But the output of MicroPython program only can be seen when it uploads to the hardware. What's more, the output of the program has strong sequential. So existing automatic program evaluation systems cannot do anything to help. To solve this problem, a new program dynamic analysis method is proposed, which is based on the similarity of simulator's finite-state machine. At the same time, a program static analysis method based on semantic analysis is proposed. Two methods are synthesized to implement the program automatic evaluation system for MicroPython open source hardware. This thesis mainly includes the following contents: (1) This thesis designs and develops a MicroPython hardware simulator, which can represent the internal sequential state. The simulator can simulate functions including input, output, display and actuator of the hardware. For supporting to simulate and evaluate simultaneously, this thesis proposes a source program re-writing method base on abstract syntax tree (AST). Then, to ensure the completeness of evaluation, this thesis develops a real-time responsing framework for external input. Finally, in order to evaluate program automatically, this thesis proposes a method to characterize simulator's finite-state machine (FSM) with functional granularity. (2) From the perspective of program dynamic analysis, this thesis proposes an automatic evaluation algorithm based on the similarity of simulator's finite-state machine. The algorithm evaluates programs by comparing the similarity of simulator's finite-state machine between the program needed to evaluate and the correct program. In order to compute similarity, the algorithm expends the dynamic time warping algorithm of single dimensional time series (DTW) to multivariate time series, and fuses expended DTW and minimum editing distance of string. Meanwhile, in order to solve the problem that the FSM is not unique due to environment noise, a method based on custom clock is proposed to replace the system clock. Starting from two application scenarios of the program automatic evaluation system, the experiment proves the effectiveness of this method in judging the right or wrong of the program and the score of the program based on the program's merits and demerits. (3) From the perspective of program static analysis, this thesis also proposes an automatic evaluation method based on semantic analysis. The method refines and extracts the basic features, expression features, data dependence features and logical control structure features of MicroPython program based on its syntax. Besides, the method gives a feature based on editing distance of AST, then optimizes zhang-shasha algorithm for calculating editing distance of AST by specifying the cost function of different node operations. Then the features extracted above are used in three common model training respectively. The effect of each model is compared and the optimal model is selected. Starting from two application scenarios of the program automatic evaluation system, the experiment proves the effectiveness of this method in judging the right or wrong of the program and the score of the program based on the program's merits and demerits. And this method is compared with the dynamic evaluating method based on the FSM similarity of the simulator. (4) This thesis designs and develops an automatic program evaluation system for MicroPython open source hardware. Starting from the actual needs, in the practice scenario, the system judges the program's right and wrong by the program automatic evaluation method based on the FSM similarity of the simulator; in the examination scenario, the system estimates the score according to the program's merits and demerits by the program automatic evaluation method based on semantic analysis. The system is in B/S architecture mode. By setting up the simulator in the front end, the pressure of the server is reduced. The system integrates online programming, hardware simulation, online problem setting and real-time evaluation, which greatly lowers the cost of manual evaluation work. To summarise, this thesis focuses on automatic programming method for hardware-oriented programming in MicroPython environment, exploring in both theory and practice. On the one hand, the comprehensive evaluation method of program dynamic analysis and program static analysis provides some reference for automatic evaluation of hardware-oriented programs. On the other hand, it also provides a novel architecture for automatic evaluation system.
参考文献总数:

 44    

作者简介:

 曾子龙,北京师范大学硕士研究生,研究方向为图形化编程与程序自动测评。攻读硕士期间发表论文《中小学信息技术教育技术平台标准初步研究》(第二作者),获得软件著作权《Mcix面向micro:bit的在线图形化编程软件》、《Mcix面向Python的混合式编程软件》、《Mcix 面向主流USB转串口芯片的Android串口通讯软件》、《Mcix面向Arduino的Android图形化编程软件》、《Mcix数据可视化软件》。    

馆藏号:

 硕081202/19001    

开放日期:

 2020-07-09    

无标题文档

   建议浏览器: 谷歌 360请用极速模式,双核浏览器请用极速模式