0

嘿,我正在使用 Python 库 Mesa 进行基于代理的建模。

我已经将“网络上的病毒”模型改编为我自己关于利益相关者参与智能城市的研究,并陷入调试 ModularServer 的问题,该服务器在 python 中的模型与其在 javascript 中的浏览器界面之间创建了链接。

这是我的代码:

# create and launch server
server = ModularServer(
    SEmodel, [network, chart], "Stakeholder Engagement Model", model_parameters
)
server.port = 8521 #default port

这是错误:

TypeError                                 Traceback (most recent call last)
<ipython-input-79-3fa8b0cdeb17> in <module>
      1 # create and launch server
----> 2 server = ModularServer(
      3     SEmodel, [network, chart], "Stakeholder Engagement Model", model_parameters
      4 )
      5 server.port = 8521 #default port

/usr/local/anaconda3/lib/python3.8/site-packages/mesa/visualization/ModularVisualization.py in __init__(self, model_cls, visualization_elements, name, model_params)
    284 
    285         self.model_kwargs = model_params
--> 286         self.reset_model()
    287 
    288         # Initializing the application itself:

/usr/local/anaconda3/lib/python3.8/site-packages/mesa/visualization/ModularVisualization.py in reset_model(self)
    312                 model_params[key] = val
    313 
--> 314         self.model = self.model_cls(**model_params)
    315 
    316     def render_model(self):

<ipython-input-76-fe37123a8f72> in __init__(self, num_nodes, avg_node_degree, engagement, trustability, influenceability, recovery, experience, initial_opinion, opinion, public_opinion, public_sector_opinion, corpo_opinion, startup_opinion, academic_opinion, civil_opinion, media_opinion)
    180 
    181         self.running = True
--> 182         self.datacollector.collect(self)
    183 
    184 

/usr/local/anaconda3/lib/python3.8/site-packages/mesa/datacollection.py in collect(self, model)
    189                     self.model_vars[var].append(reporter[0](*reporter[1]))
    190                 else:
--> 191                     self.model_vars[var].append(self._reporter_decorator(reporter))
    192 
    193         if self.agent_reporters:

/usr/local/anaconda3/lib/python3.8/site-packages/mesa/datacollection.py in _reporter_decorator(self, reporter)
    172 
    173     def _reporter_decorator(self, reporter):
--> 174         return reporter()
    175 
    176     def collect(self, model):

TypeError: 'int' object is not callable
4

0 回答 0