当前位置: 首页>>代码示例>>Python>>正文


Python Profile.getRankMaps方法代码示例

本文整理汇总了Python中profile.Profile.getRankMaps方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.getRankMaps方法的具体用法?Python Profile.getRankMaps怎么用?Python Profile.getRankMaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在profile.Profile的用法示例。


在下文中一共展示了Profile.getRankMaps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dict

# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import getRankMaps [as 别名]
preferences = []
preferences.append(preference1)
preferences.append(preference2)

# Let's set up a dictionary that associates integer representations of our candidates with their names.
candMap = dict()
candMap[1] = "john"
candMap[2] = "jane"
candMap[3] = "jill"

# Now that we have this candidate mapping and a list of Preference objects, we can construct a 
# Profile object.
profile = Profile(candMap, preferences)

# Let's print the output of some of the Profile object's methods.
print(profile.getRankMaps())
print(profile.getWmg())
print(profile.getElecType())
print(profile.getReverseRankMaps())
print(profile.getOrderVectors())

# Now let's see which candidate would win an election were we to use the Plurality rule.

# First, we construct a Mechanism object
mechanism = mechanism.MechanismPlurality()

# Let's print the ouputs of some of the Mechanism object's methods.
print(mechanism.getWinners(profile))
print(mechanism.getMov(profile))

# We can also call margin of victory functions directly without constructing a mechanism object.
开发者ID:PrefPy,项目名称:prefpy,代码行数:33,代码来源:mechanismRunnerExample.py


注:本文中的profile.Profile.getRankMaps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。