Python代写:CSC120H Simulating Canadian Elections

Introduction

高大上的Elections,特别是在大选中,投票往往会采用电子选箱,也就是智能选举系统。

相比纸质选票,电子计票有着快速计票、实时计票、节省人工成本、计票可回收利用等优点。尤其是差额票,对于候选人较多的情况,电子计票的优势就更大了。

电子计票系统中,最重要的部件就是识别有效选票、鉴别无效选票、统计选票,对识别器质量已经算法有较高的要求。

Requirement

There are so many different kinds of voting systems, especial electronic voting system in the world. In this request you will be comparing four of them: Approval Voting; Plurality, also known as First Past the Post; Copeland’s Method and the Borda Count. You will be simulating Canadian elections, where voters are choosing between the four major federal parties (New Democratic Party, Green Party, Liberal Party, Conservative Party).

  1. Approval Voting: everyone can vote many options
  2. Plurality: everyone can vote only one candidate
  3. Copeland’s Method: everyone can rank the candidates
  4. The Borda Count: everyone can rank the candidates

Analysis

计票过程

对于Approval Voting计票法,每人可投多个候选人,因此不需要考虑无效选票,检票时,当发现其中候选人之一出现选票时,记录下来
对于Plurality计票法,每人仅可投一位候选人,因此当出现多位时,该选票记为废票。有效票则记录在候选人票数中
对于Copeland’s Method计票法,每人给出排名,如果允许重复排名则不会出现无效选票,反之则需要剔除无效选票。根据选票中的票值排序,按照权值加到候选人票数,并记录下来
对于The Borda Count计票法,类似Copeland’s Method

验票过程

对于Approval Voting计票法,验票则是将候选人的票数从高到低排序
对于Plurality计票法,同Approval Voting,将候选人的票数从高到低排序
对于Copeland’s Method计票法,将候选人的加权和从高到低排序
对于The Borda Count计票法,类似Copeland’s Method,将候选人的加权和从高到低排序