1 | package agents.anac.y2019.minf.etc;
|
---|
2 |
|
---|
3 | import java.util.HashSet;
|
---|
4 | import java.util.Map;
|
---|
5 | import java.util.Set;
|
---|
6 |
|
---|
7 | import genius.core.boaframework.AcceptanceStrategy;
|
---|
8 | import genius.core.boaframework.Actions;
|
---|
9 | import genius.core.boaframework.BOAparameter;
|
---|
10 | import genius.core.boaframework.NegotiationSession;
|
---|
11 | import genius.core.boaframework.OfferingStrategy;
|
---|
12 | import genius.core.boaframework.OpponentModel;
|
---|
13 | import genius.core.timeline.Timeline;
|
---|
14 |
|
---|
15 | public class AC_Next extends AcceptanceStrategy {
|
---|
16 |
|
---|
17 | private double a;
|
---|
18 | private double b;
|
---|
19 |
|
---|
20 | /** Negotiation Information */
|
---|
21 | private NegotiationInfo negotiationInfo;
|
---|
22 |
|
---|
23 | public AC_Next(){
|
---|
24 | }
|
---|
25 |
|
---|
26 | public AC_Next(NegotiationInfo negInfo){
|
---|
27 | negotiationInfo = negInfo;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public AC_Next(NegotiationSession negoSession, OfferingStrategy strat,
|
---|
31 | double alpha, double beta) {
|
---|
32 | this.negotiationSession = negoSession;
|
---|
33 | this.offeringStrategy = strat;
|
---|
34 | this.a = alpha;
|
---|
35 | this.b = beta;
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | public void init(NegotiationSession negoSession, OfferingStrategy strat,
|
---|
40 | OpponentModel opponentModel, Map<String, Double> parameters)
|
---|
41 | throws Exception {
|
---|
42 | this.negotiationSession = negoSession;
|
---|
43 | this.offeringStrategy = strat;
|
---|
44 |
|
---|
45 | if (parameters.get("a") != null || parameters.get("b") != null) {
|
---|
46 | a = parameters.get("a");
|
---|
47 | b = parameters.get("b");
|
---|
48 | } else {
|
---|
49 | a = 1;
|
---|
50 | b = 0;
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | @Override
|
---|
55 | public String printParameters() {
|
---|
56 | String str = "[a: " + a + " b: " + b + "]";
|
---|
57 | return str;
|
---|
58 | }
|
---|
59 |
|
---|
60 | @Override
|
---|
61 | public Actions determineAcceptability() {
|
---|
62 | double time = negotiationSession.getTime();
|
---|
63 | double lastOpponentBidUtil = negotiationSession.getOpponentBidHistory()
|
---|
64 | .getLastBidDetails().getMyUndiscountedUtil();
|
---|
65 | double nextMyBidUtil = offeringStrategy.getNextBid().getMyUndiscountedUtil();
|
---|
66 | double threshold = negotiationInfo.getThreshold(time);
|
---|
67 |
|
---|
68 | if (a * lastOpponentBidUtil + b >= (nextMyBidUtil + threshold)/2.0D) {
|
---|
69 | return Actions.Accept;
|
---|
70 | }
|
---|
71 |
|
---|
72 | if (time >= 0.975 && lastOpponentBidUtil >= 0.9D) {
|
---|
73 | return Actions.Accept;
|
---|
74 | }
|
---|
75 |
|
---|
76 | if (threshold <= negotiationSession.getUtilitySpace().getReservationValueUndiscounted()){
|
---|
77 | return Actions.Break;
|
---|
78 | }
|
---|
79 |
|
---|
80 | if (negotiationSession.getTimeline().getType() == Timeline.Type.Time && time >= 0.999) {
|
---|
81 | if (negotiationSession.getUtilitySpace().getReservationValueUndiscounted() <= lastOpponentBidUtil) {
|
---|
82 | return Actions.Accept;
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | if (negotiationSession.getTimeline().getType() == Timeline.Type.Rounds
|
---|
87 | && negotiationSession.getTimeline().getCurrentTime() == negotiationSession.getTimeline().getTotalTime()-1){
|
---|
88 | if (negotiationSession.getUtilitySpace().getReservationValueUndiscounted() <= lastOpponentBidUtil) {
|
---|
89 | if(!negotiationInfo.isFirst() ||
|
---|
90 | negotiationSession.getOpponentBidHistory().getBestBidDetails().getMyUndiscountedUtil()
|
---|
91 | != negotiationSession.getOpponentBidHistory().getWorstBidDetails().getMyUndiscountedUtil()){
|
---|
92 | return Actions.Accept;
|
---|
93 | }
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 | return Actions.Reject;
|
---|
98 | }
|
---|
99 |
|
---|
100 | @Override
|
---|
101 | public Set<BOAparameter> getParameterSpec() {
|
---|
102 |
|
---|
103 | Set<BOAparameter> set = new HashSet<BOAparameter>();
|
---|
104 | set.add(new BOAparameter("a", 1.0,
|
---|
105 | "Accept when the opponent's utility * a + b is greater than the utility of our current bid"));
|
---|
106 | set.add(new BOAparameter("b", 0.0,
|
---|
107 | "Accept when the opponent's utility * a + b is greater than the utility of our current bid"));
|
---|
108 |
|
---|
109 | return set;
|
---|
110 | }
|
---|
111 |
|
---|
112 | @Override
|
---|
113 | public String getName() {
|
---|
114 | return "AC_Next";
|
---|
115 | }
|
---|
116 | }
|
---|