1 | package agents.anac.y2019.authenticagent.acceptancestrategy;
|
---|
2 |
|
---|
3 | import authenticagent.biddingstrategy.services.WooldridgeTimeDependentService;
|
---|
4 | import authenticagent.dataclasses.LastReceivedOffer;
|
---|
5 | import authenticagent.serviceclasses.GenerateRankByHistoryService;
|
---|
6 | import authenticagent.serviceclasses.ReservedRankBidService;
|
---|
7 | import authenticagent.serviceclasses.SafeBidUtilityService;
|
---|
8 | import genius.core.AgentID;
|
---|
9 | import genius.core.actions.Accept;
|
---|
10 | import genius.core.actions.Action;
|
---|
11 | import genius.core.actions.EndNegotiation;
|
---|
12 | import genius.core.timeline.TimeLineInfo;
|
---|
13 | import genius.core.utility.UtilitySpace;
|
---|
14 |
|
---|
15 | public class IQSonAcceptanceStrategy extends AbstractAcceptanceStrategy {
|
---|
16 |
|
---|
17 | private UtilitySpace utilitySpace;
|
---|
18 | private TimeLineInfo timeLineInfo;
|
---|
19 | private double MIN_UTILITY;
|
---|
20 |
|
---|
21 | public IQSonAcceptanceStrategy(UtilitySpace us, TimeLineInfo tli){
|
---|
22 | super(us);
|
---|
23 | utilitySpace = us;
|
---|
24 | timeLineInfo = tli;
|
---|
25 | MIN_UTILITY = 0.34;
|
---|
26 | }
|
---|
27 |
|
---|
28 | @Override
|
---|
29 | public Action acceptOrEnd(AgentID partyId){
|
---|
30 | if(LastReceivedOffer.bid == null)
|
---|
31 | return null;
|
---|
32 | double offeredUtility = SafeBidUtilityService.getUtility(LastReceivedOffer.bid);
|
---|
33 | if (isAcceptable(offeredUtility)) {
|
---|
34 | return new Accept(partyId, LastReceivedOffer.bid);
|
---|
35 | }
|
---|
36 | if(timeLineInfo.getTime() >= 0.95 && !partnerLastBidHasUtilMoreThanResVal(offeredUtility))
|
---|
37 | return new EndNegotiation(partyId);
|
---|
38 | return null;
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | protected boolean isAcceptable(double offeredUtility) {
|
---|
43 | double time = timeLineInfo.getTime();
|
---|
44 | WooldridgeTimeDependentService wooldridgeTimeDependentService = new WooldridgeTimeDependentService(utilitySpace, timeLineInfo);
|
---|
45 | double myLastBidUtility = GenerateRankByHistoryService.getOurLastBidUtility();
|
---|
46 | // if(time >= 0.99 && partnerLastBidHasUtilMoreThanResVal(offeredUtility))
|
---|
47 | // return true;
|
---|
48 |
|
---|
49 | if(time >= 0.95 && (MIN_UTILITY <= offeredUtility) && partnerLastBidHasUtilMoreThanResVal(offeredUtility))
|
---|
50 | return true;
|
---|
51 |
|
---|
52 | if(wooldridgeTimeDependentService.generateUtilityForABid() < offeredUtility)
|
---|
53 | return false;
|
---|
54 |
|
---|
55 | if(!partnerLastBidHasUtilMoreThanResVal(offeredUtility)) {
|
---|
56 | return false;
|
---|
57 | }
|
---|
58 | if(offeredUtility > GenerateRankByHistoryService.ourBidsAverageUtility())
|
---|
59 | return false;
|
---|
60 | return myLastBidUtility <= offeredUtility && MIN_UTILITY <= offeredUtility && partnerLastBidHasUtilMoreThanResVal(offeredUtility);
|
---|
61 | }
|
---|
62 |
|
---|
63 | private boolean partnerLastBidHasUtilMoreThanResVal(double offeredUtilFromOpponent){
|
---|
64 | double resValue = ReservedRankBidService.reservationValueFor(utilitySpace);
|
---|
65 | return offeredUtilFromOpponent >= resValue;
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|