Hi,
I am trying to set up a multi-agent system. this system contains over 20 agents and each agent has 13 bahaviours. most of them are cycle behaviours.
the problem is: after I start all of the agent for a while, some of the behaviours in some agents will stop running. the code is shown below.
class MyAgent(spade.Agent.Agent):
def __init__(self, agentid, n):
....... #(some defination)
class Receive(spade.Behaviour.Behaviour):
# this behaviour is in charge of waiting for messages
def __init__(self, b):
self.b = b
self.c = [1,0,0]
self.msg = [1,0,0]
spade.Behaviour.Behaviour.__init__(self)
self.e1 = 0
def onStart(self):
print "listening for client"
def _process(self):
self.msg = self._receive(True, 0.4)
n = self.b.n
if self.msg:
print "%d got a message" %(n)
self.c = self.msg.getContent()
else:
print "I waited but got no message"
self.e1 = self.e1 +1
def onEnd(self):
print "server closed"
class behaviour2(spade.Behaviour.PeriodicBehaviour):
........
class behaviour13(spade.Behaviour.PeriodicBehaviour):
def _setup(self):
self.thr_Send = self.Send(self)
self.behaviour_2 = self.behaviour2(self)
.........
self.behaviour_13 = self.behaviour13(self)
def tearDown(self):
self.stop()
if __name__ == "__main__":
num_MG = 28
A = {"version": 1}
for i in range(num_MG):
A[str(i)] = MyAgent(n,(i+1))
A[str(i)].start()
time.sleep(576)
for i in range(num_MG):
A[str(i)].tearDown()
I have checked the code and there is no error. after all the 28 agents runs for a while, for example, 5 minutes, the Receive behaviour stops in some agents
after the code runs the tearDown(), I made an array to record the variation of self.e1 in the Receive behaviour every 0.4 seconds. it shows like bellow:
[0, 1, 2, 3, ......, 34,34, 34,.....34] it means the cycle behaviour stops after self.e1 = 34.
I don't know why this happens and how to solve problem like this . could anyone help me with this? thans
Jin Wei