source: src/main/java/agents/rlboa/AverageTitForTatOfferingGamma1.java

Last change on this file was 153, checked in by Aron Hammond, 6 years ago

Added function to calculate opposition to MultiLateralAnalysis.java

Moved code to add RLBOA listeners to RLBOAUtils is misc package

!! close SessionInfo after tournament; this caused /tmp/ to fill up with GeniusData files

This commit finalized the RLBOA project and it is now ready for use

Our own package (uva.project.:

  • Moved to agents.rlboa
  • Added opponents and strategies that are mentioned in the report
  • Change class hierarchy, agents can now extend from RLBOAagentBilateral to inherit RL functionality.
  • States extend from AbstractState
File size: 3.1 KB
Line 
1package agents.rlboa;
2
3import genius.core.Bid;
4import genius.core.bidding.BidDetails;
5import genius.core.boaframework.*;
6import genius.core.utility.AbstractUtilitySpace;
7
8import java.util.List;
9
10public class AverageTitForTatOfferingGamma1 extends OfferingStrategy {
11
12 private int gamma = 1;
13 private int k = 0;
14 private List<BidDetails> allBids;
15
16 private double minUtil;
17 private double maxUtil;
18
19 public AverageTitForTatOfferingGamma1(NegotiationSession negotiationSession, OpponentModel opponentModel, OMStrategy omStrategy) {
20 super.init(negotiationSession, null);
21
22 OutcomeSpace sortedOutcomeSpace = new SortedOutcomeSpace(this.negotiationSession.getUtilitySpace());
23 this.negotiationSession.setOutcomeSpace(sortedOutcomeSpace);
24 allBids = sortedOutcomeSpace.getAllOutcomes();
25
26 // get min/max utility obtainable
27 try {
28 AbstractUtilitySpace utilitySpace = this.negotiationSession.getUtilitySpace();
29 Bid maxUtilBid = utilitySpace.getMaxUtilityBid();
30 Bid minUtilBid = utilitySpace.getMinUtilityBid();
31 maxUtil = utilitySpace.getUtility(maxUtilBid);
32 minUtil = utilitySpace.getUtility(minUtilBid);
33 minUtil = Math.max(minUtil, utilitySpace.getReservationValueUndiscounted());
34 } catch (Exception e) {
35 // exception is thrown by getMaxUtilityBid if there are no bids in the outcomespace
36 // but I guess that's pretty rare. Default to 0.0 - 1.0 to prevent crashes.
37 maxUtil = 1.0;
38 minUtil = 0.0;
39 }
40 }
41
42 @Override
43 public BidDetails determineOpeningBid() {
44 BidDetails openingsBid = allBids.get(k);
45 k++;
46 return openingsBid;
47 }
48
49 @Override
50 public BidDetails determineNextBid() {
51 int opponentWindowSize = this.negotiationSession.getOpponentBidHistory().size();
52 BidDetails nextBid = null;
53
54 // in the paper, the condition of applicability is t_n > 2*gamma; but because
55 // we keep track of opponent/own bids seperately we have devide the threshold by 2
56 // we can use averageTitForTat if the number of bids made by the opponent is larger
57 // than the window we average over
58 if (opponentWindowSize > gamma) {
59 double targetUtility = this.averageTitForTat();
60 nextBid = this.negotiationSession.getOutcomeSpace().getBidNearUtility(targetUtility);
61 } else {
62 nextBid = this.determineOpeningBid();
63 }
64
65 return nextBid;
66 }
67
68 private double averageTitForTat() {
69
70 // determine relative change of opponent bid
71 int tOpp = this.negotiationSession.getOpponentBidHistory().size() - 1;
72 List<BidDetails> opponentHistory = this.negotiationSession.getOpponentBidHistory().getHistory();
73
74 double opponentLastBid = opponentHistory.get(tOpp).getMyUndiscountedUtil();
75 double opponentFirstBidInWindow = opponentHistory.get(tOpp - gamma).getMyUndiscountedUtil();
76 double relativeChangeOpponent = opponentFirstBidInWindow / opponentLastBid;
77
78 // target utility is the same change applied to our last bid
79 double myLastBid = this.negotiationSession.getOwnBidHistory().getLastBidDetails().getMyUndiscountedUtil();
80 double targetUtil = relativeChangeOpponent * myLastBid;
81
82 return Math.min(Math.max(targetUtil, minUtil), maxUtil);
83 }
84
85 @Override
86 public String getName() {
87 return "AverageTitForTat2 offering";
88 }
89
90}
Note: See TracBrowser for help on using the repository browser.