public abstract class AbstractNegotiationParty extends java.lang.Object implements NegotiationParty
NegotiationParty
interface. This basic
implementation sets up some common variables for you.Modifier and Type | Field and Description |
---|---|
protected Deadline |
deadlines
map of all deadlines set for this party.
|
protected java.util.Random |
rand
Random seed used by this party.
|
protected Session |
session
This is purely for research purposes.
|
protected TimeLineInfo |
timeline
Time line used by the party if time deadline is set.
|
protected AbstractUtilitySpace |
utilitySpace
utility space used by this party (set in constructor).
|
Constructor and Description |
---|
AbstractNegotiationParty() |
Modifier and Type | Method and Description |
---|---|
protected Bid |
generateRandomBid()
Generates a random bid which will be generated using this.utilitySpace.
|
PersistentDataContainer |
getData() |
Action |
getLastReceivedAction() |
int |
getNumberOfParties() |
AgentID |
getPartyId() |
java.lang.Class<? extends MultilateralProtocol> |
getProtocol()
Get the protocol that this party supports.
|
protected Value |
getRandomValue(Issue currentIssue)
Gets a random value for the given issue.
|
TimeLineInfo |
getTimeLine()
Gets this agent's time line.
|
double |
getUtility(Bid bid)
Gets the utility for the given bid.
|
AbstractUtilitySpace |
getUtilitySpace()
Gets this agent's utility space.
|
double |
getUtilityWithDiscount(Bid bid)
Gets the time discounted utility for the given bid.
|
void |
init(AbstractUtilitySpace utilSpace,
Deadline dl,
TimeLineInfo tl,
long randomSeed,
AgentID agentId,
PersistentDataContainer data)
Initializes the party.
|
java.util.HashMap<java.lang.String,java.lang.String> |
negotiationEnded(Bid acceptedBid)
This is called to inform the agent that the negotiation has been ended.
|
void |
receiveMessage(AgentID sender,
Action act)
This method is called when another
NegotiationParty chose an
Action . |
void |
setNegotiationSession(Session ses)
sets the
session object. |
java.lang.String |
toString()
Returns a human readable string representation of this party.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
chooseAction, getDescription
protected TimeLineInfo timeline
protected Deadline deadlines
protected java.util.Random rand
protected AbstractUtilitySpace utilitySpace
protected Session session
public void init(AbstractUtilitySpace utilSpace, Deadline dl, TimeLineInfo tl, long randomSeed, AgentID agentId, PersistentDataContainer data)
NegotiationParty
init
in interface NegotiationParty
utilSpace
- (a copy of/readonly version of) the
AbstractUtilitySpace
to be used for this session.dl
- The deadline used for this negotiation.tl
- The TimeLineInfo
about current session.randomSeed
- A random seed that can be used for creating "consistent
random" behaviour.agentId
- The agent's ID.data
- storage space where the agent can store data that is
persistent over sessions. Depending on the run settings, each
[agentclass, profiles] tuple can have its own unique storage
that persists only during the run of a tournament. Between
sessions, this data is saved to disk to avoid memory issues
when other agents are running. If the storage is not empty,
this data is retrieved at the start of each session and saved
at the end of each session. The load is timeboxed by the
negotiation settings. The save time is limited to 1 second.
The programmer should ensure that storage is actually
serializable. This call is timeboxed by the negotiation
deadline settings.protected Bid generateRandomBid()
protected Value getRandomValue(Issue currentIssue) throws java.lang.Exception
currentIssue
- The issue to generate a random value forjava.lang.Exception
- if the issues type is not Discrete, Real or Integer.public double getUtility(Bid bid)
bid
- The bid to get the utility forpublic double getUtilityWithDiscount(Bid bid)
bid
- The bid to get the utility forpublic final AbstractUtilitySpace getUtilitySpace()
public TimeLineInfo getTimeLine()
public java.lang.String toString()
toString
in class java.lang.Object
public void receiveMessage(AgentID sender, Action act)
NegotiationParty
NegotiationParty
chose an
Action
. This call is timeboxed by the negotiation deadline
settings.receiveMessage
in interface NegotiationParty
sender
- The initiator of the action.This is either the AgentID, or
null if the sender is not an agent (e.g., the protocol).act
- The action performedpublic Action getLastReceivedAction()
Action
or null if nothing received yet.public int getNumberOfParties()
public final AgentID getPartyId()
public java.lang.Class<? extends MultilateralProtocol> getProtocol()
NegotiationParty
getProtocol
in interface NegotiationParty
MultilateralProtocol
, usually
StackedAlternatingOffersProtocol
. The call must finish
within 1 second.public java.util.HashMap<java.lang.String,java.lang.String> negotiationEnded(Bid acceptedBid)
NegotiationParty
negotiationEnded
in interface NegotiationParty
acceptedBid
- the final accepted bid, or null if no agreement was reached.Map
containing data to log for this agent. null is equal
to returning an empty HashMap. Typically, this info will be
logged by XmlWriteStream.write(String, java.util.Map)
public PersistentDataContainer getData()