MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 2014-03-24 13:33:34

HMR
Member
Registered: 2014-03-14
Posts: 6

What is difference between Agent Type and AbstractAgent?

hello dear
What is difference between Agent type and AbstractAgent type?

Offline

#2 2014-03-24 18:02:52

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: What is difference between Agent Type and AbstractAgent?

Hello,

- Agent(s) have their own independant life cycle : they run using their own threadand go through activate() -> live() -> end() automatically. They are generally used for designing distributed applications where agents evolve according to the messages they receive.

- AbstractAgent(s) are not threaded : they do activate() automatically but then they need to be scheduled for execution using a Scheduler agent (see the simulation tutorials). So they are designed to be used for simulating a MAS with many entities.

Offline

#3 2014-03-25 10:05:39

HMR
Member
Registered: 2014-03-14
Posts: 6

Re: What is difference between Agent Type and AbstractAgent?

Thank you so much...

Offline

#4 2014-04-01 13:42:48

keke
Member
Registered: 2014-03-01
Posts: 14

Re: What is difference between Agent Type and AbstractAgent?

Hi,
Which type of data consume much memory? AbstractAgent or Agent?
In addition, how can I modify the code such that the AbstractAgent could wait a message forever like function waitNextMessage() in the one of Agent?
Thanks

Last edited by keke (2014-04-01 14:16:26)

Offline

#5 2014-04-08 14:00:09

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: What is difference between Agent Type and AbstractAgent?

keke wrote:

Which type of data consume much memory? AbstractAgent or Agent?

Agent, because they require the creation of a thread.

keke wrote:

In addition, how can I modify the code such that the AbstractAgent could wait a message forever like function waitNextMessage() in the one of Agent?

You could do something like

Message m = nextMessage();
while(m == null){
Thread.sleep(1000);
m = nextMessage();
}

It is on purpose that such a method is not present in the AA class because the user should be aware of what he is doing : calling such a method causes the calling thread to be blocked and that is error proned because it could be another agent or a swing/GUI thread.

Offline

#6 2014-04-10 13:32:01

keke
Member
Registered: 2014-03-01
Posts: 14

Re: What is difference between Agent Type and AbstractAgent?

In fact, while waiting for your answer, I recognized this problem. I tried to test the similar code like your last week but I already changed the code like this:
if ((m=nextMessage())==null) return;
in order to not block the system.
But this makes me some problem of time: I have a network with many nodes, and each node has to wait some messages from others. By using scheduler like bee example, each node will be assigned one task and we consider node by node, i.e., after finishing doing task of this node we jump to next node (from 1-->N). However, when testing with large number of messages and transactions amongst nodes, I see the system is very slow. This comes from this problem: you have 10000 nodes, but only node 1th and 10000th communicate together, the remaining (9998 nodes) do not receive/send message, but in fact they also participate into the scheduler (for next step of protocol, for instance) but for nothing. So, the systems gets worse.

Do you have any suggestion to avoid this? I don't want 9998 nodes to be left the scheduler (since they will join in other activities later) but they makes system slowly.

Thank you

Last edited by keke (2014-04-10 13:33:54)

Offline

#7 2014-04-10 13:56:37

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: What is difference between Agent Type and AbstractAgent?

Well, what I would do would be to use the group/role system to dynamically make the agents that have to be scheduled in another group : a "working group".
the 1st and the 10000th could take the role "worker" if they know they have to be scheduled for waiting a message (you need another activator on that group/role). Once done they could leave this group/role so that they would not be scheduled anymore for this particular work.
Summarizing, the idea is : structure your application using group/role. Entering and leaving group/role is easy and would allow you to only target the right agents.

Offline

#8 2014-04-10 15:17:01

keke
Member
Registered: 2014-03-01
Posts: 14

Re: What is difference between Agent Type and AbstractAgent?

The problem is that: I don't know in advance the 1st and 10000th node will take that role (I just give you an example for these two nodes, but in fact it could be other nodes and other number of nodes).
I also take care your suggestion about dynamic leaving/entering group/role but got problem above.
Thanks in advance.

Offline

#9 2014-04-10 15:47:24

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: What is difference between Agent Type and AbstractAgent?

keke wrote:

The problem is that: I don't know in advance the 1st and 10000th node will take that role

I understood that, but the idea would be that you would do a first round on everybody using a particular activator that make some agents take the "working" roles. Then schedule the second activator (targeting the agents that have something to do) and so on. Could that be a solution ?

Offline

#10 2014-04-10 16:47:18

keke
Member
Registered: 2014-03-01
Posts: 14

Re: What is difference between Agent Type and AbstractAgent?

System is still slow sad
Let me explain the system: I have N nodes, each node n sends d_n messages to other d_n ones,then of course its friends will receives messages and so does n.
After each node sends message, the scheduler is activated so that all nodes will do some activities with receiving messages. The problem is that: for each ith message (i=1->d_n) of each node n, the scheduler will assign one slot of time for node n to process, then jumpto node (n+1) and so on, but infact it's better to node n to continue processing. Of course when N is large, the time between two process of node n (e.g., ith and (i+1)msg) is large. And i don't know how to reduce this time. Do you have any suggestion? Thanks

Offline

#11 2014-04-11 16:01:55

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: What is difference between Agent Type and AbstractAgent?

Without more info (without seeing the code), it is hard to say what is the bottleneck. Especially, 10000 is not a so big number and you should not experience such problems imo.
Still, I have try to launch 10000 (threaded) Agents and it took only about one 1 Go on my PC, which is a relatively small amount of memory. So, if your agents mainly wait for messages before doing something, maybe that it is worth a try so that you could do your application without any scheduling.

Offline

#12 2014-04-28 16:34:53

keke
Member
Registered: 2014-03-01
Posts: 14

Re: What is difference between Agent Type and AbstractAgent?

Sorry to reply you lately.
As mentioned above, my problem when using threaded Agents is memory. When I launch even 100 nodes, the VIRT memory (in "top" command in Ubuntu) shows 37GB and then it informs "out of memory", although the "true" memory to run programme RES (and also SHR) which only shows 10M. I tested with other size of network and it has the same problem.
Do you know how to reduce the VIRT memory in this case?
Thank you.

Offline

#13 2016-02-24 05:07:46

oxality
Member
Registered: 2016-02-24
Posts: 10

Re: What is difference between Agent Type and AbstractAgent?

Sorry to resurrect a dead thread but I had a question about abstract agents vs agents. Im trying to have three+ separate objects communicate with each other so i made them into agents. This worked well, but i was unable to slow the simulation down into "steps" like with abstract agents. However, with abstract agents i find myself in a jam because I cant have one object loop while waiting for a reply message. Is there anyway to apply a timeline of sorts to agents? and is there anyway to have two abstract agents communicate with each other without explicitly defining the send-receive-reply-receive process?

Last edited by oxality (2016-02-24 05:08:02)

Offline

#14 2016-02-28 19:20:09

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: What is difference between Agent Type and AbstractAgent?

Not sure that this will help but here is a first reply: You can work with AA and communicate by checking your mailbox each turn. Also, be aware that you can use a scheduler on agents from the Agent class. Finally, you can mix agents from any type.

Offline

#15 2016-03-03 23:17:29

oxality
Member
Registered: 2016-02-24
Posts: 10

Re: What is difference between Agent Type and AbstractAgent?

fmichel wrote:

Not sure that this will help but here is a first reply: You can work with AA and communicate by checking your mailbox each turn. Also, be aware that you can use a scheduler on agents from the Agent class. Finally, you can mix agents from any type.

Thanks for the reply. I may check the mailbox each turn, i didnt think to do that. Is there a way to launch into a certain method after checking the mailbox, but have that method span over multiple steps in the simulation?

Also, how does the scheduler interact/affect the regular Agents?

Offline

#16 2016-03-04 12:25:57

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: What is difference between Agent Type and AbstractAgent?

oxality wrote:

Is there a way to launch into a certain method after checking the mailbox, but have that method span over multiple steps in the simulation?

Not sure about what you want to do here, could you describe a use case ?

oxality wrote:

Also, how does the scheduler interact/affect the regular Agents?

The scheduler can trigger an Agent's method regardless of its Thread. Therefore, in a such a case, having such a method synchronized could be a good idea for avoiding inconsistent states.

Offline

#17 2016-03-05 02:48:17

oxality
Member
Registered: 2016-02-24
Posts: 10

Re: What is difference between Agent Type and AbstractAgent?

fmichel wrote:
oxality wrote:

Is there a way to launch into a certain method after checking the mailbox, but have that method span over multiple steps in the simulation?

Not sure about what you want to do here, could you describe a use case ?

So i have two entities, a console with a task list and a robot. The robot asks the console for a task (end step) the console responds with a task (end step) the robot then begins the process of moving to the work area, which i would like to span over multiple steps. In this case, the robot moves grid unit to grid unit, so preferably moving to an adjacent grid unit would take up one step.

Offline

#18 2016-03-07 20:50:23

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: What is difference between Agent Type and AbstractAgent?

oxality wrote:

So i have two entities, a console with a task list and a robot. The robot asks the console for a task (end step) the console responds with a task (end step) the robot then begins the process of moving to the work area, which i would like to span over multiple steps. In this case, the robot moves grid unit to grid unit, so preferably moving to an adjacent grid unit would take up one step.

OK, maybe that what you want could be done by using several activators in your scheduler (one per task). Did you try that ?

Offline

#19 2016-03-07 21:22:30

oxality
Member
Registered: 2016-02-24
Posts: 10

Re: What is difference between Agent Type and AbstractAgent?

fmichel wrote:

OK, maybe that what you want could be done by using several activators in your scheduler (one per task). Did you try that ?

No, but i will try. I think Ill be able to make it work though, thanks for the suggestions.

Offline

Board footer