1 | package genius.core.boaframework;
|
---|
2 |
|
---|
3 | import java.io.Serializable;
|
---|
4 | import java.util.Map;
|
---|
5 |
|
---|
6 | import genius.core.bidding.BidDetails;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Describes a bidding strategy of an agent of the BOA framework.
|
---|
10 | *
|
---|
11 | * Tim Baarslag, Koen Hindriks, Mark Hendrikx, Alex Dirkzwager and Catholijn M.
|
---|
12 | * Jonker. Decoupling Negotiating Agents to Explore the Space of Negotiation
|
---|
13 | * Strategies
|
---|
14 | *
|
---|
15 | * @author Alex Dirkzwager, Mark Hendrikx
|
---|
16 | * @author W.Pasman: this now extends {@link BOA} to unite all BOA components.
|
---|
17 | * @version 15-12-11
|
---|
18 | */
|
---|
19 | public abstract class OfferingStrategy extends BOA {
|
---|
20 | /** The next bid the agent plans to present */
|
---|
21 | protected BidDetails nextBid;
|
---|
22 | /** Reference to the opponent model */
|
---|
23 | protected OpponentModel opponentModel;
|
---|
24 | /** Reference to the opponent model strategy */
|
---|
25 | protected OMStrategy omStrategy;
|
---|
26 | /**
|
---|
27 | * Reference to helper class used if there are dependencies between the
|
---|
28 | * acceptance condition an offering strategy
|
---|
29 | */
|
---|
30 | protected SharedAgentState helper;
|
---|
31 | /** Boolean to see if endNegotiation is called */
|
---|
32 | protected boolean endNegotiation;
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Initializes the offering strategy. If parameters are used, this method
|
---|
36 | * should be overridden.
|
---|
37 | *
|
---|
38 | * @param negotiationSession
|
---|
39 | * state of the negotiation.
|
---|
40 | * @param opponentModel
|
---|
41 | * opponent model which may be used.
|
---|
42 | * @param omStrategy
|
---|
43 | * opponent model strategy which may be used.
|
---|
44 | * @param parameters
|
---|
45 | * optional parameters for the offering strategy.
|
---|
46 | * @throws Exception
|
---|
47 | * if the offering strategy fails to initialize.
|
---|
48 | */
|
---|
49 | public void init(NegotiationSession negotiationSession, OpponentModel opponentModel, OMStrategy omStrategy,
|
---|
50 | Map<String, Double> parameters) throws Exception {
|
---|
51 | super.init(negotiationSession, parameters);
|
---|
52 | this.opponentModel = opponentModel;
|
---|
53 | this.omStrategy = omStrategy;
|
---|
54 | this.endNegotiation = false;
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Determines the first bid to be offered by the agent
|
---|
59 | *
|
---|
60 | * @return the opening bid of the agent.
|
---|
61 | */
|
---|
62 | public abstract BidDetails determineOpeningBid();
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Determines the next bid the agent will offer to the opponent
|
---|
66 | *
|
---|
67 | * @return bid to offer to the opponent.
|
---|
68 | */
|
---|
69 | public abstract BidDetails determineNextBid();
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * @return next bid to be offered to the opponent.
|
---|
73 | */
|
---|
74 | public BidDetails getNextBid() {
|
---|
75 | return nextBid;
|
---|
76 | }
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Set the next bid of the agent. This method is automatically called by the
|
---|
80 | * BOA framework.
|
---|
81 | *
|
---|
82 | * @param nextBid
|
---|
83 | * to offer to the opponent.
|
---|
84 | */
|
---|
85 | public void setNextBid(BidDetails nextBid) {
|
---|
86 | this.nextBid = nextBid;
|
---|
87 | }
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Return the Helper-object. A helper is used to hold the code shared
|
---|
91 | * between the offering strategy and acceptance strategy. A good design does
|
---|
92 | * not require a helper.
|
---|
93 | *
|
---|
94 | * @return helper with shared code.
|
---|
95 | */
|
---|
96 | public SharedAgentState getHelper() {
|
---|
97 | return helper;
|
---|
98 | }
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * @return true if the negotiation should be ended.
|
---|
102 | */
|
---|
103 | public boolean isEndNegotiation() {
|
---|
104 | return endNegotiation;
|
---|
105 | }
|
---|
106 |
|
---|
107 | @Override
|
---|
108 | public final void storeData(Serializable object) {
|
---|
109 | negotiationSession.setData(BoaType.BIDDINGSTRATEGY, object);
|
---|
110 | }
|
---|
111 |
|
---|
112 | @Override
|
---|
113 | public final Serializable loadData() {
|
---|
114 | return negotiationSession.getData(BoaType.BIDDINGSTRATEGY);
|
---|
115 | }
|
---|
116 |
|
---|
117 | } |
---|