Class CNPInitiatorPlan


  • public class CNPInitiatorPlan
    extends AbstractInitiatorPlan
    Handles the initiator side of a contract-net protocol.
    • Field Detail

      • me

        protected IMessageEvent me
        Last sent message with convid for receiving answer messages.
    • Constructor Detail

      • CNPInitiatorPlan

        public CNPInitiatorPlan()
    • Method Detail

      • body

        public void body()
        The body method is called on the instatiated plan instance from the scheduler.
        Overrides:
        body in class AbstractInitiatorPlan
      • passed

        public void passed()
        Description copied from class: Plan
        The passed method is called on plan success.
        Overrides:
        passed in class Plan
      • failed

        public void failed()
        Description copied from class: Plan
        The failed method is called on plan failure/abort.
        Overrides:
        failed in class Plan
      • aborted

        public void aborted()
        Description copied from class: AbstractInitiatorPlan
        Called when the plan is aborted, i.e., when the corresponding interaction goal is dropped. Terminates the interaction using the FIPA-Cancel-Meta-Protocol.
        Overrides:
        aborted in class AbstractInitiatorPlan
      • isIterated

        protected boolean isIterated()
        Test if it is the iterated contract-net version.
        Returns:
        True, if is is the iterated version.
      • getShortProtocolName

        protected java.lang.String getShortProtocolName()
        Get protocol abbrev name.
        Returns:
        The protocol abbrev name.
      • sendCFP

        protected void sendCFP​(NegotiationRecord nr,
                               java.lang.String convid)
        Send the cfp message.
        Parameters:
        nr - The current negotation record.
        convid - The conversation id.
      • collectProposals

        protected void collectProposals​(NegotiationRecord nr,
                                        java.util.Map proposalmessages)
        Collect proposal messages.
        Parameters:
        nr - The negotiation record.
        proposalmessages - Map for storing the message of each current proposal (part. proposal -> message event).
      • evaluateProposals

        protected ParticipantProposal[] evaluateProposals​(NegotiationRecord nr,
                                                          java.util.Map proposalmessages)
        Determine acceptable proposals.
        Parameters:
        nr - The negotiation record.
        proposalmessages - The received proposal messages (required to detect null proposals).
        Returns:
        The acceptable proposals.
      • queryNextroundInfo

        protected NegotiationRecord queryNextroundInfo​(NegotiationRecord nr)
        Decide if a new iteration should be performed.
        Parameters:
        nr - The negotiation record of the current round.
        Returns:
        The negotiation record for the next round (or null, if no further iteration should be performed).
      • rejectExcludedProposals

        protected void rejectExcludedProposals​(NegotiationRecord nr,
                                               IComponentIdentifier[] newparticipants,
                                               java.util.Map proposalmessages)
        Reject all proposals, which are not part of the next round.
        Parameters:
        nr - The current negotiation record.
        newparticipants - The remaining participants of the next round, which should not be rejected.
      • acceptAllProposals

        protected NegotiationRecord acceptAllProposals​(NegotiationRecord nr,
                                                       ParticipantProposal[] acceptables,
                                                       java.util.Map proposalmessages)
        Accept all proposals in parallel.
        Parameters:
        nr - The current negotiation record.
        acceptables - The acceptable proposals.
        proposalmessages - The map containing proposal messages to reply to.
      • acceptOneProposal

        protected NegotiationRecord acceptOneProposal​(NegotiationRecord nr,
                                                      ParticipantProposal[] acceptables,
                                                      java.util.Map proposalmessages)
        Sequentially accept proposals until the first successful execution.
        Parameters:
        nr - The current negotiation record.
        acceptables - The acceptable proposals.
        proposalmessages - The map containing proposal messages to reply to.
      • determineFailure

        protected void determineFailure​(NegotiationRecord nr,
                                        ParticipantProposal[] acceptables)
        Determine success or failure of the interaction. Will make the plan fail, if not enough proposals have been executed according to the acceptables and the "needall" flag.
        Parameters:
        nr - The final negotiation record containing executed proposals.
        acceptables - The acceptable proposals.