py school match是一个python包,它实现了学生到学校分配问题的匹配算法。
py-school-match的Python项目详细描述
py学校匹配
py school match是一个开源的python包,它实现了多个匹配算法,以便分配 学生们去学校。
它提供了多种随时可用的算法:
- 最高交易周期(TTC)
- 多次拆线延迟验收(DAMTB)
- 单次拆线延迟验收(DASTB)
- 稳定改善周期(SiC)
- 延迟验收,多个系紧断裂,加上稳定循环(MSIC)
- 延迟验收,单系断开,加上非稳定循环(NSIC)
py school match是专门为学生到学校分配问题设计的。因为这个, 您可以专注于评估不同的设置和算法,而无需调整或开发 完整的解决方案。
示例代码
importpy_school_matchaspsm# Creating three students.st0=psm.Student()st1=psm.Student()st2=psm.Student()# Creating a criteria. This means 'vulnerable' is now a boolean.vulnerable=psm.Criteria('vulnerable',bool)# Assigning st1 as vulnerablestudent_vulnerable=psm.Characteristic(vulnerable,True)st1.add_characteristic(student_vulnerable)# Creating three schools, each with one seat available.sc0=psm.School(1)sc1=psm.School(1)sc2=psm.School(1)# Defining preferences (from most desired to least desired)st0.preferences=[sc0,sc1,sc2]st1.preferences=[sc0,sc2,sc1]st2.preferences=[sc2,sc1,sc0]# Creating a lists with the students and schools defined above.schools=[sc0,sc1,sc2]students=[st0,st1,st2]# Defining a rulesetruleset=psm.RuleSet()# Defining a new rule from the criteria above.rule_vulnerable=psm.Rule(vulnerable)# Adding the rule to the ruleset. This means that a 'vulnerable' student has a higher priority.# Note that rules are added in order (from higher priority to lower priority)ruleset.add_rule(rule_vulnerable)# Creating a social planner using the objects above.planner=psm.SocialPlanner(students,schools,ruleset)# Selecting an algorithmalgorithm=psm.SIC()# Running the algorithm.planner.run_matching(algorithm)# inspecting the obtained assignationforstudentinstudents:print("Student {} was assigned to School {}".format(student.id,student.assigned_school.id))
安装
依赖关系
- 图形工具(>;=2.27)
用户安装
pip install py-school-match
或者您可以克隆repo并安装它:
git clone https://github.com/igarizio/py-school-match
cd py-school-match
python setup.py install
记得先安装graph-tool。
开发
贡献是非常受欢迎的。请随时提出问题或与我联系!请记住,此软件包不提供任何形式的担保。
贡献是非常受欢迎的。请随时提出问题或与我联系!
请记住,此软件包不提供任何形式的担保。
如何引用?
在此处插入引文。