Filter votes by tag #141
-
Hello. I am creating a new pairwise method. I would like a version of the getPairwise function that only counts votes with a specified tag. Is there any way to achieve this functionality with the current API? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 13 replies
-
@julien-boudry I have spent considerable time trying to do this now. I have gotten a better understanding of Condorcet's codebase than I expected to. Some functions in VotesProcess appear to have a parameter to filter by tag. But getPairwise() in ResultsProcess doesn't have such an option. I figure that the best way to do what I want is to replicate the functionality of getPairwise, but do it on a filtered array of votes. But I don't know how to do this. I don't understand how getPairwise works. The process to determine the pairwise results on a set of votes appears to be rather complicated. Do you have any advice? I'm making a specialized application that will never be merged into the core Condorcet project. I'm not particularly against modifying the existing API. If it's straightforward to do this under the existing API, I would be happy to use that. But it may be a good opportunity to make a more flexible function for determining pairwise comparisons. |
Beta Was this translation helpful? Give feedback.
-
HI @LiamM32, Nice to hear about your project. True, it's currently not possible to get Pairwise for a Result filtered by tags. The idea behind Result object is that it contains immutable properties. A quick and correct idea could be to add a property containing an immutable Pairwise and could be easy to implement, can do it today :) Could be : $r = $e->getResult(methodOptions: ['%tagFilter' => true, 'tags' => ['tag2']]);
pairwise = $r->explicitPairwise; ps: thanks for your sponsorship! |
Beta Was this translation helpful? Give feedback.
-
Commit 5b11a2e Finally, it's: $r = $e->getResult(methodOptions: ['%tagFilter' => true, '%withTag' => true, 'tags' => ['tag2']]);
$filteredByTagsPairwise = $r->pairwise; And maybe later, iI will split getResult into different and more explicit methods names than this option filter for tags. It's more a Public API solution than a real internal solution, but it's will work very well internally. Except that all the Result & Tags systems don't work well with very large elections (only if you manually activate the external data handler), but not a problem before many millions of votes. It's a limitation that must be investigated and documented. |
Beta Was this translation helpful? Give feedback.
-
Perhaps it will be easier for you to understand what kind of function I want if I explain what I'm doing. The method I am doing requires the A vs B pairwise margin to be determined for votes for a specified tag. It does this for each tag from a list of tags. For each tag, and each pair of candidates, it calculates the following formula: For each pair of candidates, it takes the sum of outputs of that formula for each tag. The result of that sum will be treated as the pairwise margin for the Schulze (margins) method. |
Beta Was this translation helpful? Give feedback.
Commit 5b11a2e
Finally, it's:
And maybe later, iI will split getResult into different and more explicit methods names than this option filter for tags.
It's more a Public API solution than a real internal solution, but it's will work very well internally.
Except that all the Result & Tags systems don't work well with very large elections (only if you manually activate the external data handler), but not a problem before many millions of votes. It's a limitation that must be investigated and documented.