Outcome Visualisation#
For reference, see the module visualisation
.
We provide the visualisation for the outcomes of greedy_utilitarian_welfare()
and method_of_equal_shares()
. This explains in depth the outcome of the election based on the chosen rule. This includes which projects were selected or rejected, summary statistics about the election, and rule specific information such as effective vote count in method_of_equal_shares()
. The chart libraries we use are ZingChart and Google Developer Charts, and the visualisations are saved as HTML files.
Note that selecting the visualisation option will increase the runtime of the election, however without this option, the runtime will remain the same.
Greedy Utilitarian Welfare#
The visualisation for the Greedy Utilitarian Welfare currently works only on additive utility functions.
We provide a way to visualise the results using the class
GreedyWelfareVisualiser
. Note the analytics flag in the
function greedy_utilitarian_welfare()
must be set to True to
generate the visualisation.
from pabutools.visualisation.visualisation import GreedyWelfareVisualiser
from pabutools.rules.greedywelfare import greedy_utilitarian_welfare
from pabutools import election
from pabutools.election import Cost_Sat
instance, profile = election.parse_pabulib("./{path_to_election_file}.pb")
outcome = greedy_utilitarian_welfare(instance, profile, sat_class=Cost_Sat, analytics=True)
# The visualiser takes the profile, instance, and outcome as arguments
visualiser = GreedyWelfareVisualiser(profile, instance, outcome)
# name is optional and defaults to the empty string
visualiser.render("./{path_to_output_file}/", name="{name}")
The visualisation will be saved in the specified path as a standalone HTML file called “{name}_round_analysis.html”.
Note that the visualisation is only available for additive utility functions.
An example of the generated visualisation can be found here.