Re: Modifying agent content from another agent
For each agent, you could simply define a public IntBag method getAndRemoveBag() where the called agent puts the IntBag or bags in a temp location, calls clear() on it’s copies, then returns the temp copies to the calling agent.
Another approach, which is maybe safer and more keeping with the spirit of agent-based modeling, is to set it up as a multistep transaction. Here’s a generic transaction, where the sequence numbers are MASON ticks, and FOO is the name of the IntBags in question:
- Agent 1 requests FOO from Agent 2
- Agent 2 sends FOO to Agent 1
- Agent 1 acknowledges receipt of FOO to Agent 2
- Agent 2 deletes it’s copy of FOO
This approach would require creating a transaction queue for each agent, but that could be as simple as a bag used as a FIFO queue. It would also need a stack of pending (not yet completed) transactions. Bag provides push() and pop() for that purpose. Then, within each agent’s step(), the would check the transaction queue for new transactions to process.
This later approach is safer because it provides a place in the code to manage colliding requests — i.e. two or more neighboring agents asking for the same FOO. After all, in ABM this is exactly the sort of distributed processing. Also, the simple getAndRemoveBag() approach might generate weird results related to agent activation sequence. You don’t want that!
Hope this helps,
On 8/11/13 6:18 PM, "Aódar Aliev" <[log in to unmask]">[log in to unmask]> wrote:
I'm relatively new to mason as well as agent based modelling in general, and have been stuck with this problem for 2 days.
I need my agents to exchange IntBags with each other.
Within each agent I have a Bag called population which contains a set of IntBags. Each N steps I want my agents to find their closest neighbours and get certain number of IntBags from them.
My problem is that, while my agents are able to get IntBags obtaining copies of neighbouring ilk agents using map.getNeighboursExactlyWithinDistance(), I couldn't find a way to remove IntBags agent obtained from the source agent population.
Can anyone advice on how to do it?
Thank you in advance.