Code cleaning ; rename secParams.rankThreshold to rankSecThreshold
This commit is contained in:
@@ -6,7 +6,6 @@ import java.time.LocalDate
|
||||
import org.jeudego.pairgoth.model.*
|
||||
import org.jeudego.pairgoth.opengotha.TournamentType
|
||||
import org.jeudego.pairgoth.opengotha.ObjectFactory
|
||||
import org.jeudego.pairgoth.store.Store
|
||||
import org.jeudego.pairgoth.store.nextGameId
|
||||
import org.jeudego.pairgoth.store.nextPlayerId
|
||||
import org.jeudego.pairgoth.store.nextTournamentId
|
||||
@@ -93,7 +92,7 @@ object OpenGotha {
|
||||
),
|
||||
secondary = SecondaryCritParams(
|
||||
barThresholdActive = pairParams.paiSeBarThresholdActive.toBoolean(),
|
||||
rankThreshold = Pairable.parseRank(pairParams.paiSeRankThreshold),
|
||||
rankSecThreshold = Pairable.parseRank(pairParams.paiSeRankThreshold),
|
||||
nbWinsThresholdActive = pairParams.paiSeNbWinsThresholdActive.toBoolean(),
|
||||
defSecCrit = pairParams.paiSeDefSecCrit.toDouble()
|
||||
),
|
||||
@@ -333,7 +332,7 @@ object OpenGotha {
|
||||
}
|
||||
</PlacementCriteria>
|
||||
</PlacementParameterSet>
|
||||
<PairingParameterSet paiBaAvoidDuplGame="${tournament.pairing.pairingParams.base.dupWeight.toLong()}" paiBaBalanceWB="${tournament.pairing.pairingParams.base.colorBalanceWeight.toLong()}" paiBaDeterministic="${tournament.pairing.pairingParams.base.deterministic}" paiBaRandom="${tournament.pairing.pairingParams.base.random.toLong()}" paiMaAdditionalPlacementCritSystem1="${tournament.pairing.pairingParams.main.additionalPlacementCritSystem1.toString().titlecase()}" paiMaAdditionalPlacementCritSystem2="${tournament.pairing.pairingParams.main.additionalPlacementCritSystem2.toString().titlecase()}" paiMaAvoidMixingCategories="${tournament.pairing.pairingParams.main.categoriesWeight.toLong()}" paiMaCompensateDUDD="${tournament.pairing.pairingParams.main.compensateDrawUpDown}" paiMaDUDDLowerMode="${tournament.pairing.pairingParams.main.drawUpDownLowerMode.toString().substring(0, 3)}" paiMaDUDDUpperMode="${tournament.pairing.pairingParams.main.drawUpDownUpperMode.toString().substring(0, 3)}" paiMaDUDDWeight="${tournament.pairing.pairingParams.main.drawUpDownWeight.toLong()}" paiMaLastRoundForSeedSystem1="${tournament.pairing.pairingParams.main.lastRoundForSeedSystem1}" paiMaMaximizeSeeding="${tournament.pairing.pairingParams.main.seedingWeight.toLong()}" paiMaMinimizeScoreDifference="${tournament.pairing.pairingParams.main.scoreWeight.toLong()}" paiMaSeedSystem1="${tournament.pairing.pairingParams.main.seedSystem1.format()}" paiMaSeedSystem2="${tournament.pairing.pairingParams.main.seedSystem2.format()}" paiSeAvoidSameGeo="${tournament.pairing.pairingParams.geo.avoidSameGeo.toLong()}" paiSeBarThresholdActive="${tournament.pairing.pairingParams.secondary.barThresholdActive}" paiSeDefSecCrit="${tournament.pairing.pairingParams.secondary.defSecCrit.toLong()}" paiSeMinimizeHandicap="${tournament.pairing.pairingParams.handicap.weight.toLong()}" paiSeNbWinsThresholdActive="${tournament.pairing.pairingParams.secondary.nbWinsThresholdActive}" paiSePreferMMSDiffRatherThanSameClub="${tournament.pairing.pairingParams.geo.preferMMSDiffRatherThanSameClub}" paiSePreferMMSDiffRatherThanSameCountry="${tournament.pairing.pairingParams.geo.preferMMSDiffRatherThanSameCountry}" paiSeRankThreshold="${displayRank(tournament.pairing.pairingParams.secondary.rankThreshold).uppercase()}" paiStandardNX1Factor="${tournament.pairing.pairingParams.base.nx1}"/>
|
||||
<PairingParameterSet paiBaAvoidDuplGame="${tournament.pairing.pairingParams.base.dupWeight.toLong()}" paiBaBalanceWB="${tournament.pairing.pairingParams.base.colorBalanceWeight.toLong()}" paiBaDeterministic="${tournament.pairing.pairingParams.base.deterministic}" paiBaRandom="${tournament.pairing.pairingParams.base.random.toLong()}" paiMaAdditionalPlacementCritSystem1="${tournament.pairing.pairingParams.main.additionalPlacementCritSystem1.toString().titlecase()}" paiMaAdditionalPlacementCritSystem2="${tournament.pairing.pairingParams.main.additionalPlacementCritSystem2.toString().titlecase()}" paiMaAvoidMixingCategories="${tournament.pairing.pairingParams.main.categoriesWeight.toLong()}" paiMaCompensateDUDD="${tournament.pairing.pairingParams.main.compensateDrawUpDown}" paiMaDUDDLowerMode="${tournament.pairing.pairingParams.main.drawUpDownLowerMode.toString().substring(0, 3)}" paiMaDUDDUpperMode="${tournament.pairing.pairingParams.main.drawUpDownUpperMode.toString().substring(0, 3)}" paiMaDUDDWeight="${tournament.pairing.pairingParams.main.drawUpDownWeight.toLong()}" paiMaLastRoundForSeedSystem1="${tournament.pairing.pairingParams.main.lastRoundForSeedSystem1}" paiMaMaximizeSeeding="${tournament.pairing.pairingParams.main.seedingWeight.toLong()}" paiMaMinimizeScoreDifference="${tournament.pairing.pairingParams.main.scoreWeight.toLong()}" paiMaSeedSystem1="${tournament.pairing.pairingParams.main.seedSystem1.format()}" paiMaSeedSystem2="${tournament.pairing.pairingParams.main.seedSystem2.format()}" paiSeAvoidSameGeo="${tournament.pairing.pairingParams.geo.avoidSameGeo.toLong()}" paiSeBarThresholdActive="${tournament.pairing.pairingParams.secondary.barThresholdActive}" paiSeDefSecCrit="${tournament.pairing.pairingParams.secondary.defSecCrit.toLong()}" paiSeMinimizeHandicap="${tournament.pairing.pairingParams.handicap.weight.toLong()}" paiSeNbWinsThresholdActive="${tournament.pairing.pairingParams.secondary.nbWinsThresholdActive}" paiSePreferMMSDiffRatherThanSameClub="${tournament.pairing.pairingParams.geo.preferMMSDiffRatherThanSameClub}" paiSePreferMMSDiffRatherThanSameCountry="${tournament.pairing.pairingParams.geo.preferMMSDiffRatherThanSameCountry}" paiSeRankThreshold="${displayRank(tournament.pairing.pairingParams.secondary.rankSecThreshold).uppercase()}" paiStandardNX1Factor="${tournament.pairing.pairingParams.base.nx1}"/>
|
||||
<DPParameterSet displayClCol="true" displayCoCol="true" displayIndGamesInMatches="true" displayNPPlayers="false" displayNumCol="true" displayPlCol="true" gameFormat="short" playerSortType="name" showByePlayer="true" showNotFinallyRegisteredPlayers="true" showNotPairedPlayers="true" showNotParticipatingPlayers="false" showPlayerClub="true" showPlayerCountry="false" showPlayerGrade="true"/>
|
||||
<PublishParameterSet exportToLocalFile="true" htmlAutoScroll="false" print="false"/>
|
||||
</TournamentParameterSet>
|
||||
|
@@ -6,7 +6,6 @@ import org.jeudego.pairgoth.model.MainCritParams.SeedMethod.SPLIT_AND_SLIP
|
||||
import org.jeudego.pairgoth.model.PairingType.*
|
||||
import org.jeudego.pairgoth.pairing.solver.MacMahonSolver
|
||||
import org.jeudego.pairgoth.pairing.solver.SwissSolver
|
||||
import java.util.*
|
||||
import kotlin.math.min
|
||||
|
||||
// base pairing parameters
|
||||
@@ -69,7 +68,7 @@ data class MainCritParams(
|
||||
// secondary criterium parameters
|
||||
data class SecondaryCritParams(
|
||||
val barThresholdActive: Boolean = true, // Do not apply secondary criteria for players above bar
|
||||
val rankThreshold: Int = 0, // Do not apply secondary criteria above 1D rank
|
||||
val rankSecThreshold: Int = 0, // Do not apply secondary criteria above 1D rank
|
||||
val nbWinsThresholdActive: Boolean = true, // Do not apply secondary criteria when nbWins >= nbRounds / 2
|
||||
val defSecCrit: Double = MainCritParams.MAX_CATEGORIES_WEIGHT, // Should be MA_MAX_MINIMIZE_SCORE_DIFFERENCE for MM, MA_MAX_AVOID_MIXING_CATEGORIES for others
|
||||
) {
|
||||
@@ -158,7 +157,7 @@ class Swiss(
|
||||
),
|
||||
secondary = SecondaryCritParams(
|
||||
barThresholdActive = true,
|
||||
rankThreshold = -30,
|
||||
rankSecThreshold = -30,
|
||||
nbWinsThresholdActive = true,
|
||||
defSecCrit = MainCritParams.MAX_CATEGORIES_WEIGHT
|
||||
),
|
||||
@@ -269,14 +268,14 @@ fun MainCritParams.toJson() = Json.Object(
|
||||
|
||||
fun SecondaryCritParams.Companion.fromJson(json: Json.Object, localDefault: SecondaryCritParams? = null) = SecondaryCritParams(
|
||||
barThresholdActive = json.getBoolean("barThreshold") ?: localDefault?.barThresholdActive ?: default.barThresholdActive,
|
||||
rankThreshold = json.getInt("rankThreshold") ?: localDefault?.rankThreshold ?: default.rankThreshold,
|
||||
rankSecThreshold = json.getInt("rankThreshold") ?: localDefault?.rankSecThreshold ?: default.rankSecThreshold,
|
||||
nbWinsThresholdActive = json.getBoolean("winsThreshold") ?: localDefault?.nbWinsThresholdActive ?: default.nbWinsThresholdActive,
|
||||
defSecCrit = json.getDouble("secWeight") ?: localDefault?.defSecCrit ?: default.defSecCrit
|
||||
)
|
||||
|
||||
fun SecondaryCritParams.toJson() = Json.Object(
|
||||
"barThreshold" to barThresholdActive,
|
||||
"rankThreshold" to rankThreshold,
|
||||
"rankThreshold" to rankSecThreshold,
|
||||
"winsThreshold" to nbWinsThresholdActive,
|
||||
"secWeight" to defSecCrit
|
||||
)
|
||||
|
@@ -429,13 +429,6 @@ sealed class BaseSolver(
|
||||
return score
|
||||
}
|
||||
|
||||
open fun SecondaryCritParams.notNeeded(p1: Pairable, p2: Pairable) {
|
||||
// secCase = 0 : No player is above thresholds
|
||||
// secCase = 1 : One player is above thresholds
|
||||
// secCase = 2 : Both players are above thresholds
|
||||
// TODO understand where it is used
|
||||
}
|
||||
|
||||
fun GeographicalParams.apply(p1: Pairable, p2: Pairable): Double {
|
||||
val placementScoreRange = groupsCount
|
||||
|
||||
|
@@ -35,26 +35,22 @@ class MacMahonSolver(round: Int,
|
||||
|
||||
override fun SecondaryCritParams.apply(p1: Pairable, p2: Pairable): Double {
|
||||
|
||||
// Do we apply Secondary Criteria
|
||||
// secCase = 0 : No player is above thresholds -> apply secondary criteria
|
||||
// secCase = 1 : At least one player is above thresholds -> do not apply
|
||||
// Do we apply Secondary Criteria.
|
||||
// No player is above thresholds -> apply secondary criteria
|
||||
// At least one player is above thresholds -> do not apply
|
||||
|
||||
var score = 0.0
|
||||
var secCase = 0
|
||||
val nbw2Threshold =
|
||||
if (nbWinsThresholdActive) totalRounds
|
||||
else 2 * totalRounds
|
||||
|
||||
val nbw2Threshold: Int
|
||||
if (nbWinsThresholdActive) nbw2Threshold = totalRounds
|
||||
else nbw2Threshold = 2 * totalRounds
|
||||
val skipSecondary =
|
||||
(2 * p1.nbW >= nbw2Threshold) ||
|
||||
(2 * p2.nbW >= nbw2Threshold) ||
|
||||
(p1.rank + p1.nbW >= mmBar) ||
|
||||
(p2.rank + p2.nbW >= mmBar)
|
||||
|
||||
if( (2*p1.nbW >= nbw2Threshold) ||
|
||||
(2*p2.nbW >= nbw2Threshold) ||
|
||||
(p1.rank+p1.nbW >= mmBar) ||
|
||||
(p2.rank+p2.nbW >= mmBar) ) secCase = 1
|
||||
|
||||
|
||||
if (secCase == 0) score = pairing.geo.apply(p1, p2)
|
||||
|
||||
return score
|
||||
return if (skipSecondary) 0.0
|
||||
else pairing.geo.apply(p1, p2)
|
||||
}
|
||||
|
||||
override fun HandicapParams.pseudoRank(pairable: Pairable): Int {
|
||||
|
Reference in New Issue
Block a user