proper legacy mode and compare all pairings with new pairgoth pairings. Toulouse and simpleMM pairings differ
This commit is contained in:

committed by
Claude Brisson

parent
af649fc9ee
commit
21f9741a8b
@@ -33,7 +33,7 @@ sealed class BaseSolver(
|
|||||||
val rand = Random(/* seed from properties - TODO */)
|
val rand = Random(/* seed from properties - TODO */)
|
||||||
// Used in tests
|
// Used in tests
|
||||||
var weightsLogger: PrintWriter? = null
|
var weightsLogger: PrintWriter? = null
|
||||||
var asymmetricDetRandom = false
|
var legacy_mode = false
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun openGothaWeight(p1: Pairable, p2: Pairable) =
|
open fun openGothaWeight(p1: Pairable, p2: Pairable) =
|
||||||
@@ -389,7 +389,7 @@ sealed class BaseSolver(
|
|||||||
val randRange = maxSeedingWeight * 0.2
|
val randRange = maxSeedingWeight * 0.2
|
||||||
// for old tests to pass
|
// for old tests to pass
|
||||||
val rand =
|
val rand =
|
||||||
if (asymmetricDetRandom && p1.fullName() > p2.fullName()) {
|
if (legacy_mode && p1.fullName() > p2.fullName()) {
|
||||||
// for old tests to pass
|
// for old tests to pass
|
||||||
detRandom(randRange, p2, p1, false)
|
detRandom(randRange, p2, p1, false)
|
||||||
} else {
|
} else {
|
||||||
@@ -426,13 +426,12 @@ sealed class BaseSolver(
|
|||||||
val placementScoreRange = groupsCount
|
val placementScoreRange = groupsCount
|
||||||
|
|
||||||
val geoMaxCost = pairing.geo.avoidSameGeo
|
val geoMaxCost = pairing.geo.avoidSameGeo
|
||||||
//val geoMaxCost = 100000000000.0
|
|
||||||
|
|
||||||
val countryFactor: Int = if (biggestCountrySize.toDouble() / pairables.size <= proportionMainClubThreshold)
|
val countryFactor: Int = if (legacy_mode || biggestCountrySize.toDouble() / pairables.size <= proportionMainClubThreshold)
|
||||||
preferMMSDiffRatherThanSameCountry
|
preferMMSDiffRatherThanSameCountry
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
val clubFactor: Int = if (biggestClubSize.toDouble() / pairables.size <= proportionMainClubThreshold)
|
val clubFactor: Int = if (legacy_mode || biggestClubSize.toDouble() / pairables.size <= proportionMainClubThreshold)
|
||||||
preferMMSDiffRatherThanSameClub
|
preferMMSDiffRatherThanSameClub
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
|
@@ -2,6 +2,7 @@ package org.jeudego.pairgoth.test
|
|||||||
|
|
||||||
import com.republicate.kson.Json
|
import com.republicate.kson.Json
|
||||||
import org.jeudego.pairgoth.pairing.solver.BaseSolver
|
import org.jeudego.pairgoth.pairing.solver.BaseSolver
|
||||||
|
import org.jeudego.pairgoth.model.Game
|
||||||
import org.jeudego.pairgoth.test.PairingTests.Companion.compare_weights
|
import org.jeudego.pairgoth.test.PairingTests.Companion.compare_weights
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@@ -22,24 +23,31 @@ class BOSP2024Test: TestBase() {
|
|||||||
val resp = TestAPI.post("/api/tour", tournament).asObject()
|
val resp = TestAPI.post("/api/tour", tournament).asObject()
|
||||||
val tourId = resp.getInt("id")
|
val tourId = resp.getInt("id")
|
||||||
BaseSolver.weightsLogger = PrintWriter(FileWriter(getOutputFile("bosp2024-weights.txt")))
|
BaseSolver.weightsLogger = PrintWriter(FileWriter(getOutputFile("bosp2024-weights.txt")))
|
||||||
|
|
||||||
|
BaseSolver.legacy_mode = true
|
||||||
|
TestAPI.post("/api/tour/$tourId/pair/3", Json.Array("all")).asArray()
|
||||||
|
|
||||||
|
// compare weights
|
||||||
|
assertTrue(compare_weights(getOutputFile("bosp2024-weights.txt"), getTestFile("opengotha/bosp2024/bosp2024_weights_R3.txt")), "Not matching opengotha weights for BOSP test")
|
||||||
|
TestAPI.delete("/api/tour/$tourId/pair/3", Json.Array("all"))
|
||||||
|
|
||||||
|
BaseSolver.legacy_mode = false
|
||||||
val games = TestAPI.post("/api/tour/$tourId/pair/3", Json.Array("all")).asArray()
|
val games = TestAPI.post("/api/tour/$tourId/pair/3", Json.Array("all")).asArray()
|
||||||
// Aksut Husrev is ID 18
|
// Aksut Husrev is ID 18
|
||||||
val buggy = games.map { it as Json.Object }.filter { game ->
|
val solved = games.map { it as Json.Object }.filter { game ->
|
||||||
// build the two-elements set of players ids
|
// build the two-elements set of players ids
|
||||||
val players = game.entries.filter { (k, v) -> k == "b" || k == "w" }.map { (k, v) -> (v as Number).toInt() }.toSet()
|
val players = game.entries.filter { (k, v) -> k == "b" || k == "w" }.map { (k, v) -> (v as Number).toInt() }.toSet()
|
||||||
// keep game with Aksut Husrev
|
// keep game with Aksut Husrev
|
||||||
players.contains(18)
|
players.contains(18)
|
||||||
}.firstOrNull()
|
}.firstOrNull()
|
||||||
|
|
||||||
assertNotNull(buggy)
|
assertNotNull(solved)
|
||||||
|
|
||||||
// if the bug is still here, the opponent is Suleymanoglu Serap, id 24
|
// if the bug is still here, the opponent is Suleymanoglu Serap, id 24
|
||||||
val black = buggy!!.getInt("b")!!
|
val black = solved.getInt("b")!!
|
||||||
val white = buggy!!.getInt("w")!!
|
val white = solved.getInt("w")!!
|
||||||
val opponent = if (black == 18) white else black
|
val opponent = if (black == 18) white else black
|
||||||
assertNotEquals(24, opponent)
|
assertNotEquals(24, opponent)
|
||||||
|
|
||||||
// compare weights
|
|
||||||
//assertTrue(compare_weights(getOutputFile("bosp2024-weights.txt"), getTestFile("opengotha/bosp2024/bosp2024_weights_R3.txt")), "Not matching opengotha weights for BOSP test")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -164,9 +164,14 @@ class PairingTests: TestBase() {
|
|||||||
return sumOfWeights
|
return sumOfWeights
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_from_XML(name:String, forcePairing:List<Int>){
|
fun test_from_XML(name: String, forcePairing:List<Int>) {
|
||||||
|
test_from_XML_internal(name, true)
|
||||||
|
test_from_XML_internal(name, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test_from_XML_internal(name: String, legacy: Boolean){
|
||||||
// Let pairgoth use the legacy asymmetric detRandom()
|
// Let pairgoth use the legacy asymmetric detRandom()
|
||||||
BaseSolver.asymmetricDetRandom = true
|
BaseSolver.legacy_mode = legacy
|
||||||
// read tournament with pairing
|
// read tournament with pairing
|
||||||
val file = getTestFile("opengotha/pairings/$name.xml")
|
val file = getTestFile("opengotha/pairings/$name.xml")
|
||||||
logger.info("read from file $file")
|
logger.info("read from file $file")
|
||||||
@@ -203,8 +208,10 @@ class PairingTests: TestBase() {
|
|||||||
logger.info("sumOfWeightOG = " + dec.format(sumOfWeightsOG))
|
logger.info("sumOfWeightOG = " + dec.format(sumOfWeightsOG))
|
||||||
logger.info("games for round $round: {}", games.toString())
|
logger.info("games for round $round: {}", games.toString())
|
||||||
|
|
||||||
// Compare weights with OpenGotha
|
// Compare weights with OpenGotha if legacy mode
|
||||||
|
if (legacy) {
|
||||||
assertTrue(compare_weights(getOutputFile("weights.txt"), getTestFile("opengotha/$name/$name"+"_weights_R$round.txt")), "Not matching opengotha weights for round $round")
|
assertTrue(compare_weights(getOutputFile("weights.txt"), getTestFile("opengotha/$name/$name"+"_weights_R$round.txt")), "Not matching opengotha weights for round $round")
|
||||||
|
}
|
||||||
|
|
||||||
if (round in forcePairing) {
|
if (round in forcePairing) {
|
||||||
logger.info("Non unique pairing, forcing Opengotha pairing to Pairgoth")
|
logger.info("Non unique pairing, forcing Opengotha pairing to Pairgoth")
|
||||||
@@ -265,7 +272,7 @@ class PairingTests: TestBase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `SwissTest simpleSwiss`() {
|
fun `SwissTest simpleSwiss`() {
|
||||||
BaseSolver.asymmetricDetRandom = true
|
BaseSolver.legacy_mode = true
|
||||||
// read tournament with pairing
|
// read tournament with pairing
|
||||||
var file = getTestFile("opengotha/pairings/simpleswiss.xml")
|
var file = getTestFile("opengotha/pairings/simpleswiss.xml")
|
||||||
logger.info("read from file $file")
|
logger.info("read from file $file")
|
||||||
@@ -346,7 +353,7 @@ class PairingTests: TestBase() {
|
|||||||
@Test
|
@Test
|
||||||
fun `SwissTest KPMCSplitbug`() {
|
fun `SwissTest KPMCSplitbug`() {
|
||||||
// Let pairgoth use the legacy asymmetric detRandom()
|
// Let pairgoth use the legacy asymmetric detRandom()
|
||||||
BaseSolver.asymmetricDetRandom = true
|
BaseSolver.legacy_mode = true
|
||||||
// read tournament with pairing
|
// read tournament with pairing
|
||||||
val name = "20240921-KPMC-Splitbug"
|
val name = "20240921-KPMC-Splitbug"
|
||||||
val file = getTestFile("opengotha/pairings/$name.xml")
|
val file = getTestFile("opengotha/pairings/$name.xml")
|
||||||
|
Reference in New Issue
Block a user