Python mesa ModularServer error 'int' object is not callable

144 Views Asked by At

Hey I am using the Python library Mesa for Agent-Based Modeling.

I have adapted the 'virus on a network' model to my own research about stakeholder engagement in smart-city and get stuck at debugging the ModularServer which creates the link between the model in python and its browser interface in javascript.

here is my code:

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

and here is the error:

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
0

There are 0 best solutions below