Correct pairingSort function
This commit is contained in:
@@ -79,7 +79,7 @@ sealed class Solver(
|
||||
val criterionP = p.eval(criterion)
|
||||
val criterionQ = q.eval(criterion)
|
||||
if (criterionP != criterionQ) {
|
||||
return (criterionP * 100 - criterionQ * 100).toInt()
|
||||
return (criterionQ * 100 - criterionP * 100).toInt()
|
||||
}
|
||||
}
|
||||
return 0
|
||||
@@ -89,7 +89,7 @@ sealed class Solver(
|
||||
val criterionP = p.eval(criterion)
|
||||
val criterionQ = q.eval(criterion)
|
||||
if (criterionP != criterionQ) {
|
||||
return (criterionP * 100 - criterionQ * 100).toInt()
|
||||
return (criterionQ * 1e6 - criterionP * 1e6).toInt()
|
||||
}
|
||||
}
|
||||
if (p.rating == q.rating) {
|
||||
@@ -174,14 +174,11 @@ sealed class Solver(
|
||||
val matching = KolmogorovWeightedPerfectMatching(graph, ObjectiveSense.MAXIMIZE)
|
||||
val solution = matching.matching
|
||||
|
||||
fun gamesSort(p1:Pairable, p2:Pairable) = 0.5*(p1.place + p2.place)
|
||||
|
||||
var sorted = solution.map{
|
||||
val sorted = solution.map{
|
||||
listOf(graph.getEdgeSource(it), graph.getEdgeTarget(it))
|
||||
}.sortedBy { gamesSort(it[0],it[1])}
|
||||
}.sortedWith(compareBy({ 0.5*(it[0].place + it[1].place) }, { min(it[0].place, it[1].place) }))
|
||||
|
||||
|
||||
var result = sorted.flatMap { games(white = it[0], black = it[1]) }
|
||||
val result = sorted.flatMap { games(white = it[0], black = it[1]) }
|
||||
|
||||
return result
|
||||
|
||||
|
Reference in New Issue
Block a user