Пример #1
0
 /// <summary>
 /// Logistics request. Find an agent that can provide it.
 /// </summary>
 /// <param name="manufacturer">The supplier agent making the request</param>
 private void HandleRequestMessage(Agent author, TransportTask task)
 {
     // Request the payoff results from the agents in the environment
       // which can provide the required service
       Task lTask = task;
       Message agentRequest = new RequestMessage(this, ref lTask);
       messageQueue.SendPost(switchboard, agentRequest);
 }
Пример #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);
 }
Пример #3
0
 /// <summary>
 /// Manufacturer is requesting supply. Find an agent that can provide it.
 /// </summary>
 /// <param name="manufacturer">The manufacturer agent making the request</param>
 private void HandleRequestMessage(ManufacturerAgent manufacturer)
 {
     Task mTask = manufacturer.Task;
       // Request the payoff results from the agents in the environment
       // which can provide the required service
       Message agentRequest = new RequestMessage(this, ref mTask);
       messageQueue.SendPost(switchboard, agentRequest);
 }
Пример #4
0
 /// <summary>
 /// The client agent will need to keep track of the agents that it
 /// is coordinating with in order to minimise waste.
 /// </summary>
 protected override void Sensor()
 {
     // Check for the Controller
       RequestController();
       // Determine if more demand is required
       if (demand == 0) {
     demand = rnd.Next(MIN_DEMAND, MAX_DEMAND);
     Update(this, "Quantity", "Quantity: " + demand.ToString());
       }
       // If demand is required then send a request to the controller for a manufacturer
       // Only if the agents do not have a current manufacturer and the agent
       // knows who the controller is.
       if (demand > 0 && manager != null && assignedTask == null) {
     // Send a request to the controller to form a coordination group
     // with the closest manufacturer.
     Message aMessage = new RequestMessage(this, demand);
     messageQueue.SendPost(manager, aMessage);
       }
 }
Пример #5
0
 /// <summary>
 /// Handles a request message from the Controller for agents which can
 /// help fulfill the task request. The Operator will send a request
 /// to all of the agents in the communication graph connected directly with
 /// the operator to request the participating agents payoff functions.
 /// </summary>
 /// <param name="destination">Controller agent which made the request</param>
 /// <param name="task">A Manufacturer request for supply. Required in order to calculate a realistic payoff function.</param>
 private void HandleRequestMessage(Agent destination, Task task)
 {
     // Step through each agent in the communication graph connected to the operator
       foreach (CommunicationGraphEdge e in communicationNode.Edges) {
     // Send a payoff request to the agent which is not the operator
     Agent a = e.DestinationNode.Value;
     RequestMessage r = new RequestMessage(this, ref task);
     messageQueue.SendPost(a, r);
       }
       if (task.RegisteredAgents.Count > 0)
     task.RegisteredAgents.Sort(task.RegisteredAgents[0]);
       // Send the results back to the controller
       InformMessage i = new InformMessage(this, task);
       messageQueue.SendPost(destination, i);
 }
Пример #6
0
 /// <summary>
 /// Use this call to identify the Controller from the Operator
 /// </summary>
 protected void RequestController()
 {
     if (manager == null) {
     // Generate a new request message for the controller
     Clockwork.Telegram.Message m = new RequestMessage(this, manager);
     messageQueue.SendPost(switchboard, m);
       }
 }
Пример #7
0
 /// <summary>
 /// When the manufacturer performs a sensor action it will determine the following.
 /// Is the Manufacturer part of a coordination group with a client agent
 ///    * If so it will determine if it has enough product on hand to supply the client agent
 ///    * If not a failure might have occured, ensure that the missing client is intentional
 /// If the manufacturer needs stock it will need to coordinate with a supplier, else
 /// if will need to coordinate with a logistics agent to deliver the product.
 /// </summary>
 protected override void Sensor()
 {
     // Check if the agent is part of a coordination group
       if (assignedTask != null) {
     // Check if the agent has enough product. If so send a request for a logistics
     // agent.
     if (product >= ((ManufacturerTask)assignedTask).Demand && ((ManufacturerTask)assignedTask).Transport == null) {
       // Request a logistics agent to collect the product for the client
       Task task = new TransportTask(this, ((ManufacturerTask)assignedTask).Client, ((ManufacturerTask)assignedTask).Demand);
       RequestMessage m = new RequestMessage(this, ref task);
       messageQueue.SendPost(manager, m);
     } else if (stock < ((ManufacturerTask)assignedTask).Demand && ((ManufacturerTask)assignedTask).Supplier == null) {
       // Request a supplier agent to deliver the stock for the manufacturer
       RequestMessage m = new RequestMessage(this, assignedTask);
       messageQueue.SendPost(manager, m);
     }
       }
 }
Пример #8
0
 /// <summary>
 /// The supplier will check if it has any current tasks that it
 /// needs to fufill.
 /// </summary>
 protected override void Sensor()
 {
     if (assignedTask != null) {
     // Check when the supplier has got enough stock on hand to deliver to the
     // manufacturer
     if (supply >= ((SupplierTask)assignedTask).OrderAmount && ((SupplierTask)assignedTask).Transport == null) {
       // Send a request for a logistics agent to come and collect the order
       Task task = new TransportTask(this, ((SupplierTask)assignedTask).Manufacturer, ((SupplierTask)assignedTask).OrderAmount);
       RequestMessage m = new RequestMessage(this, ref task);
       messageQueue.SendPost(manager, m);
     }
       }
 }