1 | package ai2020.group6;
|
---|
2 |
|
---|
3 | import java.math.BigDecimal;
|
---|
4 |
|
---|
5 | import geniusweb.inform.Settings;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * MAExponential accepts and generates bids above a threshold exponentially
|
---|
9 | * decreasing as a function of time.
|
---|
10 | * The threshold starts at the "upperThreshold" (defaulting to 1) and decreases
|
---|
11 | * to the "lowerThreshold" (defaulting to 0) by scaling with (1-t)^e, where t is
|
---|
12 | * the progress over time and e is the parameter "e" (defaulting to 1).
|
---|
13 | *
|
---|
14 | * @author Group 6
|
---|
15 | */
|
---|
16 | public class MAExponential extends MADefaultParty {
|
---|
17 |
|
---|
18 | @Override
|
---|
19 | protected IAcceptanceStrategy getAccceptanceStrategy ( Settings settings ) {
|
---|
20 | Object val = settings.getParameters().get("minPower");
|
---|
21 | Integer minpower = (val instanceof Integer) ? (Integer) val : 2;
|
---|
22 | val = settings.getParameters().get("maxPower");
|
---|
23 | Integer maxpower = (val instanceof Integer) ? (Integer) val : Integer.MAX_VALUE;
|
---|
24 | val = settings.getParameters().get("upperThreshold");
|
---|
25 | Double upperThreshold = (val instanceof Double) ? (Double) val : 1.0;
|
---|
26 | val = settings.getParameters().get("lowerThreshold");
|
---|
27 | Double lowerThreshold = (val instanceof Double) ? (Double) val : 0.0;
|
---|
28 | val = settings.getParameters().get("e");
|
---|
29 | Double e = (val instanceof Double) ? (Double) val : 1.0;
|
---|
30 | return new UtilityBasedAcceptanceStrategy(minpower, maxpower) {
|
---|
31 | @Override
|
---|
32 | public BigDecimal getUtilityThreshold ( MAState state ) {
|
---|
33 | Double t = state.getProgressTime().doubleValue();
|
---|
34 | Double scale = Math.pow(1-t, e);
|
---|
35 | return BigDecimal.valueOf(lowerThreshold + scale * (upperThreshold - lowerThreshold));
|
---|
36 | }
|
---|
37 | };
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Override
|
---|
41 | protected IBiddingStrategy getBiddingStrategy ( Settings settings ) {
|
---|
42 | Object val = settings.getParameters().get("minPower");
|
---|
43 | Integer minpower = (val instanceof Integer) ? (Integer) val : 2;
|
---|
44 | val = settings.getParameters().get("maxPower");
|
---|
45 | Integer maxpower = (val instanceof Integer) ? (Integer) val : Integer.MAX_VALUE;
|
---|
46 | val = settings.getParameters().get("upperThreshold");
|
---|
47 | Double upperThreshold = (val instanceof Double) ? (Double) val : 1.0;
|
---|
48 | val = settings.getParameters().get("lowerThreshold");
|
---|
49 | Double lowerThreshold = (val instanceof Double) ? (Double) val : 0.0;
|
---|
50 | val = settings.getParameters().get("e");
|
---|
51 | Double e = (val instanceof Double) ? (Double) val : 1.0;
|
---|
52 | return new UtilityBasedBiddingStrategy(minpower, maxpower) {
|
---|
53 | @Override
|
---|
54 | public BigDecimal getUpperUtilityThreshold ( MAState state ) {
|
---|
55 | return BigDecimal.valueOf(upperThreshold);
|
---|
56 | }
|
---|
57 | @Override
|
---|
58 | public BigDecimal getLowerUtilityThreshold ( MAState state ) {
|
---|
59 | Double t = state.getProgressTime().doubleValue();
|
---|
60 | Double scale = Math.pow(1-t, e);
|
---|
61 | return BigDecimal.valueOf(lowerThreshold + scale * (upperThreshold - lowerThreshold));
|
---|
62 | }
|
---|
63 | };
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | protected IOptInStrategy getOptInStrategy ( Settings settings ) {
|
---|
68 | return new NoOptInStrategy();
|
---|
69 | }
|
---|
70 |
|
---|
71 | // @Override
|
---|
72 | // protected IOpponentModel initNewOpponentModel ( Settings settings ) {
|
---|
73 | // return new EmptyOpponentModel();
|
---|
74 | // }
|
---|
75 |
|
---|
76 | }
|
---|