1 | package negotiator.boaframework.offeringstrategy.anac2010;
|
---|
2 |
|
---|
3 | import java.util.Collections;
|
---|
4 | import java.util.LinkedList;
|
---|
5 | import java.util.Map;
|
---|
6 | import java.util.Random;
|
---|
7 |
|
---|
8 | import genius.core.Bid;
|
---|
9 | import genius.core.BidIterator;
|
---|
10 | import genius.core.bidding.BidDetails;
|
---|
11 | import genius.core.bidding.BidDetailsStrictSorterUtility;
|
---|
12 | import genius.core.boaframework.NegotiationSession;
|
---|
13 | import genius.core.boaframework.NoModel;
|
---|
14 | import genius.core.boaframework.OMStrategy;
|
---|
15 | import genius.core.boaframework.OfferingStrategy;
|
---|
16 | import genius.core.boaframework.OpponentModel;
|
---|
17 | import negotiator.boaframework.opponentmodel.DefaultModel;
|
---|
18 | import negotiator.boaframework.sharedagentstate.anac2010.YushuSAS;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * This is the decoupled Offering Strategy for Nozomi (ANAC2010). The code was
|
---|
22 | * taken from the ANAC2010 Yushu and adapted to work within the BOA framework.
|
---|
23 | *
|
---|
24 | * DEFAULT OM: None
|
---|
25 | *
|
---|
26 | * Decoupling Negotiating Agents to Explore the Space of Negotiation Strategies
|
---|
27 | * T. Baarslag, K. Hindriks, M. Hendrikx, A. Dirkzwager, C.M. Jonker
|
---|
28 | *
|
---|
29 | * @author Alex Dirkzwager, Mark Hendrikx
|
---|
30 | */
|
---|
31 | public class Yushu_Offering extends OfferingStrategy {
|
---|
32 |
|
---|
33 | BidDetails suggestBid = null; // the bid suggested based on op's bids
|
---|
34 | BidDetails maxUtilBid = null;
|
---|
35 | private double highPosUtil; // the highest utility that can be achieved
|
---|
36 | Random random200;
|
---|
37 | private final boolean TEST_EQUIVALENCE = false;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Empty constructor called by BOA framework.
|
---|
41 | */
|
---|
42 | public Yushu_Offering() {
|
---|
43 | }
|
---|
44 |
|
---|
45 | @Override
|
---|
46 | public void init(NegotiationSession domainKnow, OpponentModel model, OMStrategy omStrategy,
|
---|
47 | Map<String, Double> parameters) throws Exception {
|
---|
48 | if (model instanceof DefaultModel) {
|
---|
49 | model = new NoModel();
|
---|
50 | }
|
---|
51 | super.init(domainKnow, model, omStrategy, parameters);
|
---|
52 |
|
---|
53 | maxUtilBid = negotiationSession.getMaxBidinDomain();
|
---|
54 | helper = new YushuSAS(negotiationSession);
|
---|
55 | highPosUtil = negotiationSession.getMaxBidinDomain().getMyUndiscountedUtil();
|
---|
56 | if (TEST_EQUIVALENCE) {
|
---|
57 | random200 = new Random(200);
|
---|
58 | } else {
|
---|
59 | random200 = new Random();
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | @Override
|
---|
64 | public BidDetails determineOpeningBid() {
|
---|
65 | if (negotiationSession.getOpponentBidHistory().size() > 0) {
|
---|
66 | ((YushuSAS) helper).updateBelief(negotiationSession.getOpponentBidHistory().getLastBidDetails());
|
---|
67 | }
|
---|
68 | ((YushuSAS) helper).setPreviousTime(negotiationSession.getTime());
|
---|
69 | nextBid = maxUtilBid;
|
---|
70 | return nextBid;
|
---|
71 | }
|
---|
72 |
|
---|
73 | @Override
|
---|
74 | public BidDetails determineNextBid() {
|
---|
75 | ((YushuSAS) helper).updateBelief(negotiationSession.getOpponentBidHistory().getLastBidDetails());
|
---|
76 |
|
---|
77 | BidDetails myLastBid = negotiationSession.getOwnBidHistory().getLastBidDetails();
|
---|
78 |
|
---|
79 | double targetUtility;
|
---|
80 | if (myLastBid == null)
|
---|
81 | targetUtility = 1;
|
---|
82 | else {
|
---|
83 | targetUtility = ((YushuSAS) helper).calculateTargetUtility();
|
---|
84 | }
|
---|
85 | suggestBid = ((YushuSAS) helper).getSuggestBid();
|
---|
86 | if (this.suggestBid != null) {
|
---|
87 | nextBid = this.suggestBid;
|
---|
88 | } else if (targetUtility >= highPosUtil) {
|
---|
89 | nextBid = maxUtilBid;
|
---|
90 |
|
---|
91 | } else {
|
---|
92 | try {
|
---|
93 | nextBid = getNextBid(targetUtility);
|
---|
94 | } catch (Exception e) {
|
---|
95 | e.printStackTrace();
|
---|
96 | }
|
---|
97 | }
|
---|
98 | return nextBid;
|
---|
99 | }
|
---|
100 |
|
---|
101 | private BidDetails getNextBid(double targetuti) throws Exception {
|
---|
102 | BidDetails potentialBid = null;
|
---|
103 | double maxdiff = Double.MAX_VALUE;
|
---|
104 | double tempmaxdiff = Double.MAX_VALUE;
|
---|
105 | BidDetails tempnextBid = null;
|
---|
106 |
|
---|
107 | LinkedList<BidDetails> candidates = new LinkedList<BidDetails>();
|
---|
108 |
|
---|
109 | BidIterator bidsIter = new BidIterator(negotiationSession.getUtilitySpace().getDomain());
|
---|
110 | while (bidsIter.hasNext()) {
|
---|
111 | Bid bid = bidsIter.next();
|
---|
112 | BidDetails tmpBid = new BidDetails(bid, negotiationSession.getUtilitySpace().getUtility(bid),
|
---|
113 | negotiationSession.getTime());
|
---|
114 |
|
---|
115 | double vlowbound;
|
---|
116 | if (((YushuSAS) helper).getRoundLeft() > 30)
|
---|
117 | vlowbound = Math.max(((YushuSAS) helper).getBestTenBids().get(0).getMyUndiscountedUtil(), targetuti);
|
---|
118 | else
|
---|
119 | vlowbound = 0.96 * targetuti;
|
---|
120 | if ((tmpBid.getMyUndiscountedUtil() > vlowbound) && (tmpBid.getMyUndiscountedUtil() < 1.08 * targetuti))
|
---|
121 | candidates.add(tmpBid);
|
---|
122 |
|
---|
123 | double currentdiff = Math.abs(tmpBid.getMyUndiscountedUtil() - targetuti);
|
---|
124 | if (currentdiff < tempmaxdiff) {
|
---|
125 | tempmaxdiff = currentdiff;
|
---|
126 | tempnextBid = tmpBid;
|
---|
127 | }
|
---|
128 |
|
---|
129 | if ((currentdiff < maxdiff) & (tmpBid.getMyUndiscountedUtil() > targetuti)) {
|
---|
130 | maxdiff = currentdiff;
|
---|
131 | potentialBid = tmpBid;
|
---|
132 | }
|
---|
133 | }
|
---|
134 | if (negotiationSession.getOwnBidHistory().size() > 10) {
|
---|
135 | candidates.add(potentialBid);
|
---|
136 | if (TEST_EQUIVALENCE) {
|
---|
137 | Collections.sort(candidates, new BidDetailsStrictSorterUtility());
|
---|
138 | }
|
---|
139 |
|
---|
140 | if (opponentModel instanceof NoModel) {
|
---|
141 | int indexc = (int) (random200.nextDouble() * candidates.size());
|
---|
142 | potentialBid = candidates.get(indexc);
|
---|
143 | } else {
|
---|
144 | potentialBid = omStrategy.getBid(candidates);
|
---|
145 | }
|
---|
146 | }
|
---|
147 | if (potentialBid == null) {
|
---|
148 | potentialBid = tempnextBid;
|
---|
149 | }
|
---|
150 | return potentialBid;
|
---|
151 | }
|
---|
152 |
|
---|
153 | @Override
|
---|
154 | public String getName() {
|
---|
155 | return "2010 - Yushu";
|
---|
156 | }
|
---|
157 | } |
---|