Line | |
---|
1 | package geniusweb.opponentmodel.bayesian;
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Hypothesis on the weight of an issue.
|
---|
5 | * <p>
|
---|
6 | * DO NOT USE THIS. Private use for {@link BayesianOpponentModel}.
|
---|
7 | */
|
---|
8 | class WeightHypothesis extends Hypothesis {
|
---|
9 | private final double weight;
|
---|
10 |
|
---|
11 | public WeightHypothesis(double weight, double p) {
|
---|
12 | super(p);
|
---|
13 | this.weight = weight;
|
---|
14 | }
|
---|
15 |
|
---|
16 | public WeightHypothesis withWeight(double value) {
|
---|
17 | return new WeightHypothesis(value, getProbability());
|
---|
18 | }
|
---|
19 |
|
---|
20 | public double getWeight() {
|
---|
21 | return weight;
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | public String toString() {
|
---|
26 | return "P(" + weight + ")=" + getProbability();
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public WeightHypothesis with(double p) {
|
---|
31 | return new WeightHypothesis(weight, p);
|
---|
32 | }
|
---|
33 |
|
---|
34 | @Override
|
---|
35 | public int hashCode() {
|
---|
36 | final int prime = 31;
|
---|
37 | int result = super.hashCode();
|
---|
38 | long temp;
|
---|
39 | temp = Double.doubleToLongBits(weight);
|
---|
40 | result = prime * result + (int) (temp ^ (temp >>> 32));
|
---|
41 | return result;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public boolean equals(Object obj) {
|
---|
46 | if (this == obj)
|
---|
47 | return true;
|
---|
48 | if (!super.equals(obj))
|
---|
49 | return false;
|
---|
50 | if (getClass() != obj.getClass())
|
---|
51 | return false;
|
---|
52 | WeightHypothesis other = (WeightHypothesis) obj;
|
---|
53 | if (Double.doubleToLongBits(weight) != Double
|
---|
54 | .doubleToLongBits(other.weight))
|
---|
55 | return false;
|
---|
56 | return true;
|
---|
57 | }
|
---|
58 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.