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


Python Experiment.write_xml方法代码示例

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


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

示例1: altruism

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import write_xml [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()
开发者ID:similitude,项目名称:netlogo-sample-simmer,代码行数:31,代码来源:handler.py


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