public class DefaultMultilateralProtocol extends java.lang.Object implements MultilateralProtocol
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isAborted |
| Constructor and Description |
|---|
DefaultMultilateralProtocol() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterSession(Session session,
java.util.List<NegotiationParty> parties)
This will get called just after ending the session.
|
void |
applyAction(Action action,
Session session)
Apply the action according to the protocol.
|
java.util.Map<NegotiationParty,java.util.List<Action>> |
beforeSession(Session session,
java.util.List<NegotiationParty> parties)
Returns a list of Actions to be sent to
NegotiationParty.receiveMessage(AgentID, Action) . |
protected void |
checkOffer(Offer offer)
Check incoming offer
|
void |
endNegotiation()
Overwrites the rest of the protocol and sets the protocol state to finish
|
void |
endNegotiation(java.lang.String reason)
Overwrites the rest of the protocol and sets the protocol state to finish
|
java.util.Collection<NegotiationParty> |
exclude(java.util.Collection<NegotiationParty> negotiationParties,
java.lang.Class negotiationPartyClass)
Filters the list by including only the type of negotiation parties.
|
java.util.Map<NegotiationParty,java.util.List<NegotiationParty>> |
getActionListeners(java.util.List<NegotiationParty> parties)
Get a map of parties that are listening to each other's response
|
Bid |
getCurrentAgreement(Session session,
java.util.List<NegotiationParty> parties)
This method should return the current agreement.
|
int |
getNumberOfAgreeingParties(Session session,
java.util.List<NegotiationParty> parties)
Gets the number of parties that currently agree to the offer.
|
Round |
getRoundStructure(java.util.List<NegotiationParty> parties,
Session session)
Get the structure of the current round.
|
java.util.Collection<NegotiationParty> |
includeOnly(java.util.Collection<NegotiationParty> negotiationParties,
java.lang.Class negotiationPartyClass)
Filters the list by including only the type of negotiation parties.
|
boolean |
isFinished(Session session,
java.util.List<NegotiationParty> parties)
Check if the protocol is done or still busy.
|
protected static java.util.Map<NegotiationParty,java.util.List<NegotiationParty>> |
listenToAll(java.util.List<NegotiationParty> parties) |
protected static java.util.Map<NegotiationParty,java.util.List<NegotiationParty>> |
listenToNone(java.util.List<NegotiationParty> parties) |
public Round getRoundStructure(java.util.List<NegotiationParty> parties, Session session)
MultilateralProtocolNegotiationParty and the
complete Session which can be used to diversify the round
structure at some point during the session.getRoundStructure in interface MultilateralProtocolparties - The parties currently participatingsession - The complete session historypublic java.util.Map<NegotiationParty,java.util.List<Action>> beforeSession(Session session, java.util.List<NegotiationParty> parties) throws NegotiationPartyTimeoutException, java.util.concurrent.ExecutionException, java.lang.InterruptedException
MultilateralProtocolNegotiationParty.receiveMessage(AgentID, Action) . This will get
called just before the session starts. If some initialization with needs
to be done by the protocol, it can be done here.beforeSession in interface MultilateralProtocolsession - The upcoming Sessionparties - The NegotiationPartys that will participate in the
sessionNegotiationPartyTimeoutExceptionjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic void afterSession(Session session, java.util.List<NegotiationParty> parties)
MultilateralProtocolNegotiationParty.negotiationEnded(Bid) as these are always
called by the SessionManager.afterSession in interface MultilateralProtocolsession - The session instance that was used for the sessionparties - The parties that participated in the sessionpublic void applyAction(Action action, Session session) throws ActionException
MultilateralProtocolapplyAction in interface MultilateralProtocolaction - action to apply. The Agent ID in the action already has been
checked when this is called.session - the current state of this sessionActionException - if the proposed action is illegal according to the protocol.protected void checkOffer(Offer offer) throws ActionException
action - the offerActionExceptionpublic boolean isFinished(Session session, java.util.List<NegotiationParty> parties)
MultilateralProtocolSessionManager will not start a new
Round after the current one. It will however finish all the turns
described in the
MultilateralProtocol.getRoundStructure(java.util.List, genius.core.session.Session)
method.isFinished in interface MultilateralProtocolsession - the current state of this sessionparties - all the parties involved in the negotiationpublic java.util.Map<NegotiationParty,java.util.List<NegotiationParty>> getActionListeners(java.util.List<NegotiationParty> parties)
getActionListeners in interface MultilateralProtocolparties - The parties involved in the current negotiationNegotiationParty that is responding to
a NegotiationParty.chooseAction(java.util.List) event,
and the value is a list of NegotiationParty that are
listening to that key party's response.public Bid getCurrentAgreement(Session session, java.util.List<NegotiationParty> parties)
getCurrentAgreement in interface MultilateralProtocolsession - The complete session history up to this pointparties - The parties involved in the current negotiationpublic int getNumberOfAgreeingParties(Session session, java.util.List<NegotiationParty> parties)
getNumberOfAgreeingParties in interface MultilateralProtocolsession - the current state of this sessionparties - The parties currently participatingpublic java.util.Collection<NegotiationParty> includeOnly(java.util.Collection<NegotiationParty> negotiationParties, java.lang.Class negotiationPartyClass)
negotiationParties - The original list of partiesnegotiationPartyClass - The type of parties to includepublic java.util.Collection<NegotiationParty> exclude(java.util.Collection<NegotiationParty> negotiationParties, java.lang.Class negotiationPartyClass)
negotiationParties - The original list of partiesnegotiationPartyClass - The type of parties to includepublic void endNegotiation()
endNegotiation in interface MultilateralProtocolpublic void endNegotiation(java.lang.String reason)
endNegotiation in interface MultilateralProtocolreason - Optionally give a reason why the protocol is finished.protected static java.util.Map<NegotiationParty,java.util.List<NegotiationParty>> listenToAll(java.util.List<NegotiationParty> parties)
parties - all the parties in the negotiationNegotiationParty and as values for
each key all other NegotiationPartys.protected static java.util.Map<NegotiationParty,java.util.List<NegotiationParty>> listenToNone(java.util.List<NegotiationParty> parties)
parties - all the parties in the negotiationNegotiationParty and as values an
empty list.