source: src/main/java/agents/anac/y2012/AgentLG/AgentLG.java@ 68

Last change on this file since 68 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 4.4 KB
Line 
1package agents.anac.y2012.AgentLG;
2
3import genius.core.Agent;
4import genius.core.Bid;
5import genius.core.SupportedNegotiationSetting;
6import genius.core.actions.Accept;
7import genius.core.actions.Action;
8import genius.core.actions.Offer;
9import genius.core.utility.AdditiveUtilitySpace;
10
11/**
12 * The Agent is most of the time stubborn but in the end it starts to
13 * compromise. In the beginning it votes in the beginning its best votes. when
14 * the time is 0-0.6 : it votes incrementally from its best utility to a minimum
15 * of 0.75* utility and learns opponent utility. when the time is 0.6-0.9: it
16 * starts to compromise and chooses better bid for the opponents that still good
17 * for it only if the opponent is also comprising (the rate of compromise
18 * depends on the opponent and on the discount factor). when the time over 0.9:
19 * the agents starts to "panic" and compromise more frequently. when the time is
20 * over(more then 0.9995 ) it chooses opponents max utility bid for it. The
21 * Agent accept an offer only if it offered before by the agent or the time is
22 * almost over and the bid is close enough to its worst offer.
23 *
24 * @author Luba Golosman
25 */
26public class AgentLG extends Agent {
27
28 private Bid myLastBid = null;
29 private Bid oponnetLastBid = null;
30
31 private BidChooser bidChooser = null;
32 private OpponentBids oppenentsBid;
33 private boolean bidLast = false;
34
35 @Override
36 public Action chooseAction() {
37
38 Action currentAction = null;
39 try {
40 double time = timeline.getTime();
41
42 // first bid -> vote the optimal bid
43 if (myLastBid == null || oponnetLastBid == null) {
44 myLastBid = this.utilitySpace.getMaxUtilityBid();
45 currentAction = new Offer(getAgentID(), myLastBid);
46 } else {
47 double opponentUtility = this.utilitySpace
48 .getUtilityWithDiscount(oponnetLastBid, time);
49 double myUtility = this.utilitySpace
50 .getUtilityWithDiscount(myLastBid, time);
51
52 // accept if opponent offer is good enough or there is no time
53 // and the offer is 'good'
54 if (opponentUtility >= myUtility * 0.99
55 || (time > 0.999 && opponentUtility >= myUtility * 0.9)
56 || bidChooser
57 .getMyBidsMinUtility(time) <= opponentUtility) {
58 currentAction = new Accept(getAgentID(), oponnetLastBid);
59 } else if (bidLast) {
60 currentAction = new Offer(getAgentID(), myLastBid);
61 }
62 // there is lot of time ->learn the opponent and bid the 1/4
63 // most optimal bids
64 else if (time < 0.6) {
65
66 currentAction = bidChooser.getNextOptimicalBid(time);
67 } else {
68 // the time is over -> bid the opponents max utility bid for
69 // me
70 if (time >= 0.9995) {
71 myLastBid = oppenentsBid.getMaxUtilityBidForMe();
72 if (utilitySpace.getUtilityWithDiscount(myLastBid,
73 time) < utilitySpace
74 .getReservationValueWithDiscount(time))
75 myLastBid = bidChooser.getMyminBidfromBids();
76 currentAction = new Offer(getAgentID(), myLastBid);
77 } else {
78 // Comprise and chose better bid for the opponents that
79 // still good for me
80 currentAction = bidChooser.getNextBid(time);
81 }
82 }
83 }
84 if (currentAction instanceof Offer) {
85 myLastBid = ((Offer) currentAction).getBid();
86 if (oppenentsBid.getOpponentsBids().contains(myLastBid)) {
87 bidLast = true;
88 }
89 }
90
91 } catch (Exception e) {
92 currentAction = new Accept(getAgentID(), oponnetLastBid);
93 }
94
95 return currentAction;
96 }
97
98 @Override
99 public String getName() {
100 return "AgentLG";
101 }
102
103 @Override
104 public void init() {
105 oppenentsBid = new OpponentBids(utilitySpace);
106 bidChooser = new BidChooser((AdditiveUtilitySpace) this.utilitySpace,
107 getAgentID(), oppenentsBid);
108 }
109
110 @Override
111 public void ReceiveMessage(Action opponentAction) {
112 if (opponentAction instanceof Offer) {
113 oponnetLastBid = ((Offer) opponentAction).getBid();
114
115 try {
116 oppenentsBid.addBid(((Offer) opponentAction).getBid());
117 oppenentsBid.getOpponentBidUtility(
118 this.utilitySpace.getDomain(), oponnetLastBid);
119 } catch (Exception e) {
120 e.printStackTrace();
121 }
122 }
123
124 }
125
126 @Override
127 public String getVersion() {
128 return "1.1";
129 }
130
131 @Override
132 public SupportedNegotiationSetting getSupportedNegotiationSetting() {
133 return SupportedNegotiationSetting.getLinearUtilitySpaceInstance();
134 }
135
136 @Override
137 public String getDescription() {
138 return "ANAC2012";
139 }
140}
Note: See TracBrowser for help on using the repository browser.