1 | package ai2020.group6;
|
---|
2 |
|
---|
3 | import java.math.BigDecimal;
|
---|
4 |
|
---|
5 | import geniusweb.actions.Vote;
|
---|
6 | import geniusweb.inform.Settings;
|
---|
7 | import geniusweb.issuevalue.Bid;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * MAPowerWeightedExponential behaves like the MAExponential agent when it
|
---|
11 | * comes to the acceptance and bidding strategies.
|
---|
12 | *
|
---|
13 | * During the OptIn phase, this agent scales the utility of a bid with
|
---|
14 | * 1+v^(ve * (1-t)^e)) such that the utility of a bid increases the more
|
---|
15 | * support (v) it has. "ve" and "e" and parameters defaulting to 1.
|
---|
16 | *
|
---|
17 | * @author Group 6
|
---|
18 | */
|
---|
19 | public class MAPowerWeightedExponential extends MADefaultParty {
|
---|
20 |
|
---|
21 | @Override
|
---|
22 | protected IAcceptanceStrategy getAccceptanceStrategy ( Settings settings ) {
|
---|
23 | Object val = settings.getParameters().get("minPower");
|
---|
24 | Integer minpower = (val instanceof Integer) ? (Integer) val : 2;
|
---|
25 | val = settings.getParameters().get("maxPower");
|
---|
26 | Integer maxpower = (val instanceof Integer) ? (Integer) val : Integer.MAX_VALUE;
|
---|
27 | val = settings.getParameters().get("upperThreshold");
|
---|
28 | Double upperThreshold = (val instanceof Double) ? (Double) val : 1.0;
|
---|
29 | val = settings.getParameters().get("lowerThreshold");
|
---|
30 | Double lowerThreshold = (val instanceof Double) ? (Double) val : 0.0;
|
---|
31 | val = settings.getParameters().get("e");
|
---|
32 | Double e = (val instanceof Double) ? (Double) val : 1.0;
|
---|
33 | return new UtilityBasedAcceptanceStrategy(minpower, maxpower) {
|
---|
34 | @Override
|
---|
35 | public BigDecimal getUtilityThreshold ( MAState state ) {
|
---|
36 | Double t = state.getProgressTime().doubleValue();
|
---|
37 | Double scale = Math.pow(1-t, e);
|
---|
38 | return BigDecimal.valueOf(lowerThreshold + scale * (upperThreshold - lowerThreshold));
|
---|
39 | }
|
---|
40 | };
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | protected IBiddingStrategy getBiddingStrategy ( Settings settings ) {
|
---|
45 | Object val = settings.getParameters().get("minPower");
|
---|
46 | Integer minpower = (val instanceof Integer) ? (Integer) val : 2;
|
---|
47 | val = settings.getParameters().get("maxPower");
|
---|
48 | Integer maxpower = (val instanceof Integer) ? (Integer) val : Integer.MAX_VALUE;
|
---|
49 | val = settings.getParameters().get("upperThreshold");
|
---|
50 | Double upperThreshold = (val instanceof Double) ? (Double) val : 1.0;
|
---|
51 | val = settings.getParameters().get("lowerThreshold");
|
---|
52 | Double lowerThreshold = (val instanceof Double) ? (Double) val : 0.0;
|
---|
53 | val = settings.getParameters().get("e");
|
---|
54 | Double e = (val instanceof Double) ? (Double) val : 1.0;
|
---|
55 | return new UtilityBasedBiddingStrategy(minpower, maxpower) {
|
---|
56 | @Override
|
---|
57 | public BigDecimal getUpperUtilityThreshold ( MAState state ) {
|
---|
58 | return BigDecimal.valueOf(upperThreshold);
|
---|
59 | }
|
---|
60 | @Override
|
---|
61 | public BigDecimal getLowerUtilityThreshold ( MAState state ) {
|
---|
62 | Double t = state.getProgressTime().doubleValue();
|
---|
63 | Double scale = Math.pow(1-t, e);
|
---|
64 | return BigDecimal.valueOf(lowerThreshold + scale * (upperThreshold - lowerThreshold));
|
---|
65 | }
|
---|
66 | };
|
---|
67 | }
|
---|
68 |
|
---|
69 | @Override
|
---|
70 | protected IOptInStrategy getOptInStrategy ( Settings settings ) {
|
---|
71 | Object val = settings.getParameters().get("minPower");
|
---|
72 | Integer minvotepower = (val instanceof Integer) ? (Integer) val : 2;
|
---|
73 | val = settings.getParameters().get("maxPower");
|
---|
74 | Integer maxpower = (val instanceof Integer) ? (Integer) val : Integer.MAX_VALUE;
|
---|
75 | val = settings.getParameters().get("lowerThreshold");
|
---|
76 | Double lowerThreshold = (val instanceof Double) ? (Double) val : 0.7;
|
---|
77 | val = settings.getParameters().get("e");
|
---|
78 | Double e = (val instanceof Double) ? (Double) val : 1.0;
|
---|
79 | val = settings.getParameters().get("ve");
|
---|
80 | Double ve = (val instanceof Double) ? (Double) val : 1.0;
|
---|
81 | return new PowerWeightedOptInStrategy() {
|
---|
82 |
|
---|
83 | @Override
|
---|
84 | public Vote vote(MAState state, Bid bid, Integer power, Integer minpower) {
|
---|
85 | Double t = state.getProgressTime().doubleValue();
|
---|
86 | if (state.getUtilitySpace().getUtility(bid).doubleValue() * (1+Math.pow(power/(minpower*1.0), ve * Math.pow(1-t, e))) > lowerThreshold )
|
---|
87 | return new Vote(state.getId(), bid, minvotepower, maxpower);
|
---|
88 | return null;
|
---|
89 | }
|
---|
90 |
|
---|
91 | };
|
---|
92 | }
|
---|
93 |
|
---|
94 | // @Override
|
---|
95 | // protected IOpponentModel initNewOpponentModel ( Settings settings ) {
|
---|
96 | // return new EmptyOpponentModel();
|
---|
97 | // }
|
---|
98 |
|
---|
99 | }
|
---|