1 | package agents.anac.y2019.fsega2019.fsegaoppmodel;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 |
|
---|
5 | import genius.core.Bid;
|
---|
6 | import genius.core.Domain;
|
---|
7 | import genius.core.issue.Issue;
|
---|
8 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
9 | import genius.core.utility.UtilitySpace;
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 | public class UtilitySpaceHypothesis extends Hypothesis
|
---|
14 | {
|
---|
15 | private Domain dDomain;
|
---|
16 | private UtilitySpace dUS;
|
---|
17 | private WeightHypothesis dWeightHyp;
|
---|
18 | private EvaluatorHypothesis[] eEvalHyp;
|
---|
19 | ArrayList<Issue> issues;
|
---|
20 |
|
---|
21 | public UtilitySpaceHypothesis(Domain pDomain, UtilitySpace pUS, WeightHypothesis pWeightHyp, EvaluatorHypothesis[] pEvalHyp)
|
---|
22 | {
|
---|
23 | dUS = pUS;
|
---|
24 | dDomain = pDomain;
|
---|
25 | issues = (ArrayList<Issue>) dDomain.getIssues();
|
---|
26 | dWeightHyp = pWeightHyp;
|
---|
27 | eEvalHyp = pEvalHyp;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public Domain getDomain()
|
---|
31 | {
|
---|
32 | return dDomain;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public EvaluatorHypothesis[] getEvalHyp()
|
---|
36 | {
|
---|
37 | return eEvalHyp;
|
---|
38 | }
|
---|
39 |
|
---|
40 | public WeightHypothesis getHeightHyp()
|
---|
41 | {
|
---|
42 | return dWeightHyp;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public double getUtility(Bid pBid)
|
---|
46 | {
|
---|
47 | double u = 0;
|
---|
48 |
|
---|
49 | for(int k = 0; k < eEvalHyp.length; k++)
|
---|
50 | {
|
---|
51 | try
|
---|
52 | {
|
---|
53 | //utility = sum( weight * isue_evaluation)
|
---|
54 | u = u + dWeightHyp.getWeight(k) * eEvalHyp[k].getEvaluator().getEvaluation((AdditiveUtilitySpace) dUS, pBid, issues.get(k).getNumber());
|
---|
55 | }
|
---|
56 | catch (Exception e)
|
---|
57 | {
|
---|
58 | //TODO: for test
|
---|
59 | //System.out.println("Exception: in FSEGAOpponentModel.getUtil: " + e.getMessage() + " using 0");
|
---|
60 |
|
---|
61 | u = 0;
|
---|
62 | }
|
---|
63 | }
|
---|
64 | return u;
|
---|
65 |
|
---|
66 | }
|
---|
67 |
|
---|
68 | @Override
|
---|
69 | public String toString()
|
---|
70 | {
|
---|
71 | String lResult = String.format("UtilitySpaceHypotesis probab: %1.5f\n", getProbability());
|
---|
72 | lResult += dWeightHyp.toString() + " - EvaluatorHypotesis:\n";
|
---|
73 | for(EvaluatorHypothesis lHyp : eEvalHyp)
|
---|
74 | {
|
---|
75 | lResult += " - ";
|
---|
76 | lResult += lHyp.toString() + ";\n";
|
---|
77 | }
|
---|
78 |
|
---|
79 | lResult += "\n\n";
|
---|
80 | return lResult;
|
---|
81 | }
|
---|
82 | }
|
---|