source: src/test/java/bilateralexamples/boacomponents/AC_Uncertain.java@ 346

Last change on this file since 346 was 184, checked in by Tim Baarslag, 6 years ago

Created bilateralexamples

File size: 1.6 KB
RevLine 
[184]1package bilateralexamples.boacomponents;
[127]2
3import java.util.List;
4
5import genius.core.Bid;
6import genius.core.boaframework.AcceptanceStrategy;
7import genius.core.boaframework.Actions;
8import 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 */
20public class AC_Uncertain extends AcceptanceStrategy {
21
22 @Override
23 public Actions determineAcceptability() {
24 Bid receivedBid = negotiationSession.getOpponentBidHistory()
25 .getLastBid();
26 Bid lastOwnBid = negotiationSession.getOwnBidHistory().getLastBid();
27 if (receivedBid == null || lastOwnBid == null) {
28 return Actions.Reject;
29 }
30
31 UserModel userModel = negotiationSession.getUserModel();
32 if (userModel != null) {
33 List<Bid> bidOrder = userModel.getBidRanking().getBidOrder();
34 if (bidOrder.contains(receivedBid)) {
35 double percentile = (bidOrder.size()
36 - bidOrder.indexOf(receivedBid))
37 / (double) bidOrder.size();
38 if (percentile < 0.1)
39 return Actions.Accept;
40 }
41 } else {
42 // we have a normal utilityspace
43 double otherLastUtil = negotiationSession.getUtilitySpace()
44 .getUtility(receivedBid);
45 double myLastUtil = negotiationSession.getUtilitySpace()
46 .getUtility(lastOwnBid);
47 if (otherLastUtil >= 0.9 * myLastUtil) {
48 return Actions.Accept;
49 }
50 }
51 return Actions.Reject;
52 }
53
54 @Override
55 public String getName() {
56 return "AC uncertainty example";
57 }
[117]58}
Note: See TracBrowser for help on using the repository browser.