IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Programmation par agent Java Discussion :

Les Behaviours dans JADE [Tutoriel]


Sujet :

Programmation par agent Java

  1. #1
    Expert éminent sénior

    Avatar de Djug
    Homme Profil pro
    Inscrit en
    Mai 2007
    Messages
    2 980
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Algérie

    Informations forums :
    Inscription : Mai 2007
    Messages : 2 980
    Points : 17 970
    Points
    17 970
    Par défaut Les Behaviours dans JADE
    Bonjour,

    voici un article sur les Behaviours (Comportements) des agents JADE

    http://djug.developpez.com/java/jade/behaviours/


    vos remarques sont les bienvenues.

  2. #2
    Candidat au Club
    Inscrit en
    Octobre 2007
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Octobre 2007
    Messages : 2
    Points : 2
    Points
    2
    Par défaut cool
    Merci bcp.

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    158
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 158
    Points : 72
    Points
    72

  4. #4
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 16
    Points : 18
    Points
    18
    Par défaut
    Bonjour,

    j'ai quelques soucis quand à la prise en main des behaviour :

    ceux ci sont censé pouvoir "controler" un agent.
    Mais comment sont ils sensé être utilisés ?

    J'ai une classe Explorer (mon behaviour) et une classe Robot (mon agent)
    comment je dois faire pour que mon agent puisse utiliser le behaviour explorer et surtout comment écrire le behaviour pour que le robot puisse être contrôler ?

    je veux que mon robot, qui possède des attribut x et y, se déplace de manière aléatoire (via le behaviour)
    un peu de code pour illustré :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    public class MiningRobot {
    	int id;
    	int x;
    	int y;
    ... get setter ...
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    public class Explore extends Behaviour {
     
    	@Override
    	public void action() {
    		int xrand = (int) (Math.random() * 3) - 1;
    		int yrand = (int) (Math.random() * 3) - 1;
     
    		... ICI je veut controler mon robot en lui faisant robot.setX(robot.getX + xrand) ...
    	}
     
    	@Override
    	public boolean done() {
    		// TODO Auto-generated method stub
    		return false;
    	}
    c'est peut être une erreur de ma part quand à l'architecture et l'utilisation des behaviour.

    Bonne journée

  5. #5
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 16
    Points : 18
    Points
    18
    Par défaut
    auto résolu,
    il suffit de mettre l'agent en paramètre du behaviour.
    bonne journée

  6. #6
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Août 2011
    Messages : 16
    Points : 18
    Points
    18
    Par défaut
    petite précision :

    les behaviour comportent déjà un paramètre agent.
    lors de l'ajout d'un behaviour à un agent, il suffit de faire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     addBehaviour(new MySimpleBehaviour(this));

  7. #7
    Candidat au Club
    Femme Profil pro
    Chercheur en informatique
    Inscrit en
    Avril 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2012
    Messages : 2
    Points : 3
    Points
    3
    Par défaut
    Bonsoir Djug;
    je suis nouvelle dans ce forum et j'ai vraiment besoin de ton aide car je suis débutante en jade et je dois l'apprendre dans une période très courte.
    voilà je suis en train de travailler sur jade et j'ai rencontré ce problème voilà mon code:tout d'abord je travaille sur 3 agents voilà le code au niveau de l'agent interface:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    package syst_multi_agent;
    import java.io.BufferedReader;
    import java.util.ArrayList;
    import java.util.Arrays;
     
    import java.util.*;
     
    import java.io.IOException;
    import java.io.InputStreamReader;
    import jade.core.AID;
    import jade.core.Agent;
    import jade.core.ProfileImpl;
    import jade.core.Runtime;
    import jade.core.behaviours.CyclicBehaviour;
    import jade.core.behaviours.FSMBehaviour;
    import jade.core.behaviours.OneShotBehaviour;
    import jade.domain.DFService;
    import jade.domain.FIPAAgentManagement.DFAgentDescription;
    import jade.lang.acl.ACLMessage;
    import jade.lang.acl.MessageTemplate;
    import jade.wrapper.AgentContainer;
    import jade.wrapper.AgentController;
     
    public class Interface_agent extends Agent{
    	int ress_oper[][] = {{1,1,0,8,0},{1,2,0,8,0},{1,3,0,6,0},{2,1,12,2,0},{2,2,0,3,10},{2,3,11,0,10},{3,1,12,0,12},{3,2,4,0,12},{3,3,12,0,10}};
    	int op_phero [][] = {{1,1,0,1,0},{1,2,0,1,0},{1,3,0,1,0},{2,1,1,1,0},{2,2,0,1,1},{2,3,1,0,1},{3,1,1,0,1},{3,2,1,0,1},{3,3,1,0,1}};
    	int i=1 ,k=0, nbre_oper =9 ; 
    	int nbre_job =3;
     
    	public Interface_agent(){
     
    		System.out.println("---------------------------------------");
    		  System.out.println("----------------agent Interface----------------");
    		  System.out.println("---------------------------------------");
     
    		  FSMBehaviour agentA_beh= new FSMBehaviour();
     
    		  agentA_beh.registerFirstState(new creation_agents(), "creation_agents");
    		  agentA_beh.registerState(new envoie_op_jobs(), "envoie_op_jobs");
    		  agentA_beh.registerState(new envoie_op_phero(), "envoie_op_phero");
    		  agentA_beh.registerState(new attendre_rep_Agent_Job(), "attendre_rep_Agent_Job");
    		  agentA_beh.registerState(new rep_Agent_Job(), "rep_Agent_Job");
     
    		  agentA_beh.registerLastState(new fin(), "fin");
     
    		  agentA_beh.registerDefaultTransition("creation_agents", "envoie_op_jobs");
     
    		  agentA_beh.registerTransition("envoie_op_jobs", "rep_Agent_Job",1);
    		  agentA_beh.registerTransition("rep_Agent_Job", "attendre_rep_Agent_Job",0);
    		  agentA_beh.registerTransition("attendre_rep_Agent_Job", "rep_Agent_Job",0);
    		  agentA_beh.registerTransition("rep_Agent_Job", "envoie_op_phero",1);
    		  agentA_beh.registerTransition("envoie_op_phero", "attendre_rep_Agent_Job",0);
    	      agentA_beh.registerTransition("attendre_rep_Agent_Job", "fin",1);
     
    		  addBehaviour(agentA_beh);
     
     
    	}
    	public class fin extends OneShotBehaviour{
     
    		  @Override
    		  public void action()
    		  {
    		    System.out.println("arret de l'agent interface");
    		    myAgent.doDelete();  
    		  }  
    		}
    	public class creation_agents extends OneShotBehaviour
    	{
    		int valeur =0;
     
    		  public void action() {
     
    	   for (i=1;i<=3;i++)
    	{ 
     
    		try {
    			 Runtime rt = Runtime.instance();
    				ProfileImpl p = new ProfileImpl(false);
    				AgentContainer container =rt.createAgentContainer(p);
     
     
    	            AgentController Agent=null;		
    	            AgentController Agent_ress=null;	
     
     
     
    	        Agent = container.createNewAgent("Job"+i, "syst_multi_agent.Job_agent", null);
    	     	Agent.start();	
    	     	Agent_ress = container.createNewAgent("Ressource"+i, "syst_multi_agent.Ressource_agent", null);
    		    Agent_ress.start();	
    		    System.out.println("agents jobs et ressources sont crées");
     
    	} catch (Exception any) {
    		any.printStackTrace();}
    		//block();
     
    	}
     
     
    		  }
     
    		  public int onEnd(){
    			  return valeur;   
    			  }
    	}
    	           public class envoie_op_jobs extends OneShotBehaviour
    	           {  int val=0;
     
    	        	   public void action()
    	        	   { int j;
    	        	      int t;
     
    	        	      int i;
    	        	         for( i=1; i<=3;i++)
    	        		  {   int x=0;
    	        			 int[][] op_job = new int [3][5];
    	        		     System.out.println("Les opérations du job"+i+"sont");
    	        		      while(x<3)
    	        		      {
    	        		    	  for(j=0; j<nbre_oper;j++)
     
    	        			     {  
    	        		    	   if (ress_oper[j][0]==i)
    	        			        {
    	        				      for( t=0; t<5;t++)
    	        				        { op_job[x][t]= ress_oper[j][t];
    	        				          System.out.println(+op_job[x][t]);
    	        				        }   
    	        				             x=x+1;
    	        				            System.out.println("***************");
     
     
     
    	        				     }
    	        			     }
     
     
    	        			  }
     
    	        		       ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    						   message.addReceiver(new AID("Job"+i, AID.ISLOCALNAME));
    						   try {
    								 message.setContentObject((Object[])op_job);
    								 send(message);
    								 val =1;
    								 System.out.println("send the message");
    								  }catch (IOException e) {
     
    										e.printStackTrace();
    								  }
     
     
     
    	        		 }
     
    	        		}
    	        	   public int onEnd()
    					     {
    						  return val;   
    						  } 
     
    	           }
     
     
     
    				  public class attendre_rep_Agent_Job extends OneShotBehaviour
    					  {  int valeu =0;
     
    					  @Override
    					  public void action()
    					  {
    					  System.out.println("en Attente d'un message de l'agent Job");
     
    					  }  
     
    					  public int onEnd()
    					      {
    						  return valeu;   
    						  } 
    					  }
    				  public class rep_Agent_Job extends CyclicBehaviour
    				  {  int val2=0;
    					  public void action()
    					  { ACLMessage msg = receive(MessageTemplate.MatchPerformative(ACLMessage.INFORM));
    						if (msg != null) {				
    							try {
    								if (msg.getContent().equalsIgnoreCase(" !!!!Donnez moi le tableau de phéromone!!!! ") )
    								{     
    									  System.out.println("message envoyé de "+getLocalName()+" vers "+msg.getSender().getLocalName()+" est bien reçu");
     
    							          val2 =1;
     
    							    }
    							 }catch (Exception e) {
     
    								e.printStackTrace();
    						  }
     
     
     
    					  }
     
    				  }
     
    					  public int onEnd()
    				      {
    					  return val2;   
    					  } 
     
    				  }
    				  public class envoie_op_phero extends OneShotBehaviour
    		           {  int val3=0;
     
    		        	   public void action()
    		        	   { int j;
    		        	      int t;
     
    		        	      int i;
    		        	         for( i=1; i<=3;i++)
    		        		  {   int x=0;
    		        			 int[][] qt_phero = new int [3][5];
    		        		     System.out.println("Les quantité de phéromones du job"+i+"sont");
    		        		      while(x<3)
    		        		      {
    		        		    	  for(j=0; j<nbre_oper;j++)
     
    		        			     {  
    		        		    	   if (op_phero[j][0]==i)
    		        			        {
    		        				      for( t=0; t<5;t++)
    		        				        { qt_phero[x][t]= op_phero[j][t];
    		        				          System.out.println(+qt_phero[x][t]);
    		        				           //System.out.println("***************");
    		        				        }   
    		        				             x=x+1;
    		        				            System.out.println("***************");
     
     
     
    		        				     }
    		        			     }
     
     
    		        			  }
     
    		        		       ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    							   message.addReceiver(new AID("Job"+i, AID.ISLOCALNAME));
    							   try {
    									 message.setContentObject((Object[])qt_phero);
    									 send(message);
    									 val3 =1;
    									  }catch (IOException e) {
     
    											e.printStackTrace();
    									  }
     
     
     
    		        		 }
     
    		        		}
    		        	   public int onEnd()
    						     {
    							  return val3;   
    							  } 
     
    		           }
     
    }






    et au niveau de l'agent job le code est:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    package syst_multi_agent;
    import jade.core.Agent;
    import jade.core.behaviours.CyclicBehaviour;
    import jade.core.behaviours.FSMBehaviour;
    import jade.core.behaviours.OneShotBehaviour;
    import jade.lang.acl.ACLMessage;
    import jade.lang.acl.MessageTemplate;
     
    public class Job_agent extends Agent {
    	int op_job[][]= new int [3][5];
    	int qt_pheromone[][]= new int [3][5];
    	public Job_agent() 
    	{
    	  System.out.println("---------------------------------------");
    	  System.out.println("----------------agent Job----------------");
    	  System.out.println("---------------------------------------");
    	  FSMBehaviour agentjob_beh= new FSMBehaviour();
     
    	  agentjob_beh.registerFirstState(new attendreAgent_interface(), "attendreAgent_interface");
    	  agentjob_beh.registerState(new envoie_Agent_interface(), "envoie_Agent_interface");
    	  agentjob_beh.registerState(new Reception_qt_phero(), "Reception_qt_phero");
    	  agentjob_beh.registerLastState(new fin_job(), "fin_job");
    	  agentjob_beh.registerDefaultTransition("attendreAgent_interface", "envoie_Agent_interface");
    	  agentjob_beh.registerTransition("envoie_Agent_interface", "attendreAgent_interface",1);
    	  agentjob_beh.registerTransition("attendreAgent_interface", "Reception_qt_phero",1);
    	  agentjob_beh.registerTransition("Reception_qt_phero", "attendreAgent_interface",0);
    	  agentjob_beh.registerTransition("attendreAgent_interface", "fin_job",1);
     
    	  addBehaviour(agentjob_beh); 
    	}
    	  public class attendreAgent_interface extends OneShotBehaviour
    	  { 
     
    		  @Override
    		  public void action() {
     
    		  System.out.println("agent job est en Attente de l agent Interface  "); 
     
    		  block();
    		  }
     
    		}
     
    	  public class envoie_Agent_interface extends CyclicBehaviour
    	  {  int val_retour=0;
    		  public void action()
    		  {
    			  ACLMessage msg = receive();
    				if (msg != null) {				
    					try {
     
    							 op_job = (int[][]) msg.getContentObject();
    							 System.out.println("le message est bien reçu ");
    							  for(int i=0;i<3;i++)
    							  {  for(int j=0;j<5;j++)
    								  System.out.println(+op_job[i][j]);
    							  }
     
     
    						}catch (Exception e) {
    							e.printStackTrace();}
    					  ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    					  message.addReceiver(msg.getSender());
    					  message.setContent(" !!!!Donnez moi le tableau de phéromone!!!! ");  
    					  send(message);
    					  System.out.println("message envoyer de "+getLocalName()+" vers agent interface contient: "+message.getContent().toString());
    					  val_retour=1;
    		  }
     
    		  }
     
    		  public int onEnd(){
    			  return  val_retour;   
    			  }
    	  }
    	  public class Reception_qt_phero extends CyclicBehaviour
    	  {  int val_retour=0;
    		  public void action()
    		  {
    			  ACLMessage msg = receive(MessageTemplate.MatchPerformative(ACLMessage.INFORM));
    				if (msg != null) {				
    					try {
     
    						     qt_pheromone = (int[][]) msg.getContentObject();
    							 System.out.println("qt de pheromone reçu ");
    							  for(int i=0;i<3;i++)
    							  {  for(int j=0;j<5;j++)
    								  System.out.println(+qt_pheromone[i][j]);
     
    							  }
    							  val_retour=1;
     
    						}catch (Exception e) {
    							e.printStackTrace();}
     
    		  }
     
    		  }
     
    		  public int onEnd(){
    			  return  val_retour;   
    			  }
    	  }
    	  public class fin_job extends OneShotBehaviour{
     
    		  @Override
    		  public void action() {
    		  System.out.println("arret de l'agent job");
    		 myAgent.doDelete();  
    		  }  
    		}
    }

    et voilà l'exécution:

    mai 18, 2012 9:26:04 PM jade.core.Runtime beginContainer
    Infos: ----------------------------------
    This is JADE snapshot - revision $WCREV$ of $WCDATE$
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
    ----------------------------------------
    mai 18, 2012 9:26:05 PM jade.core.BaseService init
    Infos: Service jade.core.management.AgentManagement initialized
    mai 18, 2012 9:26:05 PM jade.core.BaseService init
    Infos: Service jade.core.messaging.Messaging initialized
    mai 18, 2012 9:26:05 PM jade.core.BaseService init
    Infos: Service jade.core.mobility.AgentMobility initialized
    mai 18, 2012 9:26:05 PM jade.core.BaseService init
    Infos: Service jade.core.event.Notification initialized
    mai 18, 2012 9:26:05 PM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 18, 2012 9:26:05 PM jade.mtp.http.HTTPServer <init>
    Infos: HTTP-MTP Using XML parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
    mai 18, 2012 9:26:05 PM jade.core.messaging.MessagingService boot
    Infos: MTP addresses:
    http://Nesrine-PC.lan:7778/acc
    ---------------------------------------
    ----------------agent Interface----------------
    ---------------------------------------
    mai 18, 2012 9:26:05 PM jade.core.AgentContainerImpl joinPlatform
    Infos: --------------------------------------
    Agent container Main-Container@Nesrine-PC is ready.
    --------------------------------------------
    mai 18, 2012 9:26:05 PM jade.core.Runtime beginContainer
    Infos: ----------------------------------
    This is JADE snapshot - revision $WCREV$ of $WCDATE$
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
    ----------------------------------------
    mai 18, 2012 9:26:05 PM jade.core.BaseService init
    Infos: Service jade.core.management.AgentManagement initialized
    mai 18, 2012 9:26:05 PM jade.core.BaseService init
    Infos: Service jade.core.messaging.Messaging initialized
    mai 18, 2012 9:26:05 PM jade.core.BaseService init
    Infos: Service jade.core.mobility.AgentMobility initialized
    mai 18, 2012 9:26:05 PM jade.core.BaseService init
    Infos: Service jade.core.event.Notification initialized
    mai 18, 2012 9:26:05 PM jade.core.PlatformManagerImpl localAddNode
    Infos: Adding node <Container-1> to the platform
    mai 18, 2012 9:26:05 PM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 18, 2012 9:26:05 PM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 18, 2012 9:26:06 PM jade.core.AgentContainerImpl joinPlatform
    Infos: --------------------------------------
    Agent container Container-1@Nesrine-PC is ready.
    --------------------------------------------
    ---------------------------------------
    ----------------agent Job----------------
    ---------------------------------------
    mai 18, 2012 9:26:06 PM jade.core.Runtime beginContainer
    Infos: ----------------------------------
    This is JADE snapshot - revision $WCREV$ of $WCDATE$
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
    ----------------------------------------
    ---------------------------------------
    ----------------agent Ressources---------------
    ---------------------------------------
    agents jobs et ressources sont crées
    mai 18, 2012 9:26:06 PM jade.core.PlatformManagerImpl$1 nodeAdded
    Infos: --- Node <Container-1> ALIVE ---
    mai 18, 2012 9:26:06 PM jade.core.BaseService init
    Infos: Service jade.core.management.AgentManagement initialized
    mai 18, 2012 9:26:06 PM jade.core.BaseService init
    Infos: Service jade.core.messaging.Messaging initialized
    mai 18, 2012 9:26:06 PM jade.core.BaseService init
    Infos: Service jade.core.mobility.AgentMobility initialized
    mai 18, 2012 9:26:06 PM jade.core.BaseService init
    Infos: Service jade.core.event.Notification initialized
    mai 18, 2012 9:26:06 PM jade.core.PlatformManagerImpl localAddNode
    Infos: Adding node <Container-2> to the platform
    mai 18, 2012 9:26:06 PM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    agent job est en Attente de l agent Interface
    mai 18, 2012 9:26:06 PM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 18, 2012 9:26:06 PM jade.core.AgentContainerImpl joinPlatform
    Infos: --------------------------------------
    Agent container Container-2@Nesrine-PC is ready.
    --------------------------------------------
    ---------------------------------------
    ----------------agent Job----------------
    ---------------------------------------
    ---------------------------------------
    ----------------agent Ressources---------------
    ---------------------------------------
    mai 18, 2012 9:26:06 PM jade.core.PlatformManagerImpl$1 nodeAdded
    Infos: --- Node <Container-2> ALIVE ---
    agent job est en Attente de l agent Interface
    agents jobs et ressources sont crées
    mai 18, 2012 9:26:06 PM jade.core.Runtime beginContainer
    Infos: ----------------------------------
    This is JADE snapshot - revision $WCREV$ of $WCDATE$
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
    ----------------------------------------
    mai 18, 2012 9:26:06 PM jade.core.BaseService init
    Infos: Service jade.core.management.AgentManagement initialized
    mai 18, 2012 9:26:06 PM jade.core.BaseService init
    Infos: Service jade.core.messaging.Messaging initialized
    mai 18, 2012 9:26:06 PM jade.core.BaseService init
    Infos: Service jade.core.mobility.AgentMobility initialized
    mai 18, 2012 9:26:06 PM jade.core.BaseService init
    Infos: Service jade.core.event.Notification initialized
    mai 18, 2012 9:26:06 PM jade.core.PlatformManagerImpl localAddNode
    Infos: Adding node <Container-3> to the platform
    mai 18, 2012 9:26:06 PM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 18, 2012 9:26:06 PM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 18, 2012 9:26:06 PM jade.core.AgentContainerImpl joinPlatform
    Infos: --------------------------------------
    Agent container Container-3@Nesrine-PC is ready.
    --------------------------------------------
    ---------------------------------------
    ----------------agent Job----------------
    ---------------------------------------
    ---------------------------------------
    ----------------agent Ressources---------------
    ---------------------------------------
    agents jobs et ressources sont crées
    mai 18, 2012 9:26:06 PM jade.core.PlatformManagerImpl$1 nodeAdded
    Infos: --- Node <Container-3> ALIVE ---
    Les opérations du job1sont
    1
    1
    0
    8
    0
    ***************
    1
    2
    0
    8
    0
    ***************
    1
    3
    0
    6
    0
    ***************
    send the message
    Les opérations du job2sont
    2
    1
    12
    2
    0
    ***************
    2
    2
    0
    3
    10
    ***************
    2
    3
    11
    0
    10
    ***************
    send the message
    Les opérations du job3sont
    3
    1
    12
    0
    12
    ***************
    3
    2
    4
    0
    12
    ***************
    3
    3
    12
    0
    10
    ***************
    send the message
    agent job est en Attente de l agent Interface
    le message est bien reçu
    3
    1
    12
    0
    12
    3
    2
    4
    0
    12
    3
    3
    12
    0
    10
    message envoyer de Job3 vers agent interface contient: !!!!Donnez moi le tableau de phéromone!!!!
    message envoyé de a vers Job3 est bien reçu
    le message est bien reçu
    1
    1
    0
    8
    0
    1
    2
    0
    8
    0
    1
    3
    0
    6
    0
    message envoyer de Job1 vers agent interface contient: !!!!Donnez moi le tableau de phéromone!!!!
    message envoyé de a vers Job1 est bien reçu
    le message est bien reçu
    2
    1
    12
    2
    0
    2
    2
    0
    3
    10
    2
    3
    11
    0
    10
    message envoyer de Job2 vers agent interface contient: !!!!Donnez moi le tableau de phéromone!!!!
    message envoyé de a vers Job2 est bien reçu
    le problème ici c'est que l'agent interface n'exécute pas la classe de envoie_op_phero() il se bloque au niveau rep_Agent_Job() et par la suite le msg de envoie_op_phero() ne peux pas arriver à l'agent job ... il se bloque dans rep_Agent_Job()... SVP c'est quoi le problème

  8. #8
    Expert éminent sénior

    Avatar de Djug
    Homme Profil pro
    Inscrit en
    Mai 2007
    Messages
    2 980
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Algérie

    Informations forums :
    Inscription : Mai 2007
    Messages : 2 980
    Points : 17 970
    Points
    17 970
    Par défaut
    Bonjour,
    Il ne me semble pas qu’il s’agit d’un problème au niveau du code jade, il suffit juste de revoir ton automate d’états finis, et vérifier que ton agent peut bien exécuter ses différents états.

  9. #9
    Candidat au Club
    Femme Profil pro
    Chercheur en informatique
    Inscrit en
    Avril 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2012
    Messages : 2
    Points : 3
    Points
    3
    Par défaut
    Bonjour Djug

    j'ai essayé de changer l'automate. J'ai vérifié qu'il est correcte mais j'ai le même problème l'exécution n'est pas complète elle se bloque au niveau de l'agent job et les messages de communications ne terminent pas à passer. Un autre problème: j'ai crée 3 agents jobs à partir de l'agent interface mais au niveau de l'exécution parfois il m'exécute 2 agents jobs seulement parfois 3 agents. SVP Djug essayez de m'aider car j'avais 4 jours bloqué à ce niveau et je ne peux pas terminer de faire les autres messages et les autres tâches sans la résolution de ce problème et je dois terminer le projet dans un temps limité. J'attends votre réponse merciii.
    Voici le code au niveau de l'agent interface:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    package syst_multi_agent;
    import java.io.BufferedReader;
    import java.util.ArrayList;
    import java.util.Arrays;
     
    import java.util.*;
     
    import java.io.IOException;
    import java.io.InputStreamReader;
    import jade.core.AID;
    import jade.core.Agent;
    import jade.core.ProfileImpl;
    import jade.core.Runtime;
    import jade.core.behaviours.CyclicBehaviour;
    import jade.core.behaviours.FSMBehaviour;
    import jade.core.behaviours.OneShotBehaviour;
    import jade.domain.DFService;
    import jade.domain.FIPAAgentManagement.DFAgentDescription;
    import jade.lang.acl.ACLMessage;
    import jade.lang.acl.MessageTemplate;
    import jade.wrapper.AgentContainer;
    import jade.wrapper.AgentController;
     
    public class Interface_agent extends Agent{
    	int ress_oper[][] = {{1,1,0,8,0},{1,2,0,8,0},{1,3,0,6,0},{2,1,12,2,0},{2,2,0,3,10},{2,3,11,0,10},{3,1,12,0,12},{3,2,4,0,12},{3,3,12,0,10}};
    	int op_phero [][] = {{1,1,0,1,0},{1,2,0,1,0},{1,3,0,1,0},{2,1,1,1,0},{2,2,0,1,1},{2,3,1,0,1},{3,1,1,0,1},{3,2,1,0,1},{3,3,1,0,1}};
    	int i=1 ,k=0, nbre_oper =9 ; 
    	int nbre_job =3;
    	public int[][] op_job = new int [3][5];
     
    	public Interface_agent(){
     
    		System.out.println("---------------------------------------");
    		  System.out.println("----------------agent Interface----------------");
    		  System.out.println("---------------------------------------");
     
    		  FSMBehaviour agentA_beh= new FSMBehaviour();
     
    		  agentA_beh.registerFirstState(new creation_agents(), "creation_agents");
    		  agentA_beh.registerState(new envoie_op_jobs(), "envoie_op_jobs");
    		  agentA_beh.registerState(new attendre_fin(), "attendre_fin");
    		  agentA_beh.registerState(new attendre_rep_Agent_Job(), "attendre_rep_Agent_Job");
    		  agentA_beh.registerState(new rep_Agent_Job(), "rep_Agent_Job");
    		  agentA_beh.registerState(new Attente_job(), "Attente_job");
    		  agentA_beh.registerLastState(new fin(), "fin");
     
    		  agentA_beh.registerDefaultTransition("creation_agents", "envoie_op_jobs");
     
    		  agentA_beh.registerTransition("envoie_op_jobs", "rep_Agent_Job",1);
    		  agentA_beh.registerTransition("rep_Agent_Job", "attendre_rep_Agent_Job",0);
    		  agentA_beh.registerTransition("attendre_rep_Agent_Job", "rep_Agent_Job",0);
    		  agentA_beh.registerTransition("rep_Agent_Job", "Attente_job",1);
    		  agentA_beh.registerTransition("Attente_job", "attendre_fin",0);
    		  agentA_beh.registerTransition("attendre_fin", "Attente_job",0);
    	      agentA_beh.registerTransition("Attente_job", "fin",1);
     
    		  addBehaviour(agentA_beh);
     
     
    	}
    	public class fin extends OneShotBehaviour{
     
    		  @Override
    		  public void action()
    		  {
    		    System.out.println("arret de l'agent interface");
    		    //myAgent.doDelete();  
    		  }  
    		}
    	public class creation_agents extends OneShotBehaviour
    	{
    		int valeur =0;
     
    		  public void action() {
     
    	   for (i=1;i<=3;i++)
    	{ 
     
    		try {
    			 Runtime rt = Runtime.instance();
    				ProfileImpl p = new ProfileImpl(false);
    				AgentContainer container =rt.createAgentContainer(p);
     
     
    	            AgentController Agent=null;		
    	            AgentController Agent_ress=null;	
     
     
     
    	        Agent = container.createNewAgent("Job"+i, "syst_multi_agent.Job_agent", null);
    	     	Agent.start();	
    	     	Agent_ress = container.createNewAgent("Ressource"+i, "syst_multi_agent.Ressource_agent", null);
    		    Agent_ress.start();	
    		    System.out.println("agents jobs et ressources sont crées");
     
    	} catch (Exception any) {
    		any.printStackTrace();}
    		//block();
     
    	}
     
     
    		  }
     
    		  public int onEnd(){
    			  return valeur;   
    			  }
    	}
    	           public class envoie_op_jobs extends OneShotBehaviour
    	           {  int val=0;
     
    	        	   public void action()
    	        	   { int j;
    	        	      int t;
     
    	        	      int i;
    	        	         for( i=1; i<=3;i++)
    	        		  {   int x=0;
     
    	        		     System.out.println("Les opérations du job"+i+"sont");
    	        		      while(x<3)
    	        		      {
    	        		    	  for(j=0; j<nbre_oper;j++)
     
    	        			     {  
    	        		    	   if (ress_oper[j][0]==i)
    	        			        {
    	        				      for( t=0; t<5;t++)
    	        				        { op_job[x][t]= ress_oper[j][t];
    	        				          System.out.println(+op_job[x][t]);
    	        				        }   
    	        				             x=x+1;
    	        				            System.out.println("***************");
     
     
     
    	        				     }
    	        			     }
     
     
    	        			  }
     
    	        		       ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    						   message.addReceiver(new AID("Job"+i, AID.ISLOCALNAME));
    						   try {
    								 message.setContentObject((Object[])op_job);
    								 send(message);
    								 val =1;
    								 System.out.println("send the message");
    								  }catch (IOException e) {
     
    										e.printStackTrace();
    								  }
     
     
     
    	        		 }
     
    	        		}
    	        	   public int onEnd()
    					     {
    						  return val;   
    						  } 
     
    	           }
     
     
     
    				  public class attendre_rep_Agent_Job extends OneShotBehaviour
    					  {  int valeu =0;
     
    					  @Override
    					  public void action()
    					  {
    					  System.out.println("en Attente d'un message de l'agent Job");
    					  block();
     
    					  }  
     
    					  public int onEnd()
    					      {
    						  return valeu;   
    						  } 
    					  }
    				  public class rep_Agent_Job extends CyclicBehaviour
    				  {  int val2=0;
    				     int z;
     
    					  public void action()
    					  { ACLMessage msg = receive(MessageTemplate.MatchPerformative(ACLMessage.INFORM));
    						if (msg != null) {				
    							try 
    							{
    								  if (msg.getContent().equalsIgnoreCase(" !!!!Donnez moi le tableau de phéromone!!!! ") )
    								   {     
    									  System.out.println("message envoyé de "+getLocalName()+" vers "+msg.getSender().getLocalName()+" est bien reçu");
     
    									  if(msg.getSender().getLocalName().toString().equalsIgnoreCase("Job1"))
    									  { System.out.println("Bravoooooooo 1");
    									       z=1;
    									  }
    									  else
     
    										  if(msg.getSender().getLocalName().toString().equalsIgnoreCase("Job2"))
    										  { System.out.println("Bravoooooooo 2");
    										         z=2;
    										  }
    									     else
    										     if(msg.getSender().getLocalName().toString().equalsIgnoreCase("Job3"))
    										     { System.out.println("Bravoooooooo 3");
    									               z=3;
    										     }
     
    									  int x=0;
    					        			 int[][] qt_phero = new int [3][5];
    					        		     System.out.println("Les quantité de phéromones du job"+z+"sont");
    					        		      while(x<3)
    					        		      {
    					        		    	  for(int j=0; j<nbre_oper;j++)
     
    					        			     {  
    					        		    	   if (op_phero[j][0]==z)
    					        			        {
    					        				      for(int t=0; t<5;t++)
    					        				        { qt_phero[x][t]= op_phero[j][t];
    					        				          System.out.println(+qt_phero[x][t]);
    					        				           //System.out.println("***************");
    					        				        }   
    					        				             x=x+1;
    					        				            System.out.println("^^^^^^^^^^^^^^^^^^^^");
     
     
     
    					        				     }
    					        			     }
     
     
    					        			  }
     
    					        		       ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    										   message.addReceiver(new AID("Job"+z, AID.ISLOCALNAME));
    										   message.setContentObject((Object[])qt_phero);
    												 send(message);
    												 val2 =1;
     
     
     
     
    							      }
    							 }
    							catch (Exception e) {
     
    								e.printStackTrace();
    						  }
     
     
     
    					  }
     
    				  }
     
    					  public int onEnd()
    				      {
    					  return val2;   
    					  } 
     
    				  }
    				/*  public class envoie_op_phero extends OneShotBehaviour
    		           {  int val3=0;
     
    		        	   public void action()
    		        	   { int j;
    		        	      int t;
     
    		        	      int i;
    		        	         for( i=1; i<=3;i++)
    		        		  {   int x=0;
    		        			 int[][] qt_phero = new int [3][5];
    		        		     System.out.println("Les quantité de phéromones du job"+i+"sont");
    		        		      while(x<3)
    		        		      {
    		        		    	  for(j=0; j<nbre_oper;j++)
     
    		        			     {  
    		        		    	   if (op_phero[j][0]==i)
    		        			        {
    		        				      for( t=0; t<5;t++)
    		        				        { qt_phero[x][t]= op_phero[j][t];
    		        				          System.out.println(+qt_phero[x][t]);
    		        				           //System.out.println("***************");
    		        				        }   
    		        				             x=x+1;
    		        				            System.out.println("^^^^^^^^^^^^^^^^^^^^");
     
     
     
    		        				     }
    		        			     }
     
     
    		        			  }
     
    		        		       ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    							   message.addReceiver(new AID("Job"+i, AID.ISLOCALNAME));
    							   try {
    									 message.setContentObject((Object[])qt_phero);
    									 send(message);
    									 val3 =1;
    									  }catch (IOException e) {
     
    											e.printStackTrace();
    									  }
     
     
     
    		        		 }
     
    		        		}
    		        	   public int onEnd()
    						     {
    							  return val3;   
    							  } 
     
    		           }
    		           */
    				 public class Attente_job extends OneShotBehaviour{
    					  int valeur =0;
     
    					  		  @Override
    					  		  public void action() {
     
    					  			 ACLMessage msg = receive(MessageTemplate.MatchPerformative(ACLMessage.INFORM));
    									if (msg != null) {				
    										try { if (msg.getContent().equalsIgnoreCase(" ******************* c'est terminééééé ********************** ") )
    										      {
     
    													  System.out.println("c'est terminééééé");
    													  ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    													   message.addReceiver(msg.getSender());
    													   message.setContentObject("OK");
    															 send(message);
    													  valeur =1;
    										      }
     
    											}catch (Exception e) {
    												e.printStackTrace();}
     
    							  }
    					  		  }
     
    					  		  public int onEnd(){
    					  			  return valeur;   
    					  			  }  
    					  		}
     
    				  public class attendre_fin extends OneShotBehaviour
    					  {  int valeu =0;
     
    					  @Override
    					  public void action()
    					  {
    					  System.out.println("attendre_fin");
     
    					  }  
     
    					  public int onEnd()
    					      {
    						  return valeu;   
    						  } 
    					  }
     
    }
    et Voici le code au niveau de l'agent job:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    package syst_multi_agent;
    import jade.core.Agent;
    import jade.core.behaviours.CyclicBehaviour;
    import jade.core.behaviours.FSMBehaviour;
    import jade.core.behaviours.OneShotBehaviour;
    import jade.lang.acl.ACLMessage;
    import jade.lang.acl.MessageTemplate;
     
    public class Job_agent extends Agent {
    	int op_job[][]= new int [3][5];
    	int qt_pheromone[][]= new int [3][5];
    	public Job_agent() 
    	{
    	  System.out.println("---------------------------------------");
    	  System.out.println("----------------agent Job----------------");
    	  System.out.println("---------------------------------------");
    	  FSMBehaviour agentjob_beh= new FSMBehaviour();
     
    	  agentjob_beh.registerFirstState(new attendreAgent_interface(), "attendreAgent_interface");
    	  agentjob_beh.registerState(new envoie_Agent_interface(), "envoie_Agent_interface");
    	  agentjob_beh.registerState(new Reception_qt_phero(), "Reception_qt_phero");
    	  agentjob_beh.registerState(new en_attente(), "en_attente");
    	  agentjob_beh.registerState(new msg_reçu(), "msg_reçu");
    	  agentjob_beh.registerState(new attente(), "attente");
     agentjob_beh.registerLastState(new fin_job(), "fin_job");
     
     
    	  agentjob_beh.registerDefaultTransition("attendreAgent_interface", "envoie_Agent_interface");
    	  agentjob_beh.registerTransition("envoie_Agent_interface", "attendreAgent_interface",0);
    	  agentjob_beh.registerTransition("envoie_Agent_interface", "Reception_qt_phero",1);
    	  agentjob_beh.registerTransition("Reception_qt_phero", "en_attente",0);
    	  agentjob_beh.registerTransition("en_attente", "Reception_qt_phero",0);
    	  agentjob_beh.registerTransition("Reception_qt_phero", "msg_reçu",1);
    	  agentjob_beh.registerTransition("msg_reçu", "attente",0);
    	  agentjob_beh.registerTransition("attente", "msg_reçu",0);
    	  agentjob_beh.registerTransition("msg_reçu", "fin_job",1);
     
    	  addBehaviour(agentjob_beh); 
    	}
    	  public class attendreAgent_interface extends OneShotBehaviour
    	  { 
     
    		  @Override
    		  public void action() {
     
    		  System.out.println("agent job est en Attente de l agent Interface  "); 
     
    		  block();
    		  }
     
    		}
     
    	  public class envoie_Agent_interface extends OneShotBehaviour
    	  {  int val_retour=0;
    		  public void action()
    		  {
    			  ACLMessage msg = receive();
    				if (msg != null) {				
    					try
    					{
    						   op_job = (int[][]) msg.getContentObject();
    							 System.out.println("le message est bien reçu ");
    							  for(int i=0;i<3;i++)
    							  {  for(int j=0;j<5;j++)
    								  System.out.println(+op_job[i][j]);
    							  }
    							  ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    							  message.addReceiver(msg.getSender());
    							  message.setContent(" !!!!Donnez moi le tableau de phéromone!!!! ");  
    							  send(message);
    							  System.out.println("message envoyer de "+getLocalName()+" vers agent interface contient: "+message.getContent().toString());
    							  val_retour=1;
     
    						}catch (Exception e) {
    							e.printStackTrace();}
     
     
    		  }
     
    		  }
     
    		  public int onEnd(){
    			  return  val_retour;   
    			  }
    	  }
    	  public class Reception_qt_phero extends OneShotBehaviour
    	  {  int val_retour=0;
    		  public void action()
    		  {
    			  ACLMessage msg = receive(MessageTemplate.MatchPerformative(ACLMessage.INFORM));
    				if (msg != null) {				
    					try {
     
    						     qt_pheromone = (int[][]) msg.getContentObject();
    							 System.out.println("qt de pheromone reçu ");
    							  for(int i=0;i<3;i++)
    							  {  for(int j=0;j<5;j++)
    								  System.out.println(+qt_pheromone[i][j]);
     
    							  }
    							  ACLMessage message = new ACLMessage(ACLMessage.INFORM);
    							  message.addReceiver(msg.getSender());
    							  message.setContent(" ******************* c'est terminééééé ********************** ");  
    							  send(message);
    							  System.out.println("terminéééééé"+getLocalName());
    							  val_retour=1;
     
    						}catch (Exception e) {
    							e.printStackTrace();}
     
    		  }
     
    		  }
     
    		  public int onEnd(){
    			  return  val_retour;   
    			  }
    	  }
    	  public class fin_job extends OneShotBehaviour{
     
    		  @Override
    		  public void action() {
    		  System.out.println("arret de l'agent job");
    		 myAgent.doDelete();  
    		  }  
    		}
    	  public class en_attente extends OneShotBehaviour{
    		  int valeur =0;
     
    		  		  @Override
    		  		  public void action() {
     
     
     
    		  		  }
     
    		  		  public int onEnd(){
    		  			  return valeur;   
    		  			  }  
    		  		}
    	  		  }
    	  public class attente extends OneShotBehaviour{
    		  int valeur =0;
     
    		  		  @Override
    		  		  public void action() {
     
     
     
    		  		  }
     
    		  		  public int onEnd(){
    		  			  return valeur;   
    		  			  }  
    		  		}
    	  public class msg_reçu extends OneShotBehaviour
    	  {  int val_retour=0;
    		  public void action()
    		  {
    			  ACLMessage msg = receive(MessageTemplate.MatchPerformative(ACLMessage.INFORM));
    				if (msg != null) {				
    					try { if (msg.getContent().equalsIgnoreCase("OK") )
    					      {
     
    							 System.out.println("C'est bonnnnn");
     
    							  val_retour=1;
    					      }
     
    						}catch (Exception e) {
    							e.printStackTrace();}
     
    		  }
     
    		  }
     
    		  public int onEnd(){
    			  return  val_retour;   
    			  }
    	  }
     
     
     
    }
    Voilà l'exécution:
    mai 22, 2012 11:20:43 AM jade.core.Runtime beginContainer
    Infos: ----------------------------------
    This is JADE snapshot - revision $WCREV$ of $WCDATE$
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
    ----------------------------------------
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.management.AgentManagement initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.messaging.Messaging initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.mobility.AgentMobility initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.event.Notification initialized
    mai 22, 2012 11:20:44 AM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 22, 2012 11:20:44 AM jade.mtp.http.HTTPServer <init>
    Infos: HTTP-MTP Using XML parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
    mai 22, 2012 11:20:44 AM jade.core.messaging.MessagingService boot
    Infos: MTP addresses:
    http://Nesrine-PC.safe-protect.com:7778/acc
    mai 22, 2012 11:20:44 AM jade.core.AgentContainerImpl joinPlatform
    Infos: --------------------------------------
    Agent container Main-Container@Nesrine-PC is ready.
    --------------------------------------------
    ---------------------------------------
    ----------------agent Interface----------------
    ---------------------------------------
    mai 22, 2012 11:20:44 AM jade.core.Runtime beginContainer
    Infos: ----------------------------------
    This is JADE snapshot - revision $WCREV$ of $WCDATE$
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
    ----------------------------------------
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.management.AgentManagement initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.messaging.Messaging initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.mobility.AgentMobility initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.event.Notification initialized
    mai 22, 2012 11:20:44 AM jade.core.PlatformManagerImpl localAddNode
    Infos: Adding node <Container-1> to the platform
    mai 22, 2012 11:20:44 AM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 22, 2012 11:20:44 AM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 22, 2012 11:20:44 AM jade.core.AgentContainerImpl joinPlatform
    Infos: --------------------------------------
    Agent container Container-1@Nesrine-PC is ready.
    --------------------------------------------
    ---------------------------------------
    ----------------agent Job----------------
    ---------------------------------------
    mai 22, 2012 11:20:44 AM jade.core.PlatformManagerImpl$1 nodeAdded
    Infos: --- Node <Container-1> ALIVE ---
    ---------------------------------------
    ----------------agent Ressources---------------
    ---------------------------------------
    agents jobs et ressources sont crées
    agent job est en Attente de l agent Interface
    mai 22, 2012 11:20:44 AM jade.core.Runtime beginContainer
    Infos: ----------------------------------
    This is JADE snapshot - revision $WCREV$ of $WCDATE$
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
    ----------------------------------------
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.management.AgentManagement initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.messaging.Messaging initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.mobility.AgentMobility initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.event.Notification initialized
    mai 22, 2012 11:20:44 AM jade.core.PlatformManagerImpl localAddNode
    Infos: Adding node <Container-2> to the platform
    mai 22, 2012 11:20:44 AM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 22, 2012 11:20:44 AM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 22, 2012 11:20:44 AM jade.core.AgentContainerImpl joinPlatform
    Infos: --------------------------------------
    Agent container Container-2@Nesrine-PC is ready.
    --------------------------------------------
    ---------------------------------------
    ----------------agent Job----------------
    ---------------------------------------
    ---------------------------------------
    ----------------agent Ressources---------------
    ---------------------------------------
    agents jobs et ressources sont crées
    mai 22, 2012 11:20:44 AM jade.core.Runtime beginContainer
    Infos: ----------------------------------
    This is JADE snapshot - revision $WCREV$ of $WCDATE$
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
    ----------------------------------------
    mai 22, 2012 11:20:44 AM jade.core.PlatformManagerImpl$1 nodeAdded
    Infos: --- Node <Container-2> ALIVE ---
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.management.AgentManagement initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.messaging.Messaging initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.mobility.AgentMobility initialized
    mai 22, 2012 11:20:44 AM jade.core.BaseService init
    Infos: Service jade.core.event.Notification initialized
    ---------------------------------------
    ----------------agent Job----------------
    ---------------------------------------
    ---------------------------------------
    ----------------agent Ressources---------------
    ---------------------------------------
    agents jobs et ressources sont crées
    mai 22, 2012 11:20:44 AM jade.core.PlatformManagerImpl localAddNode
    Infos: Adding node <Container-3> to the platform
    mai 22, 2012 11:20:44 AM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 22, 2012 11:20:44 AM jade.core.messaging.MessagingService clearCachedSlice
    Infos: Clearing cache
    mai 22, 2012 11:20:44 AM jade.core.AgentContainerImpl joinPlatform
    Infos: --------------------------------------
    Agent container Container-3@Nesrine-PC is ready.
    --------------------------------------------
    mai 22, 2012 11:20:44 AM jade.core.PlatformManagerImpl$1 nodeAdded
    Infos: --- Node <Container-3> ALIVE ---
    Les opérations du job1sont
    1
    1
    0
    8
    0
    ***************
    1
    2
    0
    8
    0
    ***************
    1
    3
    0
    6
    0
    ***************
    send the message
    Les opérations du job2sont
    2
    1
    12
    2
    0
    ***************
    2
    2
    0
    3
    10
    ***************
    2
    3
    11
    0
    10
    ***************
    agent job est en Attente de l agent Interface
    send the message
    Les opérations du job3sont
    3
    1
    12
    0
    12
    ***************
    3
    2
    4
    0
    12
    ***************
    3
    3
    12
    0
    10
    ***************
    send the message
    agent job est en Attente de l agent Interface
    le message est bien reçu
    3
    1
    12
    0
    12
    3
    2
    4
    0
    12
    3
    3
    12
    0
    10
    le message est bien reçu
    1
    1
    0
    8
    0
    1
    2
    0
    8
    0
    1
    3
    0
    6
    0
    message envoyer de Job1 vers agent interface contient: !!!!Donnez moi le tableau de phéromone!!!!
    message envoyer de Job3 vers agent interface contient: !!!!Donnez moi le tableau de phéromone!!!!
    message envoyé de a vers Job3 est bien reçu
    Bravoooooooo 3
    Les quantité de phéromones du job3sont
    3
    1
    1
    0
    1
    ^^^^^^^^^^^^^^^^^^^^
    3
    2
    1
    0
    1
    ^^^^^^^^^^^^^^^^^^^^
    3
    3
    1
    0
    1
    ^^^^^^^^^^^^^^^^^^^^
    qt de pheromone reçu
    3
    1
    1
    0
    1
    3
    2
    1
    0
    1
    3
    3
    1
    0
    1
    terminééééééJob3
    message envoyé de a vers Job1 est bien reçu
    Bravoooooooo 1
    Les quantité de phéromones du job1sont
    1
    1
    0
    1
    0
    ^^^^^^^^^^^^^^^^^^^^
    1
    2
    0
    1
    0
    ^^^^^^^^^^^^^^^^^^^^
    1
    3
    0
    1
    0
    ^^^^^^^^^^^^^^^^^^^^
    le message est bien reçu
    2
    1
    12
    2
    0
    2
    2
    0
    3
    10
    2
    3
    11
    0
    10
    message envoyer de Job2 vers agent interface contient: !!!!Donnez moi le tableau de phéromone!!!!
    message envoyé de a vers Job2 est bien reçu
    Bravoooooooo 2
    Les quantité de phéromones du job2sont
    2
    1
    1
    1
    0
    ^^^^^^^^^^^^^^^^^^^^
    2
    2
    0
    1
    1
    ^^^^^^^^^^^^^^^^^^^^
    2
    3
    1
    0
    1
    ^^^^^^^^^^^^^^^^^^^^
    qt de pheromone reçu
    2
    1
    1
    1
    0
    2
    2
    0
    1
    1
    2
    3
    1
    0
    1
    terminééééééJob2
    qt de pheromone reçu
    1
    1
    0
    1
    0
    1
    2
    0
    1
    0
    1
    3
    0
    1
    0
    terminééééééJob1

  10. #10
    Membre du Club
    Femme Profil pro
    Chercheuse en Informatique
    Inscrit en
    Février 2012
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheuse en Informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 32
    Points : 41
    Points
    41
    Par défaut Les comportement parallèles
    Bonsoir Djug,

    j'ai un soucis concernant les comportement parallèle et leur utilité.
    En fait, j'ai besoin d'un comportement qui lit les messages et les stocker dans une liste a tout moment dans le programme et a un autre comportement qui utilise le contenu des message donc j'ai besoin toujours de la nouvelle liste des messages. est ce que les comportements parallèle assure ce mécanisme décrit ci-dessus ou non ?

    Merci d'avance

  11. #11
    Expert éminent sénior

    Avatar de Djug
    Homme Profil pro
    Inscrit en
    Mai 2007
    Messages
    2 980
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Algérie

    Informations forums :
    Inscription : Mai 2007
    Messages : 2 980
    Points : 17 970
    Points
    17 970
    Par défaut
    Je crois que tu peux le faire avec deux comportements parallèles.

  12. #12
    Membre du Club
    Femme Profil pro
    Chercheuse en Informatique
    Inscrit en
    Février 2012
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheuse en Informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 32
    Points : 41
    Points
    41
    Par défaut
    Citation Envoyé par Djug Voir le message
    Je crois que tu peux le faire avec deux comportements parallèles.
    Merci beaucoup pour votre aide.
    Dans mon programme j'utilise le FSMBehaviours. Est ce que vous pouvez m'expliquez comment j’intègre le comportement parallèle dans le FSMBehaviours.
    je ne trouve plus un exemple qui me montre cette structure

    Merci.

  13. #13
    Membre du Club
    Femme Profil pro
    Chercheuse en Informatique
    Inscrit en
    Février 2012
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheuse en Informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 32
    Points : 41
    Points
    41
    Par défaut
    l'article est très utile mais je pense que l'exemple que vous avez donner concernant la combinaison entre FSMBehaviour et le parralelBehaviour ne décrit pas vraiment l'utilité du comportement parallèle car vous avez dit que s'il génère un 5, il passe a l’état D sinon il passe a l’état E donc je pense que cet un exemple d'un FSMBehviour tout court.

    Est ce que vous pouvez me clarifier de plus cette partie
    Mercii

  14. #14
    Membre à l'essai
    Femme Profil pro
    Chercheur en informatique
    Inscrit en
    Octobre 2011
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheur en informatique

    Informations forums :
    Inscription : Octobre 2011
    Messages : 13
    Points : 15
    Points
    15
    Par défaut Behaviour
    Bonjour,

    j'ai une ambiguïté au niveau du fonctionnement de la méthode block(). En fait à chaque nouvelle exécution il y a changement de l'ordre d'exécution j'ai pas compris la cause. SVP aidez moi

  15. #15
    Membre du Club
    Femme Profil pro
    Chercheuse en Informatique
    Inscrit en
    Février 2012
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheuse en Informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 32
    Points : 41
    Points
    41
    Par défaut
    Citation Envoyé par sassion Voir le message
    Bonjour,

    j'ai une ambiguïté au niveau du fonctionnement de la méthode block(). En fait à chaque nouvelle exécution il y a changement de l'ordre d'exécution j'ai pas compris la cause. SVP aidez moi
    Bonjour sassion,

    non la méthode block n'a aucune effet sur l'ordre de exécution. normalement si tu as plusieurs agents qui s’exécutent au même temps alors l’exécution se déroule en parallèle donc a chaque exécution tu auras un nouvel ordre d’exécution. sinon si tu as un comportement parallèle donc aussi l'ordre d'exécution change a chaque fois

  16. #16
    Membre à l'essai
    Femme Profil pro
    Chercheur en informatique
    Inscrit en
    Octobre 2011
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheur en informatique

    Informations forums :
    Inscription : Octobre 2011
    Messages : 13
    Points : 15
    Points
    15
    Par défaut Behaviour
    Bonjour,

    Vraiment je suis bloqué. j'ai un problème lors d'envoie de message.
    En fait, j'utilise 3 familles d'agents qui s’exécutent simultanément. mon problème est que il y a un conflit de message, un message envoyé par Agent1 doit être traité au niveau du comportement 2 de l'agent Agent2 alors que ce message arrive a l'agent Agent2 lorsque ce lui ci est entrain d’exécuter le comportement 1 donc le message en question sera mal traité ou bien je vais avoir des exceptions

    Sil vous plait aidez moi

  17. #17
    Expert éminent sénior

    Avatar de Djug
    Homme Profil pro
    Inscrit en
    Mai 2007
    Messages
    2 980
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Algérie

    Informations forums :
    Inscription : Mai 2007
    Messages : 2 980
    Points : 17 970
    Points
    17 970
    Par défaut
    Que veux-tu dire par mal traité ? Peut-on jeter un coup d’œil sur le code du 2e agent ?

  18. #18
    Membre à l'essai
    Femme Profil pro
    Chercheur en informatique
    Inscrit en
    Octobre 2011
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheur en informatique

    Informations forums :
    Inscription : Octobre 2011
    Messages : 13
    Points : 15
    Points
    15
    Par défaut
    djug Merci pour votre réponse,


    mal traité c'est à dire que le message arrive a cet agent lorsqu'il est entrain d’exécuter le comportement de exploreDirection1 alors alors que la réponse a ce message je l'ai traité au niveau du comportement exploreDirection2.

    Et je peux pas les mettre ensemble car chaque agent va recevoir plusieurs messages a la fois.

    Autre chose:
    est ce normal que si j'ai 4 agents de même type lors de l'exécution il m'affiche 2 fois seulement "Fin Agent" au lieu de 4??

    est ce logique qu'a chaque exécution il m'affiche un ordre différent des messages??


    S'il VOUS plait Aidez moi je suis pressé par le temps quel est l'idée qui m'échappe concernant le raisonnement de JADE.



    voici le code de l'agent2

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    public void setup(){
    		System.out.println("Hello World! My name is "+getLocalName());
     
    		  System.out.println("-----------------------------------------------");
    		  System.out.println("----------------Agent Decideur----------------");
    		  System.out.println("-----------------------------------------------");
     
    		  FSMBehaviour agentD_beh= new FSMBehaviour();
     
    		    agentD_beh.registerFirstState(new attendreOrdre(), "attendreOrdre");
    		    agentD_beh.registerState(new ordonnerAcc(), "ordonnerAcc");
    		    agentD_beh.registerState(new exploreDirection(), "exploreDirection");
    		    agentD_beh.registerState(new exploreDirection1(), "exploreDirection1");
    		    agentD_beh.registerState(new exploreDirection2(), "exploreDirection2");
    		    agentD_beh.registerState(new verif(), "verif");
    		    agentD_beh.registerLastState(new fin(), "fin");
     
    		    agentD_beh.registerDefaultTransition("attendreOrdre", "exploreDirection");
    		    //agentD_beh.registerDefaultTransition("ordonnerAcc", "exploreDirection");
    		    agentD_beh.registerDefaultTransition("exploreDirection", "exploreDirection1");
    		    agentD_beh.registerDefaultTransition("exploreDirection1", "exploreDirection2");
    		    agentD_beh.registerDefaultTransition("exploreDirection2", "verif");
    		    agentD_beh.registerDefaultTransition("verif", "fin");
    		   /* agentD_beh.registerDefaultTransition("attendreOrdre", "ordonnerAcc");
    		    agentD_beh.registerDefaultTransition("ordonnerAcc", "exploreDirection");
    		    agentD_beh.registerDefaultTransition("exploreDirection", "fin");*/
     
    		 addBehaviour(agentD_beh); 
    		/* System.out.println("--------inst1---------");
    		  o.affich(currentinst1);
    		  System.out.println("--------inst2---------");
    		  o.affich(currentinst2);
    		  System.out.println("--------inst3---------");
    		  o.affich(currentinst3);
    		  System.out.println("--------inst4---------");
    		  o.affich(currentinst4);*/
    	}
     
        public ArrayList ordonnerAcc(ArrayList ta,ArrayList acc){
    		ArrayList l=new ArrayList();
    		ListIterator i=ta.listIterator();
    		while(i.hasNext()){
    			Object o=i.next();
    			ListIterator j=acc.listIterator();
    			while(j.hasNext()){
    				Object o1=j.next();
    				if(o.toString().equals(o1.toString())){
    					l.add(o);
    					}
    				}
    			}
    		return l;
    	}
     
        private class attendreOrdre extends OneShotBehaviour{
    		  @Override
    		  public void action() {
    			  System.out.println("en attente des restes des agents");
    			 block(); 
    		  }
    		}
    		/*****************************************************************/
        private class ordonnerAcc extends OneShotBehaviour{
     
            int valeurRetour=0;
            ArrayList l=new ArrayList();
    		  @Override
    		  public void action() {
    			  MessageTemplate modele = MessageTemplate.MatchPerformative(ACLMessage.INFORM);			 
    			  ACLMessage msg = myAgent.receive(modele);
    				if(msg!=null)
    					{
    					try {
    						ArrayList list=new ArrayList();
    						System.out.println("voici le contenu du message des ordres"+msg.getContentObject());
    						System.out.println("je m'appelle"+myAgent.getLocalName());
    						String ch=myAgent.getLocalName();
    						ListIterator i=ai.ldm.listIterator();
    						while(i.hasNext()){
    							AgentDecideur a=(AgentDecideur)i.next();
    							if(String.valueOf(ch.charAt(2)).equals(String.valueOf(a.agId))){
    								l=(ArrayList) msg.getContentObject();
    								System.out.println("accoinatance sans ordre"+a.accointance);
    								list= ordonnerAcc(l,a.accointance);
    								a.accointance=o.copie(list);
    								System.out.println("accoinatance avec ordre"+a.accointance);
    							}
    						}
    					} catch (UnreadableException e) {e.printStackTrace();}
    					valeurRetour=1;
    					}
    				else{valeurRetour=0;block();
    				}
    				}	
    		  public int onEnd(){
    			  return valeurRetour;
    			  }
    		  }
     
    		/*****************************************************************/
        private class exploreDirection extends OneShotBehaviour{
        		int valeurRetour=0;
    		  @Override
    		  public void action() {
    			 boolean tr=false;
    			 MessageTemplate modele = MessageTemplate.and(MessageTemplate.MatchPerformative(ACLMessage.CFP),
    					  MessageTemplate.MatchConversationId("1"));
    			  //MessageTemplate modele = MessageTemplate.MatchPerformative(ACLMessage.CFP);			 
    			  ACLMessage msg = myAgent.receive(modele);
    			  ArrayList l=new ArrayList();
    			  if(msg==null){valeurRetour=0;block();}
     
    				if(msg!=null){
    					try {
    						int size=myAgent.getQueueSize();
    						System.out.println("je m'appelle décideur "+myAgent.getLocalName());
    						//System.out.println("size de la boite de reception"+myAgent.getQueueSize());
    					    System.out.println("voici le contenu du message des tuples"+msg.getContentObject());
    					    l=(ArrayList) msg.getContentObject();
    					    String ch=myAgent.getLocalName();
    					    if(String.valueOf(ch.charAt(2)).equals("1"))
    					    	{currentinst1.add(l.get(0));currentinst1.add(l.get(1));}
    					    if(String.valueOf(ch.charAt(2)).equals("2"))
    					        {currentinst2.add(l.get(2));currentinst2.add(l.get(3));}
    					    if(String.valueOf(ch.charAt(2)).equals("3"))
    				    	    {currentinst3.add(l.get(4));currentinst3.add(l.get(5));}
    					    } catch (UnreadableException e) {e.printStackTrace();}
    					}
    				}
    		  public int onEnd(){
    			  return valeurRetour;
    		  }
    		}
        /*****************************************************************/
        private class exploreDirection1 extends OneShotBehaviour{
        		int valeurRetour=0;
    		  public void action() {
    			  MessageTemplate modele = MessageTemplate.and(MessageTemplate.MatchPerformative(ACLMessage.CFP),
    					  MessageTemplate.MatchConversationId("2"));
    			 // MessageTemplate modele = MessageTemplate.MatchPerformative(ACLMessage.CFP);			 
    			  ACLMessage msg = myAgent.receive(modele);
    			  ArrayList l=new ArrayList();
    			  if(msg==null){valeurRetour=0;block();}
     
    				if(msg!=null)
    					{
    					try {
    						int size=myAgent.getQueueSize();
    						System.out.println("je m'appelle décideur "+myAgent.getLocalName());
    					    System.out.println("voici le contenu du message des tuples"+msg.getContentObject());
    					    l=(ArrayList) msg.getContentObject();
    					    String ch=myAgent.getLocalName();
    					    if(String.valueOf(ch.charAt(2)).equals("2"))
    					        {currentinst2.add(l.get(0));currentinst2.add(l.get(1));}
    					    if(String.valueOf(ch.charAt(2)).equals("3"))
    				    	    {currentinst3.add(l.get(2));currentinst3.add(l.get(3));}
    					    } catch (UnreadableException e) {e.printStackTrace();}
    					}
    			  }
    		  public int onEnd(){
    			  return valeurRetour;
    		  }
    		}
        /*****************************************************************/
        private class exploreDirection2 extends OneShotBehaviour{
        		int valeurRetour=0;
    		  public void action() {
    			  MessageTemplate modele = MessageTemplate.and(MessageTemplate.MatchPerformative(ACLMessage.CFP),
    					  MessageTemplate.MatchConversationId("3"));
    			 // MessageTemplate modele = MessageTemplate.MatchPerformative(ACLMessage.CFP);
    			  //MessageTemplate.MatchConversationId("id msg");
    			  ACLMessage msg = myAgent.receive(modele);
    			  ArrayList l=new ArrayList();
    			  if(msg==null){valeurRetour=0;block();}
     
    				if(msg!=null)
    					{
    					try {
    						int size=myAgent.getQueueSize();
    						System.out.println("je m'appelle décideur "+myAgent.getLocalName());
    					    System.out.println("voici le contenu du message des tuples"+msg.getContentObject());
    					    l=(ArrayList) msg.getContentObject();
    					    String ch=myAgent.getLocalName();
    					    if(String.valueOf(ch.charAt(2)).equals("1"))
    					        {currentinst1.add(l.get(0));currentinst1.add(l.get(1));}
    					    if(String.valueOf(ch.charAt(2)).equals("4"))
    				    	    {currentinst4.add(l.get(2));currentinst4.add(l.get(3));}
    					    if(String.valueOf(ch.charAt(2)).equals("3"))
    			    	        {currentinst3.add(l.get(4));currentinst3.add(l.get(5));}
    					    } catch (UnreadableException e) {e.printStackTrace();}
    					}
    			  }
    		  public int onEnd(){
    			  return valeurRetour;
    		  }
    		}
     
        /*****************************************************************/
        private class verif extends OneShotBehaviour{
        		int valeurRetour=0;
    		  public void action() {
    		  }
    		  public int onEnd(){
    			  return valeurRetour;
    		  }
    		}
           /*****************************************************************/
      private class fin extends OneShotBehaviour{
    		  @Override
    		  public void action() {
    			  System.out.println("--------inst1---------");
    			  o.affich(currentinst1);
    			  System.out.println("--------inst2---------");
    			  o.affich(currentinst2);
    			  System.out.println("--------inst3---------");
    			  o.affich(currentinst3);
    			  System.out.println("--------inst4---------");
    			  o.affich(currentinst4);
    			  System.out.println("findecideur"+myAgent.getLocalName());
    		  }
      }
          /*****************************************************************/
    }

  19. #19
    Expert éminent sénior

    Avatar de Djug
    Homme Profil pro
    Inscrit en
    Mai 2007
    Messages
    2 980
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Algérie

    Informations forums :
    Inscription : Mai 2007
    Messages : 2 980
    Points : 17 970
    Points
    17 970
    Par défaut
    Je pense que tu as deux type de messages, ceux qui doivent etre lu au niveau de exploreDirection1, et ceux qui doivent être lu au niveau de exploreDirection2, donc il suffit de différencier les deux type de messages :
    http://djug.developpez.com/java/jade/communication/#LVI

    Si tu as uniquement deux message de fin d’exécution, cela veut dire que ton système n’a pas réussi à lancer que deux agents, ou il y’a quelque chose qui bloque l’exécution des deux autres agents (peut être une attente de la réception d’un message).

  20. #20
    Membre à l'essai
    Femme Profil pro
    Chercheur en informatique
    Inscrit en
    Octobre 2011
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Chercheur en informatique

    Informations forums :
    Inscription : Octobre 2011
    Messages : 13
    Points : 15
    Points
    15
    Par défaut Agent sniffer
    Bonjour,
    s'il vous plait savez vous comment programmer l'agent sniffer.

    merci.

Discussions similaires

  1. alterner les couleurs dans un tableau avec xsl
    Par Eithelgul dans le forum XSL/XSLT/XPATH
    Réponses: 14
    Dernier message: 03/05/2015, 23h29
  2. Réponses: 9
    Dernier message: 06/11/2007, 12h36
  3. [syntaxe] Gerer les variables dans une requete
    Par rastapopulos dans le forum MS SQL Server
    Réponses: 12
    Dernier message: 15/04/2003, 12h53
  4. gérer les jpg dans une fenetre directdraw???
    Par Anonymous dans le forum DirectX
    Réponses: 1
    Dernier message: 14/06/2002, 13h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo