Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java @ 942:796c54058dc4
Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
flys-artifacts/trunk@2351 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 18 Jul 2011 10:13:25 +0000 |
parents | 659608128823 |
children | 821aaceb2776 |
rev | line source |
---|---|
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import gnu.trove.TDoubleArrayList; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
744
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
5 import java.util.Random; |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
6 |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 public class WQ |
925
0cb1a70b8b92
Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
748
diff
changeset
|
8 extends NamedObjectImpl |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 { |
925
0cb1a70b8b92
Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
748
diff
changeset
|
10 // TODO: s/w/ws/g |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 protected TDoubleArrayList w; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
925
0cb1a70b8b92
Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
748
diff
changeset
|
13 // TODO: s/q/qs/g |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 protected TDoubleArrayList q; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 public WQ() { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 this(""); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 public WQ(String name) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 w = new TDoubleArrayList(); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 q = new TDoubleArrayList(); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public WQ(int capacity) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 this(capacity, ""); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 public WQ(int capacity, String name) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 super(name); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 w = new TDoubleArrayList(capacity); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 q = new TDoubleArrayList(capacity); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 public WQ(double [] qs, double [] ws) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 this(qs, ws, ""); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 public WQ(double [] qs, double [] ws, String name) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 super(name); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 w = new TDoubleArrayList(ws); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 q = new TDoubleArrayList(qs); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 public void add(double w, double q) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 this.w.add(w); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 this.q.add(q); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 public int size() { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 return w.size(); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 public double getW(int idx) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 return w.getQuick(idx); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 public double getQ(int idx) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 return q.getQuick(idx); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 public double [] get(int idx) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 return get(idx, new double [2]); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 public double [] get(int idx, double [] dst) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 dst[0] = w.getQuick(idx); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 dst[1] = q.getQuick(idx); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 return dst; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 public double [] getWs() { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 return w.toNativeArray(); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 public double [] getQs() { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 return q.toNativeArray(); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 public static void removeNaNs(TDoubleArrayList [] arrays) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 int dest = 0; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 int A = arrays.length; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 int N = arrays[0].size(); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 OUTER: for (int i = 0; i < N; ++i) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 for (int j = 0; j < A; ++j) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 TDoubleArrayList a = arrays[j]; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 double v = a.getQuick(i); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 if (Double.isNaN(v)) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 continue OUTER; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 a.setQuick(dest, v); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 ++dest; |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 if (dest < N) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 for (int i = 0; i < A; ++i) { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 arrays[i].remove(dest, N-dest); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 public void removeNaNs() { |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 removeNaNs(new TDoubleArrayList [] { w, q }); |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 } |
744
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
110 |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
111 public boolean guessWaterIncreasing() { |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
112 return guessWaterIncreasing(0.05f); |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
113 } |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
114 |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
115 public boolean guessWaterIncreasing(float factor) { |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
116 |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
117 int N = w.size(); |
926
659608128823
Fix(?) for flys/issue114
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
118 if (N < 2) return false; |
659608128823
Fix(?) for flys/issue114
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
119 |
744
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
120 int samples = (int)(factor*N) + 1; |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
121 |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
122 int up = 0; |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
123 |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
124 Random rand = new Random(); |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
125 |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
126 for (int i = 0; i < samples; ++i) { |
748
30be4b71c36c
WQ: Guessing increaing w is not based on direct neighbors any more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
744
diff
changeset
|
127 int pos2 = rand.nextInt(N-1) + 1; |
926
659608128823
Fix(?) for flys/issue114
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
128 if (pos2 == 0) continue; |
748
30be4b71c36c
WQ: Guessing increaing w is not based on direct neighbors any more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
744
diff
changeset
|
129 int pos1 = rand.nextInt(pos2); |
30be4b71c36c
WQ: Guessing increaing w is not based on direct neighbors any more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
744
diff
changeset
|
130 double w1 = w.getQuick(pos1); |
30be4b71c36c
WQ: Guessing increaing w is not based on direct neighbors any more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
744
diff
changeset
|
131 double w2 = w.getQuick(pos2); |
744
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
132 if (w2 > w1) ++up; |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
133 } |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
134 |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
135 return up > samples/2; |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
136 } |
b385577bcaca
WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
726
diff
changeset
|
137 |
726
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 } |
cbaa3ca86f2f
Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |