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


Python GeneralMethods.trueWith方法代码示例

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


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

示例1: messageSelectionMethod

# 需要导入模块: from library.classes import GeneralMethods [as 别名]
# 或者: from library.classes.GeneralMethods import trueWith [as 别名]
 def messageSelectionMethod(self, currentTimeStep, user, currentTopics, **conf):
     if self.lastObservedTimeStep != currentTimeStep:
         self._updateTopicProbabilities(currentTimeStep, currentTopics, **conf)
     message = None
     if GeneralMethods.trueWith(user.messagingProbability):
         if GeneralMethods.trueWith(user.newTopicProbability):
             topic = Topic(len(currentTopics))
             currentTopics.append(topic)
             message = user.generateMessage(currentTimeStep, topic)
         else:
             if GeneralMethods.trueWith(user.probabilityOfPickingPopularTopic):
                 if user.topicClass != None:
                     topicIndex = GeneralMethods.weightedChoice(
                         [i[1] for i in self.topicProbabilities[user.topicClass]]
                     )
                     topic = self.topicProbabilities[user.topicClass][topicIndex][0]
                     message = user.generateMessage(currentTimeStep, topic)
                     if not GeneralMethods.trueWith(topic.stickiness):
                         message = None
                 else:
                     topicIndex = GeneralMethods.weightedChoice([i[1] for i in self.topTopics])
                     topic = self.topTopics[topicIndex][0]
                     message = user.generateMessage(currentTimeStep, topic)
             else:
                 if user.topicClass != None:
                     message = user.generateMessage(
                         currentTimeStep, random.choice(self.topicProbabilities[user.topicClass])[0]
                     )
                 else:
                     topicIndex = GeneralMethods.weightedChoice([i[1] for i in self.allTopics])
                     topic = self.allTopics[topicIndex][0]
                     message = user.generateMessage(currentTimeStep, topic)
     return message
开发者ID:kykamath,项目名称:spam_model,代码行数:35,代码来源:models.py

示例2: __init__

# 需要导入模块: from library.classes import GeneralMethods [as 别名]
# 或者: from library.classes.GeneralMethods import trueWith [as 别名]
 def __init__(self, id):
     self.id = id
     self.totalCount = 0
     self.countDistribution = defaultdict(int)
     self.age = 0
     self.topicClass = random.choice(topicClasses)
     self.decayCoefficient = -3
     if GeneralMethods.trueWith(0.05): self.stickiness = random.uniform(stickinessLowerThreshold, 1.0)
     else: self.stickiness = random.uniform(0.0, 0.1)
     self.payloads = PayLoad.generatePayloads(self.id, noOfPayloadsPerTopic)
     #Non-modeling attributes.
     self.color = GeneralMethods.getRandomColor()
开发者ID:kykamath,项目名称:spam_model,代码行数:14,代码来源:objects_original.py


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