@@ -99,6 +99,8 @@ |
List<String> Acc_years = Arrays.asList(CSIP_Const.ACC_years); |
|
for (int i = 0; i < hrus.size(); i++) { |
+ w_log.println(" HRU_ID: " + i); |
+ w_log.flush(); |
String hru_seq = ""; |
String hru_veg_seq = ""; |
List<String[]> list = new ArrayList(); |
@@ -136,6 +138,8 @@ |
double singlconf = (Double.parseDouble(list.get(j)[2]) * 0.1) / 100; |
if (map.get(sum_hash_id) == null) { |
map.put(sum_hash_id, singlconf); |
+ w_log.println(" sum_hash_id: " + sum_hash_id + " singlconf: " + singlconf); |
+ w_log.flush(); |
} |
for (int k = j + 1; k < list.size(); k++) { |
if (Boolean.parseBoolean(list.get(k)[1])) { |
@@ -149,6 +153,8 @@ |
|
if (map.get(sum_hash_id) == null) { |
map.put(sum_hash_id, avg_confe); |
+ w_log.println(" sum_hash_id: " + sum_hash_id + " avg_confe: " + avg_confe); |
+ w_log.flush(); |
} |
} else { |
sum_hash_id = "" + hashid; |
@@ -157,14 +163,18 @@ |
} |
} |
} |
- |
+ w_log.println(" "); |
+ w_log.flush(); |
Map<String, Double> sorted = sortByValues(map); |
double max_avg_conf = 0; |
for (String key : sorted.keySet()) { |
max_avg_conf = sorted.get(key) * 100; |
+ w_log.println(" max_avg_conf: " + max_avg_conf); |
+ w_log.flush(); |
break; |
} |
- |
+ w_log.println(" "); |
+ w_log.flush(); |
Map<Integer, Double> weights = new HashMap(); |
weights.put(1, 0.0); |
weights.put(2, 2.0); |
@@ -173,12 +183,12 @@ |
weights.put(5, 5.0); |
weights.put(6, 6.0); |
|
- map = new HashMap<>(); |
+ map.clear(); |
Map<Double, String> seq_map = new HashMap<>(); |
Map<String, String> seq_acc = new HashMap<>(); |
List<String> character_combination = new ArrayList(); |
|
- conf = new ArrayList(); |
+ conf.clear(); |
List<Double> ac_list = new ArrayList(); |
|
for (int j = 0; j < list.size(); j++) { |
@@ -201,6 +211,8 @@ |
map.put(list.get(j)[0], Acs); |
seq_map.put(Acs, hru_seq_arr); |
seq_acc.put(hru_seq_arr, list.get(j)[0]); |
+ w_log.println(" Acs: " + Acs + " hru_seq_arr: " + hru_seq_arr + " list.get(j)[0]: " + list.get(j)[0]); |
+ w_log.flush(); |
character_combination.add(hru_seq_arr); |
} else { |
if (Acs > map.get(seq_acc.get(hru_seq_arr))) { |
@@ -210,6 +222,8 @@ |
map.put(list.get(j)[0], Acs); |
seq_map.put(Acs, hru_seq_arr); |
seq_acc.put(hru_seq_arr, list.get(j)[0]); |
+ w_log.println(" Acs: " + Acs + " hru_seq_arr: " + hru_seq_arr + " list.get(j)[0]: " + list.get(j)[0]); |
+ w_log.flush(); |
} |
} |
} |
@@ -236,6 +250,8 @@ |
seq_map.put(Ac, hru_seq_arr); |
seq_acc.put(hru_seq_arr, sum_hash_id); |
character_combination.add(hru_seq_arr); |
+ w_log.println(" Ac: " + Ac + " hru_seq_arr: " + hru_seq_arr + " sum_hash_id: " + sum_hash_id); |
+ w_log.flush(); |
} else { |
if (Ac > map.get(seq_acc.get(hru_seq_arr))) { |
seq_map.remove(map.get(seq_acc.get(hru_seq_arr))); |
@@ -244,6 +260,8 @@ |
map.put(sum_hash_id, Ac); |
seq_map.put(Ac, hru_seq_arr); |
seq_acc.put(hru_seq_arr, sum_hash_id); |
+ w_log.println(" Ac: " + Ac + " hru_seq_arr: " + hru_seq_arr + " sum_hash_id: " + sum_hash_id); |
+ w_log.flush(); |
} |
} |
|
@@ -259,6 +277,15 @@ |
} |
} |
Map<String, Double> sorted2 = sortByValues(map); |
+ max_avg_conf = 0; |
+ for (String key : sorted2.keySet()) { |
+ max_avg_conf = sorted2.get(key) * 100; |
+ w_log.println(" max_avg_conf: " + max_avg_conf); |
+ w_log.flush(); |
+ break; |
+ } |
+ w_log.println(" "); |
+ w_log.flush(); |
|
hrus.get(i).hru_seq_org = hru_seq; |
hrus.get(i).hru_seq_work = hru_seq; |
@@ -46,7 +46,8 @@ |
Statement state = conn.createStatement(); |
|
for (int i = 0; i < unique_cmzs.size(); i++) { |
- String queryString = "select * from \"PUBLIC\".LMOD_MGMTS_ACR where CMZ='" + Integer.parseInt(unique_cmzs.get(i)) + "' order by years desc"; |
+ //original String queryString = "select * from \"PUBLIC\".LMOD_MGMTS_ACR where CMZ='" + Integer.parseInt(unique_cmzs.get(i)) + "' order by years desc"; |
+ String queryString = "select max(KEY),max(COVERCROPS),max(CROPSEQUENCE),cropseqacr,irrigated,years from LMOD_MGMTS_ACR group by cropseqacr,irrigated order by years desc;"; |
//String queryString = "select max(KEY),max(CMZ),max(IRRIGATED),max(COVERCROPS),max(CROPSEQUENCE),cropseqacr,years from \"PUBLIC\".LMOD_MGMTS_ACR group by cropseqacr order by years desc;"; |
// String queryString = "select max(KEY),max(CMZ),max(IRRIGATED),max(COVERCROPS),max(CROPSEQUENCE),cropseqacr,years from \"PUBLIC\".LMOD_MGMTS_ACR where CMZ='" + Integer.parseInt(unique_cmzs.get(i)) + "' or CMZ='15.1' or CMZ='3' or CMZ='4' or CMZ='4.1' or CMZ='6' or CMZ='7' or CMZ='8' or CMZ='9' or CMZ='10' or CMZ='2' group by cropseqacr order by years desc;"; |
w_log.println(" " + queryString); |
@@ -54,15 +55,15 @@ |
int count = 0; |
while (result.next()) { |
ArrayList<String> LMOD_data_by_CMZ = new ArrayList<>(); |
- LMOD_data_by_CMZ.add(result.getString("KEY")); |
- LMOD_data_by_CMZ.add(result.getString("CMZ")); |
+ LMOD_data_by_CMZ.add(result.getString("max(KEY)")); |
+ LMOD_data_by_CMZ.add("4"); |
LMOD_data_by_CMZ.add(result.getString("IRRIGATED")); |
- LMOD_data_by_CMZ.add(result.getString("COVERCROPS")); |
- LMOD_data_by_CMZ.add(result.getString("CROPSEQUENCE")); |
+ LMOD_data_by_CMZ.add(result.getString("max(COVERCROPS)")); |
+ LMOD_data_by_CMZ.add(result.getString("max(CROPSEQUENCE)")); |
LMOD_data_by_CMZ.add(result.getString("CROPSEQACR")); |
LMOD_data_by_CMZ.add(result.getString("YEARS")); |
LMOD_CMZ_Data.add(LMOD_data_by_CMZ); |
- DB_LMOD_map.put(result.getString("CROPSEQACR") + "_" + result.getString("CMZ") + "_" + result.getString("IRRIGATED"), LMOD_data_by_CMZ); |
+ DB_LMOD_map.put(result.getString("CROPSEQACR") + "_" + "4" + "_" + result.getString("IRRIGATED"), LMOD_data_by_CMZ); |
count++; |
} |
|
@@ -132,7 +133,7 @@ |
throws InterruptedException, ExecutionException { |
|
int threadnr = 1; |
- if (hrus.size() > 7) { |
+ if (hrus.size() > 10000) { |
threadnr = CSIP_Const.ThreadNumber; |
} |
|
@@ -211,7 +212,7 @@ |
|
if (LMOD_CMZ_Data.get(j).get(5).toCharArray().length > hrus.get(i).hru_seq_org.toCharArray().length) { |
|
- if (jaro.proximity(LMOD_CMZ_Data.get(j).get(5), hrus.get(i).hru_seq_org) > 0.3) { |
+ if (jaro.proximity(LMOD_CMZ_Data.get(j).get(5), hrus.get(i).hru_seq_org) > 0.0) { |
|
if (map_bigger_rot_jaro.get(LMOD_CMZ_Data.get(j).get(5)) == null) { |
map_bigger_rot_jaro.put(LMOD_CMZ_Data.get(j).get(5), jaro.proximity(LMOD_CMZ_Data.get(j).get(5), hrus.get(i).hru_seq_org)); |
@@ -260,9 +261,9 @@ |
// generic matching here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
String pattern = ""; |
boolean match = false; |
-// w_log.println(i + " HRU "); |
-// w_log.println(" veg_seq : " + hrus.get(i).hru_veg_seq); |
-// w_log.println(" org_seq : " + hrus.get(i).hru_seq_org); |
+ w_log.println(i + " HRU "); |
+ w_log.println(" veg_seq : " + hrus.get(i).hru_veg_seq); |
+ w_log.println(" org_seq : " + hrus.get(i).hru_seq_org); |
w_log.flush(); |
String new_rebuilt = ""; |
int hash_pos = 0; |
@@ -276,7 +277,7 @@ |
//w_log.println(" " + hash_pos + ".in LIST Seq : " + hrus.get(i).seq_map.get(hrus.get(i).sorted_adjusted_conf.get(key)) + " Adjusted avg. Conf: " + hrus.get(i).sorted_adjusted_conf.get(key) + " for: " + key); |
for (String cmz : hrus.get(i).cmz) { |
|
-// w_log.println(" " + hash_pos + ".in LIST Seq : " + hrus.get(i).seq_map.get(hrus.get(i).sorted_adjusted_conf.get(key)) + " Adjusted avg. Conf: " + hrus.get(i).sorted_adjusted_conf.get(key) + " for: " + key + " CMZ: " + cmz); |
+ w_log.println(" " + hash_pos + ".in LIST Seq : " + hrus.get(i).seq_map.get(hrus.get(i).sorted_adjusted_conf.get(key)) + " Adjusted avg. Conf: " + hrus.get(i).sorted_adjusted_conf.get(key) + " for: " + key + " CMZ: " + cmz); |
int int_cmz = Integer.parseInt(cmz); |
|
if (!match && DB_LMOD_map.get(hrus.get(i).seq_map.get(hrus.get(i).sorted_adjusted_conf.get(key)) + "_" + int_cmz + "_" + (hrus.get(i).irrigated).toString().toUpperCase()) != null) { |
@@ -284,7 +285,7 @@ |
pattern = hrus.get(i).seq_map.get(hrus.get(i).sorted_adjusted_conf.get(key)); |
|
// w_log.println(" " + hash_pos + ".in LIST Seq : " + hrus.get(i).seq_map.get(hrus.get(i).sorted_adjusted_conf.get(key)) + " Adjusted avg. Conf: " + hrus.get(i).sorted_adjusted_conf.get(key) + " for: " + key); |
-// w_log.println(" LMOD : ==> " + pattern); |
+ w_log.println(" LMOD : ==> " + pattern); |
ArrayList<String> LMOD_data_by_CMZ = DB_LMOD_map.get(hrus.get(i).seq_map.get(hrus.get(i).sorted_adjusted_conf.get(key)) + "_" + int_cmz + "_" + (hrus.get(i).irrigated).toString().toUpperCase()); |
|
M_R.LMOD_Key = LMOD_data_by_CMZ.get(0); |
@@ -311,13 +312,14 @@ |
ind++; |
} |
|
- char[] rebuilt = new char[hrus.get(i).hru_seq_org.toCharArray().length]; |
- String org_seq = hrus.get(i).hru_seq_org; |
String help = ""; |
double jaro_loop_value = 0.0; |
|
for (int element : indexes) { |
|
+ char[] rebuilt = new char[hrus.get(i).hru_seq_org.toCharArray().length]; |
+ String org_seq = hrus.get(i).hru_seq_org; |
+ |
for (int j = 0; j < pattern.toCharArray().length; j++) { |
rebuilt[element + j] = pattern.toCharArray()[j]; |
} |
@@ -328,8 +330,8 @@ |
|
int width = pattern.toCharArray().length; |
|
-// w_log.println(" rebuilt lenght: " + rebuilt.length); |
-// w_log.println(" before: " + before + " after: " + after + " width: " + width); |
+// w_log.println(" rebuilt lenght: " + rebuilt.length); |
+// w_log.println(" before: " + before + " after: " + after + " width: " + width); |
int b = 0; |
while (before > 0) { |
rebuilt[(before - 1)] = pattern.toCharArray()[(width - 1) - b]; |
@@ -365,9 +367,9 @@ |
x++; |
} |
} |
-// w_log.println(" detected rotation :" + org_seq); |
-// w_log.println(" rebuilt rotation :" + new_rebuilt); |
-// w_log.println(" JaroSimilarity : " + jaro.proximity(org_seq, new_rebuilt) + " similar"); |
+ w_log.println(" detected rotation :" + org_seq); |
+ w_log.println(" rebuilt rotation :" + new_rebuilt); |
+ w_log.println(" JaroSimilarity : " + jaro.proximity(org_seq, new_rebuilt) + " similar"); |
if (jaro.proximity(org_seq, new_rebuilt) > jaro_loop_value) { |
jaro_loop_value = jaro.proximity(org_seq, new_rebuilt); |
help = help_inner; |
@@ -406,8 +408,8 @@ |
} |
} |
M_R.Detected_Rebuilt_Rotation = hrus.get(i).hru_seq_org + " - " + help; |
-// w_log.println(" "); |
-// w_log.flush(); |
+ w_log.println(" "); |
+ w_log.flush(); |
//if (jaro.proximity(org_seq, new_rebuilt) > 0.2) { |
match = true; |
break; |
@@ -542,8 +544,8 @@ |
break; |
} |
} |
-// w_log.println(" "); |
-// w_log.flush(); |
+ w_log.println(" "); |
+ w_log.flush(); |
if (!map_bigger_rot_jaro.isEmpty()) { |
Map<String, Double> sorted = sortByValues(map_bigger_rot_jaro); |
double old_value = 0; |