Class CNPInitiatorPlan
- java.lang.Object
-
- jadex.bdiv3x.runtime.Plan
-
- jadex.bdi.planlib.protocols.AbstractInitiatorPlan
-
- jadex.bdi.planlib.protocols.contractnet.CNPInitiatorPlan
-
public class CNPInitiatorPlan extends AbstractInitiatorPlan
Handles the initiator side of a contract-net protocol.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jadex.bdiv3x.runtime.Plan
Plan.PlanWaitAbstraction
-
-
Field Summary
Fields Modifier and Type Field Description protected IMessageEvent
me
Last sent message with convid for receiving answer messages.
-
Constructor Summary
Constructors Constructor Description CNPInitiatorPlan()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
aborted()
Called when the plan is aborted, i.e., when the corresponding interaction goal is dropped.protected NegotiationRecord
acceptAllProposals(NegotiationRecord nr, ParticipantProposal[] acceptables, java.util.Map proposalmessages)
Accept all proposals in parallel.protected NegotiationRecord
acceptOneProposal(NegotiationRecord nr, ParticipantProposal[] acceptables, java.util.Map proposalmessages)
Sequentially accept proposals until the first successful execution.void
body()
The body method is called on the instatiated plan instance from the scheduler.protected void
collectProposals(NegotiationRecord nr, java.util.Map proposalmessages)
Collect proposal messages.protected void
determineFailure(NegotiationRecord nr, ParticipantProposal[] acceptables)
Determine success or failure of the interaction.protected ParticipantProposal[]
evaluateProposals(NegotiationRecord nr, java.util.Map proposalmessages)
Determine acceptable proposals.void
failed()
The failed method is called on plan failure/abort.protected IMessageEvent
getInitialMessage()
Get the initial message.protected java.lang.String
getShortProtocolName()
Get protocol abbrev name.protected boolean
isIterated()
Test if it is the iterated contract-net version.void
passed()
The passed method is called on plan success.protected NegotiationRecord
queryNextroundInfo(NegotiationRecord nr)
Decide if a new iteration should be performed.protected void
rejectExcludedProposals(NegotiationRecord nr, IComponentIdentifier[] newparticipants, java.util.Map proposalmessages)
Reject all proposals, which are not part of the next round.protected void
sendCFP(NegotiationRecord nr, java.lang.String convid)
Send the cfp message.-
Methods inherited from class jadex.bdi.planlib.protocols.AbstractInitiatorPlan
getTimeout
-
Methods inherited from class jadex.bdiv3x.runtime.Plan
checkNotInAtomic, createExpression, createGoal, createInternalEvent, createMessageEvent, dispatchInternalEvent, dispatchSubgoal, dispatchSubgoalAndWait, dispatchSubgoalAndWait, dispatchTopLevelGoal, endAtomic, fail, fail, fail, getAgent, getBeliefbase, getClock, getComponentDescription, getComponentIdentifier, getComponentName, getDispatchedElement, getEventbase, getException, getExpression, getExpressionbase, getExternalAccess, getGoalbase, getLogger, getParameter, getParameters, getParameterSet, getParameterSets, getPlanbase, getPlanElement, getReason, getRPlan, getScope, getTime, getWaitqueue, hasParameter, hasParameterSet, killAgent, sendMessage, sendMessageAndWait, sendMessageAndWait, startAtomic, toString, waitFor, waitForCondition, waitForCondition, waitForCondition, waitForConditionInline, waitForConditionInline, waitForEver, waitForFactAdded, waitForFactAdded, waitForFactChanged, waitForFactChanged, waitForFactRemoved, waitForFactRemoved, waitForGoalFinished, waitForGoalFinished, waitForGoalFinished, waitForGoalFinished, waitForInternalEvent, waitForInternalEvent, waitForMessageEvent, waitForMessageEvent, waitForReply, waitForReply, waitForReply, waitForReply, waitForTick
-
-
-
-
Field Detail
-
me
protected IMessageEvent me
Last sent message with convid for receiving answer messages.
-
-
Method Detail
-
body
public void body()
The body method is called on the instatiated plan instance from the scheduler.- Overrides:
body
in classAbstractInitiatorPlan
-
passed
public void passed()
Description copied from class:Plan
The passed method is called on plan success.
-
failed
public void failed()
Description copied from class:Plan
The failed method is called on plan failure/abort.
-
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 classAbstractInitiatorPlan
-
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.
-
getInitialMessage
protected IMessageEvent getInitialMessage()
Get the initial message.- Specified by:
getInitialMessage
in classAbstractInitiatorPlan
- Returns:
- The initial message of the interaction.
-
-