Question: I need Task 2 done in python program, please not handwritten, Task 1 output was a dictionary as follows: { 1: [3, 2, 4, 1],
I need Task 2 done in python program, please not handwritten,
Task 1 output was a dictionary as follows:
{ 1: [3, 2, 4, 1], 2: [4, 3, 1, 2], 3: [2, 3, 1, 4], 4: [1, 3, 4, 2], }


![1], 2: [4, 3, 1, 2], 3: [2, 3, 1, 4], 4:](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f12fbfd6c8d_43166f12fbf756c1.jpg)
![[1, 3, 4, 2], } Voting Rules: Dictatorship: An agent is selected,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f12fc08a626_43266f12fc00d813.jpg)


Voting Rules: Dictatorship: An agent is selected, and the winner is the alternative that this agent ranks first. For example, if the preference ordering of the selected agent is a > >B> 8, then the winner is alternative a. Plurality: The winner is the alternative that appears the most times in the first position of the agents' preference orderings. In the case of a tie, use a tie- breaking rule to select a single winner. Veto: Every agent assigns 0 points to the alternative that they rank in the last place of their preference orderings, and 1 point to every other alternative. The winner is the alternative with the most number of points. In the case of a tie, use a tie-breaking rule to select a single winner. Borda: Every agent assigns a score of 0 to the their least-preferred alternative (the one at the bottom of the preference ranking), a score of 1 to the second least-preferred alternative, ... , and a score of m 1 to their favourite alternative. In other words, the alternative ranked at position i receives a score of m - j. The winner is the alternative with the highest score. In the case of a tie, use a tie-breaking rule to select a single Borda: Every agent assigns a score of 0 to the their least-preferred alternative (the one at the bottom of the preference ranking), a score of 1 to the second least-preferred alternative, ... , and a score of m - 1 to their favourite alternative. In other words, the alternative ranked at position ; receives a score of m - j. The winner is the alternative with the highest score. In the case of a tie, use a tie-breaking rule to select a single winner. m1 Harmonic: Every agent assigns a score of th to the their least-preferred alternative (the one at the bottom of the preference ranking), a score of m-1 to the second least-preferred alternative, ..., and a score of 1 to their favourite alternative. In other words, the alternative ranked at position ; receives a score of 1. The winner is the alternative with the highest score. In the case of a tie, use a tie-breaking rule to select a single winner. Single Transferable Vote (STV): The voting rule works in rounds. In each round, the alternatives that appear the least frequently in the first position of agents' rankings are removed, and the process is repeated. When the final set of alternatives is removed (one or possibly more), then this last set is the set of possible winners. If there are more than one, a tie-breaking rule is used to select a single winner. Example: Consider the preference profile of the example above. In the first round alternative (\delta is removed V) and we get the following new preference profile: Agent 1: ayB Agent 2:a > B> Agent 3: Y Ba Agent 4: Bay In the second round, both y and B are removed. In the third round, a is removed, and a is the winner. Tie-Breaking Rules: We will consider the following three tie-breaking rules. Here, we assume that the alternatives are represented by integers. max: Among the possible winning alternatives, select the one with the highest number. min: Among the possible winning alternatives, select the one with the lowest number. agent i: Among the possible winning alternatives, select the one that agent i ranks the highest in his/her preference ordering. Task 2: Implement the following functions: dictatorship(preference Profile, agent) -> int The function should input a preference profile represented by a dictionary as described above and an integer corresponding to an agent. The return of the function should be the winner according to the Dictatorship rule described above. The function should include error handling in case the inputted integer does not correspond to an agent (but not necessarily if it is not an integer). scoringRule(preferences, scoreVector, tieBreak): -> int The function should input . a preference profile represented by a dictionary as described above. a score vector of length m, i.e., equal to the number of alternatives, i.e., a list of length m containing positive floating numbers. an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). For every agent, the function assigns the highest score in the scoring vector to the most preferred alternative of the agent, the second highest score to the second most preferred alternative of the agent and so on, and the lowest score to the least preferred alternative of the agent. In the end, it returns the alternative with the highest total score, using the tie-breaking option to distinguish between alternatives with the same score. The function should contain error-handling code for the case when the length of the scoring vector is not m. In that case, the message "Incorrect input" should be printed and the function should return false. plurality (preferences, tieBreak) -> int The function should input a preference profile represented by a dictionary as described above. an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). The function should return the winner of the Plurality rule as described above, using the tie-breaking option to distinguish between possible winners. veto (preferences, tieBreak) -> int veto (preferences, tieBreak) -> int The function should input . a preference profile represented by a dictionary as described above. an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). The function should return the winner of the Veto rule as described above, using the tie-breaking option to distinguish between possible winners. borda (preferences, tieBreak) -> int The function should input a preference profile represented by a dictionary as described above. an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). The function should return the winner of the Borda rule as described above, using the tie-breaking option to distinguish between possible winners. harmonic (preferences, tieBreak) -> int The function should input a preference profile represented by a dictionary as described above. an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). The function should return the winner of the Harmonic rule as described above, using the tie-breaking option to distinguish between possible winners. STV (preferences, tieBreak) -> int The function should input . a preference profile represented by a dictionary as described above. an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). The function should return the winner of the Single Transferable Vote rule as described above, using the tie-breaking option to distinguish an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). The function should return the winner of the Harmonic rule as described above, using the tie-breaking option to distinguish between possible winners. STV (preferences, tieBreak) -> int The function should input a preference profile represented by a dictionary as described above. an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). The function should return the winner of the Single Transferable Vote rule as described above, using the tie-breaking option to distinguish between possible winners. rangeVoting (values, tieBreak) -> int The function should input a worksheet corresponding to an xlsx file, see Task 1 for the details. an option for the tie-breaking among possible winners (see section "Tie-Breaking" below). The function should return the alternative that has the maximum sum of valuations, i.e., the maximum sum of numerical values in the xlsx file, using the tie-breaking option to distinguish between possible winners. Tie-breaking: For the tieBreak input of these functions, the possible options are the following: tieBreak = "max". In that case the max tie-breaking rule should be applied (see above). tieBreak = "min". In that case the min tie-breaking rule should be applied (see above). tieBreak is an integer between 1 and n: In that case the agent i rule should be applied, with i being the inputted integer (see above). The function should include error handling in case the inputted integer does not correspond to an agent
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
