1 | package agents.anac.y2019.kagent.boacomponents;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 |
|
---|
5 | import genius.core.Bid;
|
---|
6 | import genius.core.boaframework.AcceptanceStrategy;
|
---|
7 | import genius.core.boaframework.Actions;
|
---|
8 | import genius.core.uncertainty.UserModel;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Accepts:
|
---|
12 | * <ul>
|
---|
13 | * <li>if we have uncertainty profile, and we receive an offer in our highest
|
---|
14 | * 10% best bids.
|
---|
15 | * <li>if we have normal utilityspace, and we receive offer with a utility
|
---|
16 | * better than 90% of what we offered last.
|
---|
17 | * </ul>
|
---|
18 | * Discount is ignored.
|
---|
19 | */
|
---|
20 | public class AC_Uncertain_Kindly extends AcceptanceStrategy {
|
---|
21 |
|
---|
22 | private int loan;
|
---|
23 |
|
---|
24 | public AC_Uncertain_Kindly() {
|
---|
25 | super();
|
---|
26 | this.loan = 0;
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public Actions determineAcceptability() {
|
---|
31 | Bid receivedBid = negotiationSession.getOpponentBidHistory()
|
---|
32 | .getLastBid();
|
---|
33 | Bid lastOwnBid = negotiationSession.getOwnBidHistory().getLastBid();
|
---|
34 | if (receivedBid == null || lastOwnBid == null) {
|
---|
35 | return Actions.Reject;
|
---|
36 | }
|
---|
37 |
|
---|
38 | UserModel userModel = negotiationSession.getUserModel();
|
---|
39 | if (userModel != null) {
|
---|
40 | List<Bid> bidOrder = userModel.getBidRanking().getBidOrder();
|
---|
41 |
|
---|
42 |
|
---|
43 | if (bidOrder.contains(receivedBid)) {
|
---|
44 | double percentile = (bidOrder.size()
|
---|
45 | - bidOrder.indexOf(receivedBid))
|
---|
46 | / (double) bidOrder.size();
|
---|
47 | if (percentile < 0.1)
|
---|
48 | return Actions.Accept;
|
---|
49 | }
|
---|
50 | } else {
|
---|
51 |
|
---|
52 | // we have a normal utilityspace
|
---|
53 |
|
---|
54 | double otherLastUtil = negotiationSession.getUtilitySpace()
|
---|
55 | .getUtility(receivedBid);
|
---|
56 | double myLastUtil = negotiationSession.getUtilitySpace()
|
---|
57 | .getUtility(lastOwnBid);
|
---|
58 | if (otherLastUtil >= 0.95 * myLastUtil && loan < 10) {
|
---|
59 | System.err.print("loan plus");
|
---|
60 | loan += 1;
|
---|
61 | return Actions.Accept;
|
---|
62 | } else if (otherLastUtil >= 1.05 * myLastUtil) {
|
---|
63 | System.err.print("loan minus");
|
---|
64 | loan -= 1;
|
---|
65 | return Actions.Accept;
|
---|
66 | }
|
---|
67 | }
|
---|
68 | return Actions.Reject;
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public String getName() {
|
---|
73 | return "AC uncertainty example";
|
---|
74 | }
|
---|
75 | }
|
---|