Basic MMS computation
This commit is contained in:
@@ -9,7 +9,7 @@ import org.jeudego.pairgoth.store.Store
|
||||
sealed class Pairable(val id: ID, val name: String, open val rating: Int, open val rank: Int) {
|
||||
companion object {
|
||||
val MIN_RANK: Int = -30 // 30k
|
||||
val MAX_RANK: Int = 20
|
||||
val MAX_RANK: Int = 8 // 9D
|
||||
}
|
||||
abstract fun toJson(): Json.Object
|
||||
abstract val club: String?
|
||||
|
@@ -181,8 +181,8 @@ class MacMahon(
|
||||
placementParams: PlacementParams = PlacementParams(
|
||||
Criterion.NBW, Criterion.SOSW, Criterion.SOSOSW
|
||||
),
|
||||
var mmFloor: Int = -20,
|
||||
var mmBar: Int = 0
|
||||
var mmFloor: Int = -20, // 20k
|
||||
var mmBar: Int = 0 // 1D
|
||||
): Pairing(MAC_MAHON, pairingParams, placementParams) {
|
||||
companion object {}
|
||||
override fun pair(tournament: Tournament<*>, round: Int, pairables: List<Pairable>): List<Game> {
|
||||
|
@@ -236,7 +236,6 @@ sealed class BaseSolver(
|
||||
open fun MainCritParams.minimizeScoreDifference(p1: Pairable, p2: Pairable): Double {
|
||||
var score = 0.0
|
||||
val scoreRange: Int = groupsCount
|
||||
// TODO check category equality if category are used in SwissCat
|
||||
if (scoreRange != 0){
|
||||
val x = abs(p1.group - p2.group).toDouble() / scoreRange.toDouble()
|
||||
score = concavityFunction(x, scoreWeight)
|
||||
|
@@ -13,17 +13,18 @@ class MacMahonSolver(round: Int,
|
||||
BaseSolver(round, history, pairables, pairingParams, placementParams) {
|
||||
|
||||
override val scores: Map<ID, Double> by lazy {
|
||||
historyHelper.wins.mapValues {
|
||||
pairablesMap[it.key]!!.let { pairable ->
|
||||
pairable.mmBase + pairable.nbW
|
||||
}
|
||||
}
|
||||
pairablesMap.mapValues { it.value.let {
|
||||
pairable -> pairable.mmBase + pairable.nbW // TODO take tournament parameter into account
|
||||
} }
|
||||
}
|
||||
|
||||
val Pairable.mmBase: Double get() = min(max(rank, mmFloor), mmBar) + mmsZero
|
||||
val Pairable.mms: Double get() = scores[id] ?: 0.0
|
||||
|
||||
// CB TODO - configurable criteria
|
||||
override val mainLimits get() = Pair(mmFloor.toDouble(), 100.0) // TODO ?
|
||||
val mainScoreMin = mmFloor + PLA_SMMS_SCORE_MIN - Pairable.MIN_RANK
|
||||
val mainScoreMax = mmBar + PLA_SMMS_SCORE_MAX + (round-1) - Pairable.MIN_RANK // round number starts at 1
|
||||
override val mainLimits get() = Pair(mainScoreMin.toDouble(), mainScoreMax.toDouble())
|
||||
override fun evalCriterion(pairable: Pairable, criterion: Criterion) = when (criterion) {
|
||||
Criterion.MMS -> pairable.mms
|
||||
Criterion.SOSM -> pairable.sos
|
||||
@@ -35,6 +36,8 @@ class MacMahonSolver(round: Int,
|
||||
|
||||
companion object {
|
||||
const val mmsZero = 30.0
|
||||
const val PLA_SMMS_SCORE_MAX = 2 // TODO move this into placement criteria
|
||||
const val PLA_SMMS_SCORE_MIN = -1
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user