简体   繁体   English

python:运行台面模拟 - 如何保存每次运行的结果?

[英]python: Run mesa simulation - how to save results of each run?

I am using this mesa framework which has two main files: model.py and server.py .我正在使用这个mesa 框架,它有两个主要文件: model.pyserver.py The simulation as built runs exactly once but I would like to run it several times ex 5 times but save the values for each run.构建的模拟只运行一次,但我想运行几次,例如 5 次,但保存每次运行的值。 I am using the command line to run the code and after each run I can click the 'Reset' button我正在使用命令行运行代码,每次运行后我都可以单击“重置”按钮'复位按钮 to run the simulation again.再次运行模拟。 The code currently clears everything when I click 'Reset' but I was wondering if it is possible to save the results of the simulation somewhere so I can calculate averages after multiple iterations.当我单击“重置”时,代码当前会清除所有内容,但我想知道是否可以将模拟结果保存在某处,以便我可以在多次迭代后计算平均值。 I thought of creating a monte carlo simulation but realized that is not possible because it requires human intervention to run and monte carlo simulations run on their own.我想创建一个蒙特卡罗模拟,但意识到这是不可能的,因为它需要人为干预才能运行,而蒙特卡罗模拟是自行运行的。

Now I want to simplify and be able to save all values after each iteration.现在我想简化并能够在每次迭代后保存所有值。 This sounds easy but due to the nature of the framework, I am unsure if this possible.这听起来很简单,但由于框架的性质,我不确定这是否可能。 I need to be able to store the values before this is called again我需要能够在再次调用之前存储这些值

server = ModularServer(
Schelling, [canvas_element, happy_element, happy_chart], "Schelling", model_params

Does anyone have any ideas if this can be accomplished?如果这可以实现,有没有人有任何想法? I spent the past few days on this and am unsure if this is possible.过去几天我都在研究这个,但不确定这是否可行。 I checked stackoverflow for similar questions but did not find any.我检查了类似问题的计算器,但没有找到任何问题。

Sorry for all the updates, I tried to simplify to the basic problem.抱歉所有更新,我试图简化为基本问题。

Thanks in advance for any help.在此先感谢您的帮助。

如果有任何解决方案,我需要将我的运行保存到 MESA 中的文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM