source: src/main/java/agents/FunctionalAcceptor.java@ 126

Last change on this file since 126 was 126, 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

Added input for strategyParameters to SessionPanel (gui)

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

Our own package:

  • 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: 1.9 KB
Line 
1package agents;
2
3import java.util.ArrayList;
4
5import genius.core.Bid;
6import genius.core.SupportedNegotiationSetting;
7import genius.core.timeline.DiscreteTimeline;
8
9/**
10 * uses the cutoffs to accept
11 */
12public class FunctionalAcceptor extends TimeDependentAgent {
13 double rv = -0.1;
14 int ownTotalRounds = 0;
15 private static ArrayList<Double> cutoffs;
16
17 public void init() {
18 rv = utilitySpace.getReservationValue();
19 ownTotalRounds = (getTotalRounds() - 1) / 2;
20
21 cutoffs = new ArrayList<Double>(ownTotalRounds);
22 for (int i = 0; i < ownTotalRounds; i++)
23 cutoffs.add(bid(i + 1));
24
25 super.init();
26 }
27
28 @Override
29 public double getE() {
30 return 0;
31 }
32
33 @Override
34 public String getName() {
35 return "FunctionalAcceptor";
36 }
37
38 public double bid(int j) {
39 if (j == 1)
40 return 0.5 + 0.5 * rv;
41 else
42 return 0.5 + 0.5 * Math.pow(bid(j - 1), 2);
43 }
44
45 public double functionalReservationValue() {
46 boolean immediate = false;
47
48 if (!immediate) {
49 return cutoffs.get(getOwnRoundsLeft());
50 } else {
51 // immediate acceptance case
52 return utilitySpace.getReservationValue();
53 }
54 }
55
56 @Override
57 public boolean isAcceptable(Bid plannedBid) {
58 Bid opponentLastBid = getOpponentLastBid();
59 if (getUtility(opponentLastBid) >= functionalReservationValue())
60 return true;
61 return false;
62 }
63
64 // discrete rounds' methods
65 public int getRound() {
66 return ((DiscreteTimeline) timeline).getRound();
67 }
68
69 public int getRoundsLeft() {
70 return ((DiscreteTimeline) timeline).getRoundsLeft();
71 }
72
73 public int getOwnRoundsLeft() {
74 return ((DiscreteTimeline) timeline).getOwnRoundsLeft();
75 }
76
77 public int getTotalRounds() {
78 return ((DiscreteTimeline) timeline).getTotalRounds();
79 }
80
81 public double getTotalTime() {
82 return ((DiscreteTimeline) timeline).getTotalTime();
83 }
84
85 @Override
86 public SupportedNegotiationSetting getSupportedNegotiationSetting() {
87 return SupportedNegotiationSetting.getLinearUtilitySpaceInstance();
88 }
89}
Note: See TracBrowser for help on using the repository browser.