本文整理汇总了Python中experiment.Experiment.add_metric方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.add_metric方法的具体用法?Python Experiment.add_metric怎么用?Python Experiment.add_metric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类experiment.Experiment
的用法示例。
在下文中一共展示了Experiment.add_metric方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: altruism
# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import add_metric [as 别名]
def altruism(self, altruisticProbability, selfishProbability, altruismCost,
altruismBenefit, disease, harshness, numTicks):
"""
Runs an experiment of the Biology/Evolution/Altruism model.
:returns: The table output of the experiment.
"""
job = uuid4()
exp_path = '/tmp/%s/experiment.xml' % job
out_path = '/tmp/%s/out.csv' % job
params = {
'altruistic-probability': altruisticProbability,
'selfish-probability': selfishProbability,
'cost-of-altruism': altruismCost,
'benefit-from-altruism': altruismBenefit,
'disease': disease,
'harshness': harshness,
}
exp = Experiment(steps=numTicks, params=params)
exp.add_metric(color='pink').add_metric(color='green')
exp.write_xml(exp_path)
model = '%s/models/Sample Models/Biology/Evolution/Altruism.nlogo' % NETLOGO_HOME
self.call_experiment(model, exp_path, exp.name, out_path)
with open(out_path, 'r') as out_file:
return out_file.read()