Compare weights and print first difference
This commit is contained in:
@@ -84,7 +84,7 @@ sealed class Solver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun weight(p1: Pairable, p2: Pairable) =
|
open fun weight(p1: Pairable, p2: Pairable) =
|
||||||
1.0 + // 1 is minimum value because 0 means "no matching allowed"
|
// 1.0 + // 1 is minimum value because 0 means "no matching allowed"
|
||||||
pairing.base.apply(p1, p2) +
|
pairing.base.apply(p1, p2) +
|
||||||
pairing.main.apply(p1, p2) +
|
pairing.main.apply(p1, p2) +
|
||||||
pairing.secondary.apply(p1, p2) +
|
pairing.secondary.apply(p1, p2) +
|
||||||
@@ -141,6 +141,7 @@ sealed class Solver(
|
|||||||
File(WEIGHTS_FILE).appendText("secHandiCost="+pairing.handicap.handicap(p, q).toString()+"\n")
|
File(WEIGHTS_FILE).appendText("secHandiCost="+pairing.handicap.handicap(p, q).toString()+"\n")
|
||||||
File(WEIGHTS_FILE).appendText("secGeoCost="+pairing.geo.apply(p, q).toString()+"\n")
|
File(WEIGHTS_FILE).appendText("secGeoCost="+pairing.geo.apply(p, q).toString()+"\n")
|
||||||
File(WEIGHTS_FILE).appendText("totalCost="+weight(p,q).toString()+"\n")
|
File(WEIGHTS_FILE).appendText("totalCost="+weight(p,q).toString()+"\n")
|
||||||
|
//%.2f".format(pi)
|
||||||
//println(weight(q,p))
|
//println(weight(q,p))
|
||||||
logWeights("total", p, q, weight(p,q))
|
logWeights("total", p, q, weight(p,q))
|
||||||
//weightsToFile(p, q)
|
//weightsToFile(p, q)
|
||||||
|
@@ -237,7 +237,7 @@ class BasicTests: TestBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add to map
|
// Add to map
|
||||||
if (file == "weights.txt") {
|
if (file == file1) {
|
||||||
map1[Pair(name1, name2)] = costs
|
map1[Pair(name1, name2)] = costs
|
||||||
} else {
|
} else {
|
||||||
map2[Pair(name1, name2)] = costs
|
map2[Pair(name1, name2)] = costs
|
||||||
@@ -247,6 +247,29 @@ class BasicTests: TestBase() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var diff_found = false
|
||||||
|
for ((key, value) in map1) {
|
||||||
|
// Check if key exists in both
|
||||||
|
if (map2.containsKey(key)) {
|
||||||
|
// Compare values
|
||||||
|
if (value != map2[key] && diff_found==false) {
|
||||||
|
// Key exists but values differ - print key
|
||||||
|
logger.info("Difference found at $key")
|
||||||
|
logger.info("baseDuplicateGameCost = "+value!![0].toString()+" "+map2[key]!![0].toString())
|
||||||
|
logger.info("baseRandomCost = "+value!![1].toString()+" "+map2[key]!![1].toString())
|
||||||
|
logger.info("baseBWBalanceCost = "+value!![2].toString()+" "+map2[key]!![2].toString())
|
||||||
|
logger.info("mainCategoryCost = "+value!![3].toString()+" "+map2[key]!![3].toString())
|
||||||
|
logger.info("mainScoreDiffCost = "+value!![4].toString()+" "+map2[key]!![4].toString())
|
||||||
|
logger.info("mainDUDDCost = "+value!![5].toString()+" "+map2[key]!![5].toString())
|
||||||
|
logger.info("mainSeedCost = "+value!![6].toString()+" "+map2[key]!![6].toString())
|
||||||
|
logger.info("secHandiCost = "+value!![7].toString()+" "+map2[key]!![7].toString())
|
||||||
|
logger.info("secGeoCost = "+value!![8].toString()+" "+map2[key]!![8].toString())
|
||||||
|
diff_found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return map1==map2
|
return map1==map2
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,9 +291,9 @@ class BasicTests: TestBase() {
|
|||||||
logger.info("games for round 1: {}", games_np.toString())
|
logger.info("games for round 1: {}", games_np.toString())
|
||||||
|
|
||||||
logger.info("Compare weights with itself")
|
logger.info("Compare weights with itself")
|
||||||
assertTrue(compare_weights("weights.txt", "weights.txt"), "expecting success")
|
assertTrue(compare_weights("weights.txt", "weights_clone.txt"), "Weights not equal to itselft")
|
||||||
logger.info("Compare weights with opengotha")
|
logger.info("Compare weights with opengotha")
|
||||||
assertTrue(compare_weights("weights.txt", "opengotha/simpleswiss_weightsonly_R1.txt"), "expecting success")
|
assertTrue(compare_weights("weights.txt", "opengotha/simpleswiss_weightsonly_R1.txt"), "Not matching opengotha weights")
|
||||||
|
|
||||||
val pairings_R1 = """[{"id":283,"w":195,"b":201,"h":0,"r":"?","dd":0},
|
val pairings_R1 = """[{"id":283,"w":195,"b":201,"h":0,"r":"?","dd":0},
|
||||||
|{"id":284,"w":186,"b":184,"h":0,"r":"?","dd":0},{"id":285,"w":200,"b":194,"h":0,"r":"?","dd":0},
|
|{"id":284,"w":186,"b":184,"h":0,"r":"?","dd":0},{"id":285,"w":200,"b":194,"h":0,"r":"?","dd":0},
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user