Class ContractNetProtocol

java.lang.Object
dev.agenor.runtime.dialogue.protocol.ContractNetProtocol
All Implemented Interfaces:
Protocol

public class ContractNetProtocol extends Object implements Protocol
Contract Net Protocol for task delegation and negotiation.

Flow:


 Initiator                    Participants
     |                             |
     |-------- CFP --------------->| (broadcast)
     |                             |
     |<------- PROPOSE/REFUSE -----|
     |<------- PROPOSE/REFUSE -----|
     |                             |
     |-------- AGREE ------------->| (to winner)
     |-------- REFUSE ------------>| (to others)
     |                             |
     |<------- INFORM/FAILURE -----|
     |                             |
 
Since:
0.5.0
  • Field Details

  • Constructor Details

    • ContractNetProtocol

      public ContractNetProtocol()
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface Protocol
      Returns:
      unique identifier for this protocol
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface Protocol
      Returns:
      human-readable name for display
    • getInitialState

      public ProtocolState getInitialState()
      Specified by:
      getInitialState in interface Protocol
      Returns:
      the initial state when a conversation starts
    • nextState

      public ProtocolState nextState(ProtocolState current, Performative received, boolean isInitiator)
      Description copied from interface: Protocol
      Computes the next state given a performative.
      Specified by:
      nextState in interface Protocol
      Parameters:
      current - the current state
      received - the received performative
      isInitiator - true if this agent initiated the protocol
      Returns:
      the next state
    • senderPerforms

      public boolean senderPerforms(Performative performative)
      Contract Net reverses the direction of AGREE.

      The initiator sends CFP and later AGREE to accept one proposal; the party that takes on the work is the participant in both cases. Only PROPOSE — a participant offering to do it — binds its own sender.

      Specified by:
      senderPerforms in interface Protocol
      Parameters:
      performative - the performative that creates the commitment
      Returns:
      true when the sender performs, false when the receiver does
    • allowedPerformatives

      public Set<Performative> allowedPerformatives(ProtocolState state, boolean isInitiator)
      Description copied from interface: Protocol
      Gets the set of allowed performatives in a given state.
      Specified by:
      allowedPerformatives in interface Protocol
      Parameters:
      state - the current state
      isInitiator - true if this agent initiated the protocol
      Returns:
      set of valid performatives