Handle additionnal seeding criterium
This commit is contained in:
@@ -16,7 +16,7 @@ sealed class Pairable(val id: ID, val name: String, open val rating: Int, open v
|
||||
abstract fun toMutableJson(): Json.MutableObject
|
||||
abstract val club: String?
|
||||
abstract val country: String?
|
||||
open fun nameSeed(separator: String =" "): String {
|
||||
open fun fullName(separator: String = " "): String {
|
||||
return name
|
||||
}
|
||||
val skip = mutableSetOf<Int>() // skipped rounds
|
||||
@@ -95,7 +95,7 @@ class Player(
|
||||
}
|
||||
|
||||
override fun toJson(): Json.Object = toMutableJson()
|
||||
override fun nameSeed(separator: String): String {
|
||||
override fun fullName(separator: String): String {
|
||||
return name + separator + firstname
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import org.jeudego.pairgoth.model.*
|
||||
import java.util.*
|
||||
|
||||
abstract class BasePairingHelper(
|
||||
val round: Int,
|
||||
history: List<List<Game>>, // History of all games played for each round
|
||||
var pairables: List<Pairable>, // All pairables for this round, it may include the bye player
|
||||
val pairing: PairingParams,
|
||||
@@ -125,15 +126,22 @@ abstract class BasePairingHelper(
|
||||
val criterionP = p.eval(criterion)
|
||||
val criterionQ = q.eval(criterion)
|
||||
if (criterionP != criterionQ) {
|
||||
return (criterionQ * 1e6 - criterionP * 1e6).toInt()
|
||||
return -criterionP.compareTo(criterionQ)
|
||||
}
|
||||
}
|
||||
if (p.rating == q.rating) {
|
||||
return if (p.name > q.name) 1 else -1
|
||||
val additionalCriterion =
|
||||
if (round <= pairing.main.lastRoundForSeedSystem1) pairing.main.additionalPlacementCritSystem1
|
||||
else pairing.main.additionalPlacementCritSystem2
|
||||
if (additionalCriterion != Criterion.NONE) {
|
||||
val criterionP = p.eval(additionalCriterion)
|
||||
val criterionQ = q.eval(additionalCriterion)
|
||||
if (criterionP != criterionQ) {
|
||||
return -criterionP.compareTo(criterionQ)
|
||||
}
|
||||
return q.rating - p.rating
|
||||
}
|
||||
return p.fullName().compareTo(q.fullName())
|
||||
}
|
||||
open fun nameSort(p: Pairable, q: Pairable): Int {
|
||||
return if (p.name > q.name) 1 else -1
|
||||
return p.fullName().compareTo(q.fullName())
|
||||
}
|
||||
}
|
@@ -4,8 +4,8 @@ import org.jeudego.pairgoth.model.Pairable
|
||||
|
||||
fun detRandom(max: Double, p1: Pairable, p2: Pairable): Double {
|
||||
var inverse = false
|
||||
var name1 = p1.nameSeed("")
|
||||
var name2 = p2.nameSeed("")
|
||||
var name1 = p1.fullName("")
|
||||
var name2 = p2.fullName("")
|
||||
if (name1 > name2) {
|
||||
name1 = name2.also { name2 = name1 }
|
||||
inverse = true
|
||||
|
@@ -22,13 +22,13 @@ import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
sealed class BaseSolver(
|
||||
val round: Int, // Round number
|
||||
round: Int,
|
||||
history: List<List<Game>>, // History of all games played for each round
|
||||
pairables: List<Pairable>, // All pairables for this round, it may include the bye player
|
||||
pairing: PairingParams,
|
||||
placement: PlacementParams,
|
||||
val usedTables: BitSet
|
||||
) : BasePairingHelper(history, pairables, pairing, placement) {
|
||||
) : BasePairingHelper(round, history, pairables, pairing, placement) {
|
||||
|
||||
companion object {
|
||||
val rand = Random(/* seed from properties - TODO */)
|
||||
@@ -77,7 +77,7 @@ sealed class BaseSolver(
|
||||
}
|
||||
// println("choose Bye: " + p.nameSeed() + " mms2 " +2*p.main+" "+ weightForBye)
|
||||
}
|
||||
println("Bye player : " + chosenByePlayer.nameSeed())
|
||||
println("Bye player : " + chosenByePlayer.fullName())
|
||||
byePlayers.add(chosenByePlayer)
|
||||
nameSortedPairables.remove(chosenByePlayer)
|
||||
// Keep chosenByePlayer in pairingSortedPairables to be identical to opengotha
|
||||
@@ -91,8 +91,8 @@ sealed class BaseSolver(
|
||||
weight(p, q).let { if (it != Double.NaN) builder.addEdge(p, q, it/1e6) }
|
||||
weight(q, p).let { if (it != Double.NaN) builder.addEdge(q, p, it/1e6) }
|
||||
weightsLogger?.apply {
|
||||
this.println("Player1Name=${p.nameSeed()}")
|
||||
this.println("Player2Name=${q.nameSeed()}")
|
||||
this.println("Player1Name=${p.fullName()}")
|
||||
this.println("Player2Name=${q.fullName()}")
|
||||
this.println("baseDuplicateGameCost=${dec.format(pairing.base.avoidDuplicatingGames(p, q))}")
|
||||
this.println("baseRandomCost=${dec.format(pairing.base.applyRandom(p, q))}")
|
||||
this.println("baseBWBalanceCost=${dec.format(pairing.base.applyColorBalance(p, q))}")
|
||||
@@ -384,7 +384,7 @@ sealed class BaseSolver(
|
||||
if ((2 * cla1 < groupSize && 2 * cla2 >= groupSize) || (2 * cla1 >= groupSize && 2 * cla2 < groupSize)) {
|
||||
val randRange = maxSeedingWeight * 0.2
|
||||
val rand: Double
|
||||
if (p1.nameSeed() > p2.nameSeed()) {rand = detRandom(randRange, p2, p1)}
|
||||
if (p1.fullName() > p2.fullName()) {rand = detRandom(randRange, p2, p1)}
|
||||
else {rand = detRandom(randRange, p1, p2)}
|
||||
maxSeedingWeight - rand
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user