本文整理汇总了Python中messages.Messages.calculate_at_equilibrium方法的典型用法代码示例。如果您正苦于以下问题:Python Messages.calculate_at_equilibrium方法的具体用法?Python Messages.calculate_at_equilibrium怎么用?Python Messages.calculate_at_equilibrium使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messages.Messages
的用法示例。
在下文中一共展示了Messages.calculate_at_equilibrium方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _code_fitness
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import calculate_at_equilibrium [as 别名]
def _code_fitness(self, code, codon_usage = None):
""" Gets the overall fitness of a code at the given codon usage,
if no codon usage is given the codon usage of the
currently fixed code at equilibrium is used. """
fitness_contributions = None
if codon_usage is None:
if self._last_messages is None:
if code == self._current_code:
msgs = Messages(self._current_code.effective_code_matrix,
self._fitness_matrix,
self._message_mutation_matrix)
msgs.calculate_at_equilibrium()
self._last_messages = msgs
fitness_contributions = msgs.fitness_contributions
else:
self._code_fitness(self._current_code)
if fitness_contributions is None:
msgs = Messages(code.effective_code_matrix,
self._fitness_matrix,
self._message_mutation_matrix)
msgs.calculate_at_codon_usage(self._last_messages.codon_usage)
fitness_contributions = msgs.fitness_contributions
overall_fitness = self._overall_fitness(fitness_contributions)
if codon_usage is None and code == self._current_code:
self._current_code_fitness = overall_fitness
return overall_fitness