1 | package genius.core.utility;
|
---|
2 |
|
---|
3 | import java.util.Enumeration;
|
---|
4 |
|
---|
5 | import genius.core.Bid;
|
---|
6 | import genius.core.issue.Objective;
|
---|
7 |
|
---|
8 | /* Created by Dimitrios Tsimpoukis
|
---|
9 | *
|
---|
10 | * Subclass of AdditiveUtilitySpace that adds a perturbation in the utility of the bids.
|
---|
11 | * Used for the introduction of Uncertainty. Only changed method is getUtility(Bid bid)
|
---|
12 | *
|
---|
13 | *
|
---|
14 | */
|
---|
15 |
|
---|
16 | public class AdditiveUtilitySpaceWithPerturbation extends AdditiveUtilitySpace {
|
---|
17 |
|
---|
18 | private static final long serialVersionUID = -8882680929008252676L;
|
---|
19 |
|
---|
20 | private double perturbation;
|
---|
21 |
|
---|
22 | public AdditiveUtilitySpaceWithPerturbation(AdditiveUtilitySpace uspace) {
|
---|
23 | super(uspace);
|
---|
24 | }
|
---|
25 |
|
---|
26 | public AdditiveUtilitySpaceWithPerturbation(AdditiveUtilitySpace uspace,
|
---|
27 | double perturbation) {
|
---|
28 | super(uspace);
|
---|
29 | this.perturbation = perturbation;
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public double getUtility(Bid bid) {
|
---|
34 | double utility = 0;
|
---|
35 |
|
---|
36 | Objective root = getDomain().getObjectivesRoot();
|
---|
37 | Enumeration<Objective> issueEnum = root.getPreorderIssueEnumeration();
|
---|
38 | while (issueEnum.hasMoreElements()) {
|
---|
39 | Objective is = issueEnum.nextElement();
|
---|
40 | Evaluator eval = getEvaluator(is);
|
---|
41 | if (eval == null) {
|
---|
42 | throw new IllegalArgumentException(
|
---|
43 | "UtilitySpace does not contain evaluator for issue "
|
---|
44 | + is + ". ");
|
---|
45 | }
|
---|
46 |
|
---|
47 | switch (eval.getType()) {
|
---|
48 | case DISCRETE:
|
---|
49 | case INTEGER:
|
---|
50 | case REAL:
|
---|
51 | utility += eval.getWeight()
|
---|
52 | * getEvaluation(is.getNumber(), bid);
|
---|
53 | break;
|
---|
54 | case OBJECTIVE:
|
---|
55 | // we ignore OBJECTIVE. Not clear what it is and why.
|
---|
56 | break;
|
---|
57 | }
|
---|
58 | }
|
---|
59 | double result = utility + perturbation; // Introduction of Perturbation
|
---|
60 | if (result > 1)
|
---|
61 | return 1;
|
---|
62 | if (result < 0)
|
---|
63 | return 0;
|
---|
64 | return result;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public double getPerturbation() {
|
---|
68 | return perturbation;
|
---|
69 | }
|
---|
70 |
|
---|
71 | public void setPerturbation(double perturbation) {
|
---|
72 | this.perturbation = perturbation;
|
---|
73 | }
|
---|
74 |
|
---|
75 | }
|
---|