1 | package agents.anac.y2019.authenticagent;
|
---|
2 |
|
---|
3 | import authenticagent.acceptancestrategy.AbstractAcceptanceStrategy;
|
---|
4 | import authenticagent.acceptancestrategy.IQSonAcceptanceStrategy;
|
---|
5 | import authenticagent.biddingstrategy.AbstractBiddingStrategy;
|
---|
6 | import authenticagent.biddingstrategy.IQSonBiddingStrategy;
|
---|
7 | import authenticagent.dataclasses.LastReceivedOffer;
|
---|
8 | import authenticagent.opponentmodeling.AbstractOpponentModeling;
|
---|
9 | import authenticagent.opponentmodeling.OpponentModelingByNNearestBids;
|
---|
10 | import authenticagent.serviceclasses.finaldecisionaboutthebid.AbstractFinalDecisionAboutTheBid;
|
---|
11 | import authenticagent.serviceclasses.finaldecisionaboutthebid.FinalBidByIQSonAndNNearestBids;
|
---|
12 | import authenticagent.serviceclasses.GenerateRankByHistoryService;
|
---|
13 | import authenticagent.serviceclasses.SafeBidUtilityService;
|
---|
14 | import genius.core.AgentID;
|
---|
15 | import genius.core.Bid;
|
---|
16 | import genius.core.actions.Accept;
|
---|
17 | import genius.core.actions.Action;
|
---|
18 | import genius.core.actions.Offer;
|
---|
19 | import genius.core.parties.AbstractNegotiationParty;
|
---|
20 | import genius.core.parties.NegotiationInfo;
|
---|
21 | import genius.core.utility.AbstractUtilitySpace;
|
---|
22 |
|
---|
23 | import java.util.*;
|
---|
24 |
|
---|
25 |
|
---|
26 | public class AuthenticAgent extends AbstractNegotiationParty {
|
---|
27 |
|
---|
28 | private AbstractBiddingStrategy abstractBiddingStrategy;
|
---|
29 | private AbstractOpponentModeling abstractOpponentModeling;
|
---|
30 | private AbstractFinalDecisionAboutTheBid abstractFinalDecisionAboutTheBid;
|
---|
31 | private AbstractAcceptanceStrategy abstractAcceptanceStrategy;
|
---|
32 | private ArrayList<Bid> opponentModelingBids;
|
---|
33 |
|
---|
34 | @Override
|
---|
35 | public void init(NegotiationInfo info){
|
---|
36 | super.init(info);
|
---|
37 | SafeBidUtilityService.init(utilitySpace, userModel);
|
---|
38 | abstractBiddingStrategy = new IQSonBiddingStrategy(utilitySpace, timeline);
|
---|
39 | abstractOpponentModeling = new OpponentModelingByNNearestBids(utilitySpace, userModel);
|
---|
40 | abstractFinalDecisionAboutTheBid = new FinalBidByIQSonAndNNearestBids(utilitySpace, userModel);
|
---|
41 | GenerateRankByHistoryService.init();
|
---|
42 | abstractAcceptanceStrategy = new IQSonAcceptanceStrategy(utilitySpace, timeline);
|
---|
43 | opponentModelingBids = new ArrayList<>();
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Override
|
---|
47 | public Action chooseAction(List<Class<? extends Action>> possibleActions)
|
---|
48 | {
|
---|
49 | Action resultAction = getToughAction();
|
---|
50 | if (resultAction != null)
|
---|
51 | {
|
---|
52 | return resultAction;
|
---|
53 | }
|
---|
54 | resultAction = abstractAcceptanceStrategy.acceptOrEnd(getPartyId());
|
---|
55 | if(resultAction != null)
|
---|
56 | {
|
---|
57 | return resultAction;
|
---|
58 | }
|
---|
59 | opponentModelingBids = abstractOpponentModeling.getRecommendedBids();
|
---|
60 | Bid bidByBiddingStrategy = abstractBiddingStrategy.getBid();
|
---|
61 | Bid finalBid = abstractFinalDecisionAboutTheBid.generateFinalBid(opponentModelingBids,
|
---|
62 | bidByBiddingStrategy);
|
---|
63 | resultAction = new Offer(getPartyId(), finalBid);
|
---|
64 | return resultAction;
|
---|
65 | }
|
---|
66 |
|
---|
67 | private Action getToughAction()
|
---|
68 | {
|
---|
69 | double minUtility = 0.9;
|
---|
70 | boolean domainIsNotSmall = SafeBidUtilityService.getNumberOfPossibleBids() > 1000;
|
---|
71 | if (timeline.getTime() < 0.17 && domainIsNotSmall)
|
---|
72 | {
|
---|
73 | if(LastReceivedOffer.bid != null)
|
---|
74 | if (SafeBidUtilityService.getUtility(LastReceivedOffer.bid) >= minUtility)
|
---|
75 | return new Accept(getPartyId(), LastReceivedOffer.bid);
|
---|
76 | return new Offer(getPartyId(), SafeBidUtilityService.getBidWithUtility(1));
|
---|
77 | }
|
---|
78 | return null;
|
---|
79 | }
|
---|
80 |
|
---|
81 | @Override
|
---|
82 | public void receiveMessage(AgentID sender, Action action)
|
---|
83 | {
|
---|
84 | super.receiveMessage(sender, action);
|
---|
85 | if (action instanceof Offer)
|
---|
86 | {
|
---|
87 | Bid bid = ((Offer) action).getBid();
|
---|
88 | LastReceivedOffer.updateLastOffer(sender.toString(), bid);
|
---|
89 | abstractOpponentModeling.addNewOpponentIfNotExists(sender.toString());
|
---|
90 | double receivedUtility = SafeBidUtilityService.getUtility(bid);
|
---|
91 | GenerateRankByHistoryService.addBidToOpponentsBidsHistory(receivedUtility, bid);
|
---|
92 | }
|
---|
93 | }
|
---|
94 |
|
---|
95 | @Override
|
---|
96 | public String getDescription()
|
---|
97 | {
|
---|
98 | return "This is AuthenticAgent";
|
---|
99 | }
|
---|
100 |
|
---|
101 | @Override
|
---|
102 | public AbstractUtilitySpace estimateUtilitySpace()
|
---|
103 | {
|
---|
104 | return super.estimateUtilitySpace();
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|