Skip to content

Commit

Permalink
Updated resoluteness_data and added to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wesholliday committed Dec 26, 2024
1 parent 3b7e602 commit 77ca4f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/source/analysis_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ Functions that can be used to compare and contrast voting methods.
.. autofunction:: pref_voting.analysis.condorcet_efficiency_data
```

## Resoluteness


```{eval-rst}
.. autofunction:: pref_voting.analysis.resoluteness_data
```

## Axiom Violations
Expand Down
5 changes: 5 additions & 0 deletions pref_voting/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def resoluteness_data(
"probmod": list(),
"probmod_param":list(),
"num_trials": list(),
"freq_multiple_winners": list(),
"avg_num_winners": list(),
"avg_percent_winners": list(),
}
Expand All @@ -255,10 +256,13 @@ def resoluteness_data(
data = list(map(get_data, range(num_trials)))

num_winners = {vm.name: 0 for vm in vms}
multiple_winners = {vm.name: 0 for vm in vms}

for d in data:
for vm in vms:
num_winners[vm.name] += int(d["num_winners"][vm.name])
if d["num_winners"][vm.name] > 1:
multiple_winners[vm.name] += 1

for vm in vms:
data_for_df["vm"].append(vm.name)
Expand All @@ -267,6 +271,7 @@ def resoluteness_data(
data_for_df["probmod"].append(probmod)
data_for_df["probmod_param"].append(probmod_param)
data_for_df["num_trials"].append(num_trials)
data_for_df["freq_multiple_winners"].append(multiple_winners[vm.name] / num_trials)
data_for_df["avg_num_winners"].append(
num_winners[vm.name] / num_trials
)
Expand Down

0 comments on commit 77ca4f1

Please sign in to comment.