jadex.bdi.planlib.protocols.contractnet
Class CNPInitiatorPlan

java.lang.Object
  extended by jadex.bdi.runtime.impl.AbstractPlan
      extended by jadex.bdi.runtime.Plan
          extended by jadex.bdi.planlib.protocols.AbstractInitiatorPlan
              extended by jadex.bdi.planlib.protocols.contractnet.CNPInitiatorPlan
All Implemented Interfaces:
ISuspendable, java.io.Serializable

public class CNPInitiatorPlan
extends AbstractInitiatorPlan

Handles the initiator side of a contract-net protocol.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jadex.bdi.runtime.Plan
Plan.SyncResultListener
 
Field Summary
protected  IMessageEvent me
          Last sent message with convid for receiving answer messages.
 
Fields inherited from class jadex.bdi.runtime.Plan
lis
 
Fields inherited from class jadex.bdi.runtime.impl.AbstractPlan
interpreter, planinit
 
Constructor Summary
CNPInitiatorPlan()
           
 
Method Summary
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.
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.
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
aborted, getTimeout
 
Methods inherited from class jadex.bdi.runtime.Plan
createWaitAbstraction, dispatchSubgoalAndWait, dispatchSubgoalAndWait, failed, getMonitor, isEventRegisteredInWaitqueue, passed, resume, sendMessageAndWait, sendMessageAndWait, suspend, waitFor, waitForCondition, waitForCondition, waitForEver, waitForExternalCondition, waitForExternalCondition, waitForFactAdded, waitForFactAdded, waitForFactAddedOrRemoved, waitForFactAddedOrRemoved, waitForFactChanged, waitForFactChanged, waitForFactRemoved, waitForFactRemoved, waitForGoal, waitForGoal, waitForGoal, waitForGoal, waitForInternalEvent, waitForInternalEvent, waitForMessageEvent, waitForMessageEvent, waitForReply, waitForReply, waitForTick, waitForWaitAbstraction, waitForWaitAbstraction
 
Methods inherited from class jadex.bdi.runtime.impl.AbstractPlan
createComponentIdentifier, createComponentIdentifier, createComponentIdentifier, createExpression, createExpression, createGoal, createInternalEvent, createMessageEvent, dispatchInternalEvent, dispatchSubgoal, dispatchTopLevelGoal, endAtomic, fail, fail, fail, getBeliefbase, getBody, getClock, getComponentIdentifier, getComponentName, getDispatchedElement, getEventbase, getException, getExpression, getExpressionbase, getExternalAccess, getFlyweight, getGoalbase, getInterpreter, getLifecycleState, getLogger, getParameter, getParameters, getParameterSet, getParameterSets, getPlanbase, getPlanElement, getPropertybase, getRCapability, getReason, getRPlan, getScope, getState, getTime, getType, getWaitqueue, hasParameter, hasParameterSet, killAgent, sendMessage, startAtomic, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.

Specified by:
body in class Plan

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 class AbstractInitiatorPlan
Returns:
The initial message of the interaction.


Copyright © 2010. All Rights Reserved.