func PairwiseMajority(pp PreferenceProfile) Preference { u := ProfileUniverse(pp) return relation.NewFunctionBinaryRelation(u, func(x, y set.Element) bool { return CountPreferenceOf(x, y, pp) >= CountPreferenceOf(y, x, pp) }) }
func BordaCounting(pp PreferenceProfile) Preference { u := ProfileUniverse(pp) return relation.NewFunctionBinaryRelation(u, func(x, y set.Element) bool { return ProfileBordaCount(x, pp) >= ProfileBordaCount(y, pp) }) }
func WeightedMajority(pp PreferenceProfile, w func(uint) float64) Preference { u := ProfileUniverse(pp) return relation.NewFunctionBinaryRelation(u, func(x, y set.Element) bool { return CountWeightedPreferenceOf(x, y, pp, w) >= CountWeightedPreferenceOf(y, x, pp, w) }) }
"testing" "github.com/nlandolfi/set" "github.com/nlandolfi/set/relation" ) var numbers set.Interface = set.New() func init() { for n := 0; n < 100; n++ { numbers.Add(n) } } var equality relation.AbstractInterface = relation.NewFunctionBinaryRelation(numbers, func(x, y set.Element) bool { return x == y }) var lessEqual relation.AbstractInterface = relation.NewFunctionBinaryRelation(numbers, func(x, y set.Element) bool { return x.(int) <= y.(int) }) func BenchmarkSymmetric(b *testing.B) { for n := 0; n < b.N; n++ { if relation.Symmetric(equality) != true { b.Fatalf("The equality relation should be symmetric") } } } func BenchmarkTransitive(b *testing.B) {