Discussion:
[jade-develop] Creation of multiple agents in multiple container
Chaitanya Deshpande
2014-01-23 15:40:42 UTC
Permalink
Hi,

I want to create clones of agents in multiple containers. How can I do it using instances of agent classes?

Thanks!!
/Chaitanya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://avalon.cselt.it/pipermail/jade-develop/attachments/20140123/af29e747/attachment.html>
Caire Giovanni
2014-01-24 09:24:46 UTC
Permalink
Hi,

Question: do you just want to create many instances of a given agent class or you actually want to create clones of an already running agent (i.e. new instances of the same class that at the time of their creation have exactly the same internal state of the original agent). Jade supports both options, but, of course, you have to do different things.

Bye,

Giovanni

Da: jade-develop-bounces at avalon.tilab.com [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di Chaitanya Deshpande
Inviato: gioved? 23 gennaio 2014 16:41
A: jade-develop at avalon.tilab.com
Oggetto: [jade-develop] Creation of multiple agents in multiple container

Hi,

I want to create clones of agents in multiple containers. How can I do it using instances of agent classes?

Thanks!!
/Chaitanya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://avalon.cselt.it/pipermail/jade-develop/attachments/20140124/ee4b2bd7/attachment.html>
Caire Giovanni
2014-01-25 15:50:18 UTC
Permalink
Hi,

Your agent can clone himself by calling the doClone() of the Agent class as below
ContainerID cid = new ContainerID("Container-1", null);
String cloneName = getLocalName()+"_Clone1";
doClone(cid, cloneName);

To create many clones you can do something like that (how to initialize the locations variable is up to you):

private String originalAgentName;
private List<ContainerID> locations;

public void setup() {
originalAgentName = getLocalName();
...
}


// somewhere in your code
final Iterator<ContainerID> = locations.iterator();
addBehaviour(new Behaviour(null) {
public void action() {
if (getLocalName().equals(originalAgentName)) {
// I'm the original agent
if (it.hasNext()) {
ContainerID destination = it.next();
String newName = "clone-on-"+destination.getName();
doClone(destination, newName);
}
}
}

public Boolean done() {
return !it.hasNext();
}
} );

Pay attention that in ordet to be clonable your agent must be fully Serializable.

Bye,

Giovanni

Da: Chaitanya Deshpande [mailto:cdes at kth.se]
Inviato: venerd? 24 gennaio 2014 10:42
A: Caire Giovanni
Oggetto: RE: Creation of multiple agents in multiple container

Hi Giovanni,

Thanks for your reply.

I want to create clones of agents already running in the main container, in other non-main containers.

Regards
/Chaitanya


From: Caire Giovanni [giovanni.caire at telecomitalia.it]
Sent: Friday, January 24, 2014 10:24 AM
To: Chaitanya Deshpande; jade-develop at avalon.tilab.com
Subject: R: Creation of multiple agents in multiple container
Hi,

Question: do you just want to create many instances of a given agent class or you actually want to create clones of an already running agent (i.e. new instances of the same class that at the time of their creation have exactly the same internal state of the original agent). Jade supports both options, but, of course, you have to do different things.

Bye,

Giovanni

Da: jade-develop-bounces at avalon.tilab.com [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di Chaitanya Deshpande
Inviato: gioved? 23 gennaio 2014 16:41
A: jade-develop at avalon.tilab.com
Oggetto: [jade-develop] Creation of multiple agents in multiple container

Hi,

I want to create clones of agents in multiple containers. How can I do it using instances of agent classes?

Thanks!!
/Chaitanya
Questo messaggio e i suoi allegati sono indirizzati esclusivamente alle persone indicate. La diffusione, copia o qualsiasi altra azione derivante dalla conoscenza di queste informazioni sono rigorosamente vietate. Qualora abbiate ricevuto questo documento per errore siete cortesemente pregati di darne immediata comunicazione al mittente e di provvedere alla sua distruzione, Grazie.

This e-mail and any attachments is confidential and may contain privileged information intended for the addressee(s) only. Dissemination, copying, printing or use by anybody else is unauthorised. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail, Thanks.
[cid:image001.gif at 01CF19EB.D01BDE50]Rispetta l'ambiente. Non stampare questa mail se non ? necessario.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://avalon.cselt.it/pipermail/jade-develop/attachments/20140125/3dc010f5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 677 bytes
Desc: image001.gif
URL: <http://avalon.cselt.it/pipermail/jade-develop/attachments/20140125/3dc010f5/attachment.gif>
Loading...