source: src/main/java/genius/core/parties/NegotiationParty.java

Last change on this file was 199, checked in by Tim Baarslag, 5 years ago

60s timeout default

File size: 4.5 KB
Line 
1package genius.core.parties;
2
3import java.util.List;
4
5import java.util.Map;
6
7import java.io.Serializable;
8
9import genius.core.AgentID;
10import genius.core.Bid;
11import genius.core.Deadline;
12import genius.core.actions.Action;
13import genius.core.persistent.PersistentDataContainer;
14import genius.core.protocol.MultilateralProtocol;
15import genius.core.protocol.StackedAlternatingOffersProtocol;
16import genius.core.timeline.TimeLineInfo;
17import genius.core.utility.AbstractUtilitySpace;
18import genius.core.xml.XmlWriteStream;
19
20/**
21 * Base interface for Negotiation parties. All parties must minimally implement
22 * this interface. Parties can extend {@link AbstractNegotiationParty} to get
23 * more support from the parent class. Parties can do multilateral negotiations.
24 * Notice that 'multilateral' includes 'bilateral'.
25 *
26 * <h1>Protocol</h1>
27 * <p>
28 * Your implementation must adhere to the protocol that it specifies in
29 * {@link #getProtocol()}. If it doesn't, it may be kicked from the negotiation
30 * at runtime.
31 *
32 * <p>
33 * Implementors of this class must have a public no-argument constructor. In
34 * fact we recommend not to implement any constructor at all and do
35 * initialization in the init() call.
36 * <p>
37 * Immediately after construction of the class, the functiondsf
38 * {@link #init(AbstractUtilitySpace, Deadline, TimeLineInfo, long, AgentID,PersistentDataContainer)}
39 * will be called.
40 *
41 * <h1>Sand-boxing</h1>
42 * <p>
43 * The functions in this interface are implemented by competitors in a
44 * competition of agents. All calls to this interface may be sand-boxed in an
45 * attempt to ensure the competition will follow the protocols (instead of
46 * crashing). Sand-boxing attempts to protect the rest of the system for
47 * out-of-memory, time-out, throws, and various types of {@link SecurityManager}
48 * related issues (eg calling {@link System#exit(int)}) that may occur inside
49 * the implemented party.
50 * </p>
51 * <p>
52 * Some functions are limited to a fixed time limit, eg 1 second. Other
53 * functions may be limited to a deadline as set in the actual settings for the
54 * negotiation. In that case, the deadline is a global deadline for which the
55 * entire negotiation session must be completed. If the deadline is round based,
56 * the session is usually also time-limited to DEFAULT_TIME_OUT seconds, to ensure that even
57 * in a round-based negotiation, the negotiotion will end in a reasonable time.
58 * </p>
59 */
60public interface NegotiationParty extends Serializable {
61 /**
62 * Initializes the party, informing it of many negotiation details. This
63 * MUST be called exactly once, immediately after construction of any class
64 * implementing this.
65 *
66 * @param info
67 * information about the negotiation that this party is part of.
68 */
69 public void init(NegotiationInfo info);
70
71 /**
72 * When this function is called, it is expected that the Party chooses one
73 * of the actions from the possible action list and returns an instance of
74 * the chosen action.
75 *
76 *
77 * @param possibleActions
78 * List of all actions possible.
79 * @return The chosen {@link Action}.
80 */
81 public Action chooseAction(List<Class<? extends Action>> possibleActions);
82
83 /**
84 * This method is called to inform the party that another
85 * {@link NegotiationParty} chose an {@link Action}.
86 *
87 * @param sender
88 * The initiator of the action.This is either the AgentID, or
89 * null if the sender is not an agent (e.g., the protocol).
90 * @param action
91 * The action performed
92 */
93 void receiveMessage(AgentID sender, Action action);
94
95 /**
96 * @return a human-readable description for this party.
97 */
98 public String getDescription();
99
100 /**
101 * Get the protocol that this party supports.
102 *
103 *
104 * @return the actual supported {@link MultilateralProtocol}, usually
105 * {@link StackedAlternatingOffersProtocol}.
106 */
107 public Class<? extends MultilateralProtocol> getProtocol();
108
109 /**
110 * This is called to inform the agent that the negotiation has been ended.
111 * This allows the agent to record some final conclusions about the run.
112 *
113 * @param acceptedBid
114 * the final accepted bid, or null if no agreement was reached.
115 * @return {@link Map} containing data to log for this agent. null is equal
116 * to returning an empty HashMap. Typically, this info will be
117 * logged by {@link XmlWriteStream#write(String, java.util.Map)} to
118 * an XML file.
119 */
120 public Map<String, String> negotiationEnded(Bid acceptedBid);
121}
Note: See TracBrowser for help on using the repository browser.