Fix rounding option: correct choice is 'round down' or 'no rounding'
This commit is contained in:
@@ -15,6 +15,7 @@ import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.round
|
||||
|
||||
// TODO CB avoid code redundancy with solvers
|
||||
|
||||
@@ -29,7 +30,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f
|
||||
val epsilon = 0.00001
|
||||
// Note: this works for now because we only have .0 and .5 fractional parts
|
||||
return if (pairing.pairingParams.main.roundDownScore) floor(score + epsilon)
|
||||
else ceil(score - epsilon)
|
||||
else round(2 * score) / 2
|
||||
}
|
||||
|
||||
if (frozen != null) {
|
||||
@@ -45,7 +46,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f
|
||||
val score = roundScore(mmBase +
|
||||
(nbW(pairable) ?: 0.0) +
|
||||
(1..round).map { round ->
|
||||
if (playersPerRound.getOrNull(round - 1)?.contains(pairable.id) == true) 0 else 1
|
||||
if (playersPerRound.getOrNull(round - 1)?.contains(pairable.id) == true) 0.0 else 1.0
|
||||
}.sum() * pairing.pairingParams.main.mmsValueAbsent)
|
||||
Pair(
|
||||
if (pairing.pairingParams.main.sosValueAbsentUseBase) mmBase
|
||||
@@ -96,7 +97,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f
|
||||
val pairables = pairables.values.filter { includePreliminary || it.final }.map { it.toDetailedJson() }
|
||||
pairables.forEach { player ->
|
||||
for (crit in criteria) {
|
||||
player[crit.first] = (crit.second[player.getID()] ?: 0.0).toInt()
|
||||
player[crit.first] = crit.second[player.getID()] ?: 0.0
|
||||
}
|
||||
player["results"] = Json.MutableArray(List(round) { "0=" })
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ abstract class BasePairingHelper(
|
||||
// Decide each pairable group based on the main criterion
|
||||
protected val groupsCount get() = 1 + (mainLimits.second - mainLimits.first).toInt()
|
||||
private val _groups by lazy {
|
||||
pairables.associate { pairable -> Pair(pairable.id, pairable.main.toInt()) }
|
||||
pairables.associate { pairable -> Pair(pairable.id, (pairable.main * 2).toInt() / 2) }
|
||||
}
|
||||
|
||||
// place (among sorted pairables)
|
||||
|
@@ -480,7 +480,7 @@ sealed class BaseSolver(
|
||||
val epsilon = 0.00001
|
||||
// Note: this works for now because we only have .0 and .5 fractional parts
|
||||
return if (pairing.main.roundDownScore) floor(score + epsilon)
|
||||
else ceil(score - epsilon)
|
||||
else round(2 * score) / 2
|
||||
}
|
||||
|
||||
open fun HandicapParams.clamp(input: Int): Int {
|
||||
|
Reference in New Issue
Block a user