source: src/main/java/agents/OptimalBidderSimpleU.java@ 209

Last change on this file since 209 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 2.7 KB
Line 
1/**
2 * OptimalBidder: using the optimal stopping rule (cutoffs) for bidding.
3 * B_{j+1} = 1/2 + 1/2 B_j^2
4 * @author rafik
5 ************************************************************************************************************************************/
6
7package agents;
8
9import java.util.HashMap;
10
11import genius.core.issue.ISSUETYPE;
12import genius.core.issue.IssueDiscrete;
13import genius.core.issue.Value;
14import genius.core.issue.ValueDiscrete;
15import genius.core.utility.AdditiveUtilitySpace;
16import genius.core.utility.Evaluator;
17import genius.core.utility.EvaluatorDiscrete;
18
19public class OptimalBidderSimpleU extends OptimalBidderU {
20 private static double rvB;
21
22 public void init() {
23 partitions = 1000;
24 super.init();
25 }
26
27 @Override
28 public String getName() {
29 return "OptimalBidderSimpleU";
30 }
31
32 /**
33 * computation of the bid for round j as in prop 4.3
34 *
35 * @param round
36 * j
37 * @return bid value
38 **/
39 @Override
40 public double bid(int j) {
41 if (j == 1)
42 return 0.5 + 0.5 * rvB;
43 else
44 return 0.5 + 0.5 * Math.pow(bid(j - 1), 2);
45 }
46
47 /**
48 * reservation value: if the reservation value is already set (<> -1.0)
49 * simply return it, otherwise get it from the utility space
50 *
51 * @param double
52 * @return double
53 * @throws Exception
54 **/
55 @Override
56 public double getReservationValue(double arg) throws Exception {
57 boolean flag = true;
58 double rv = 0.0;
59
60 if (arg == -1.0) // first time // TODO rmeove the -1, rv, etc.
61 {
62 if (pie.getType().equals(ISSUETYPE.DISCRETE)) // get/set rvB...
63 {
64 IssueDiscrete discrete_pie = (IssueDiscrete) pie;
65 int nvalues = discrete_pie.getNumberOfValues();
66 print(" nvalues = " + nvalues);
67 values = new HashMap<Integer, Value>(nvalues);
68
69 for (int i = 0; i < nvalues; i++) {
70 ValueDiscrete value = discrete_pie.getValue(i);
71 Evaluator evaluator = ((AdditiveUtilitySpace) utilitySpace)
72 .getEvaluator(pie.getNumber());
73 Integer evaluation = ((EvaluatorDiscrete) evaluator)
74 .getValue((ValueDiscrete) value);
75 values.put(i, value);
76
77 if (evaluation != 0 && flag) // reaching rvB
78 {
79 rv = (double) i / partitions; // rvB normalized
80 utilitySpace.setReservationValue(rv); // TODO no need
81 // for this,
82 // remove it.
83 flag = false;
84 print(" rvB = " + rv);
85 }
86 }
87 return rv;
88 } else {
89 throw new Exception("Type " + pie.getType()
90 + " not supported by " + getName());
91 }
92 } else {
93 return arg;
94 }
95 }
96
97 /**
98 * U_{j+1} : utility cutoffs
99 *
100 * @param int
101 * @return double
102 * @throws Exception
103 **/
104
105 @Override
106 public double utility(int j) {
107 return (Math.pow(bid(j), 2) - rvB) / (1 - rvB);
108 }
109
110} // end
Note: See TracBrowser for help on using the repository browser.