Example #1
0
 /// <summary>
 /// Received a response from the operator with the results of the client
 /// task request in the environment. Check if a valid agent is registered
 /// and form a coordination group with the respective agents if required.
 /// </summary>
 /// <param name="destination">Client agent which made the original request</param>
 /// <param name="task">The results of the Client task request in the enivornment</param>
 private void HandleInformMessage(Agent destination, ClientTask task)
 {
     if (task.RegisteredAgents.Count > 0) {
     // Create an entry in the execution tree. For now the order
     // is placed as a task in the tree with the current client as
     // the target.
     ExecutionNode n = new ExecutionNode(task);
     tree.Root.Add(n);
     // Greedy method means that the best payoff result will be assigned to the
     // coordination group.
     // Send a message to the client and the manufacturer informing them of
     // the current situation
     InformMessage i = new InformMessage(this, task);
     // Send the message first to the client
     messageQueue.SendPost(task.Agent, i);
     // Generate a manufacturer task
     ManufacturerTask mTask = new ManufacturerTask((ClientAgent)task.Agent);
     mTask.Agent = task.RegisteredAgents[0].TaskAgent;
     tree.AddChild(task, mTask);
     i = new InformMessage(this, mTask);
     // Send the message also to the manufacturer
     communicationNode.AddEdge(task.RegisteredAgents[0].TaskAgent.CommunicationNode);
     messageQueue.SendPost(task.RegisteredAgents[0].TaskAgent, i);
       }
 }
Example #2
0
 /// <summary>
 /// Controller will create a coordination group between the
 /// client and the best possible solution agent.
 /// Three possibilities can occur when requesting an agent from
 /// the operator, all of which will be handled by the payoff function
 /// of the agent.
 ///   IE: A logistics agent is nearby which already has a load but no longer
 ///       has a client.
 ///       A manufacturer is nearby which already has capacity but no longer has
 ///       a client.
 ///       A manufacturer is nearby which has spare capacity.
 /// </summary>
 /// <param name="client">Client agent which is making the request</param>
 private void HandleRequestMessage(ClientAgent client)
 {
     // Controller will request payoffs from all agents in the environment
       // from the possible payoffs it is possible for the controller to select the
       // best agent for the job.
       // Create a demand request message and send it to the operator agent.
       Task cTask = new ClientTask(client);
       Message agentRequest = new RequestMessage(this, ref cTask);
       messageQueue.SendPost(switchboard, agentRequest);
       // Check if the communication edge is already set
       communicationNode.AddEdge(client.CommunicationNode);
 }
Example #3
0
 /// <summary>
 /// Response from the controller indicating that the task group is a success
 /// </summary>
 /// <param name="controller">Controller which sent the message</param>
 /// <param name="task">Task associated with the current message</param>
 private void HandleInformMessage(Controller controller, ClientTask task)
 {
     coordinationNode.AddEdge(task.RegisteredAgents[0].TaskAgent.CoordinationNode);
       assignedTask = task;
 }