Correct result entered for basic MMS test
This commit is contained in:
@@ -237,10 +237,20 @@ sealed class BaseSolver(
|
||||
|
||||
return score
|
||||
}
|
||||
open fun debug(p: Pairable) {
|
||||
|
||||
}
|
||||
open fun MainCritParams.minimizeScoreDifference(p1: Pairable, p2: Pairable): Double {
|
||||
var score = 0.0
|
||||
val scoreRange: Int = groupsCount
|
||||
if (p1.name == "Lefebvre" && p2.name == "Bonjean") {
|
||||
println("p1 ${p1.name} ${p1.group} ${p1.nbW}")
|
||||
debug(p1)
|
||||
|
||||
println("p2 ${p2.name} ${p2.group} ${p2.nbW}")
|
||||
debug(p2)
|
||||
|
||||
}
|
||||
if (scoreRange != 0){
|
||||
val x = abs(p1.group - p2.group).toDouble() / scoreRange.toDouble()
|
||||
score = concavityFunction(x, scoreWeight)
|
||||
@@ -417,7 +427,8 @@ sealed class BaseSolver(
|
||||
fun GeographicalParams.apply(p1: Pairable, p2: Pairable): Double {
|
||||
val placementScoreRange = groupsCount
|
||||
|
||||
val geoMaxCost = avoidSameGeo
|
||||
//val geoMaxCost = avoidSameGeo
|
||||
val geoMaxCost = 100000000000.0
|
||||
|
||||
val countryFactor = preferMMSDiffRatherThanSameCountry
|
||||
val clubFactor: Int = preferMMSDiffRatherThanSameClub
|
||||
@@ -455,7 +466,6 @@ sealed class BaseSolver(
|
||||
// TODO Same family
|
||||
|
||||
// compute geoRatio
|
||||
|
||||
val mainPart = max(countryRatio, clubRatio)
|
||||
val secPart = min(countryRatio, clubRatio)
|
||||
|
||||
@@ -466,7 +476,7 @@ sealed class BaseSolver(
|
||||
}
|
||||
|
||||
// The concavity function is applied to geoRatio to get geoCost
|
||||
val dbGeoCost: Double = geoMaxCost.toDouble() * (1.0 - geoRatio) * (1.0 + pairing.base.nx1 * geoRatio)
|
||||
val dbGeoCost: Double = concavityFunction(geoRatio, geoMaxCost)
|
||||
var score = pairing.main.scoreWeight - dbGeoCost
|
||||
|
||||
score = min(score, geoMaxCost)
|
||||
|
@@ -18,6 +18,10 @@ class MacMahonSolver(round: Int,
|
||||
} }
|
||||
}
|
||||
|
||||
override fun debug(p: Pairable) {
|
||||
println("${p.mms} ${p.mmBase} ${p.nbW}")
|
||||
}
|
||||
|
||||
val Pairable.mmBase: Double get() = min(max(rank, mmFloor), mmBar) + mmsZero
|
||||
val Pairable.mms: Double get() = scores[id] ?: 0.0
|
||||
|
||||
|
@@ -10,6 +10,7 @@ import org.junit.jupiter.api.TestInstance
|
||||
import org.junit.jupiter.api.TestMethodOrder
|
||||
import java.nio.charset.StandardCharsets
|
||||
import kotlin.math.abs
|
||||
import kotlin.reflect.typeOf
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@@ -344,20 +345,30 @@ class PairingTests: TestBase() {
|
||||
|
||||
var games: Json.Array
|
||||
var firstGameID: Int
|
||||
var forcedGames: Json.Array
|
||||
var game: Json
|
||||
|
||||
for (round in 1..5) {
|
||||
// games must be created and then modified by PUT
|
||||
games = TestAPI.post("/api/tour/$id/pair/$round", Json.Array("all")).asArray()
|
||||
logger.info("games for round $round: {}", games.toString())
|
||||
|
||||
assertTrue(compare_weights("weights.txt", "opengotha/simplemm/simplemm_weights_R$round.txt"), "Not matching opengotha weights for round $round")
|
||||
assertTrue(compare_games(games, Json.parse(pairings[round - 1])!!.asArray()),"pairings for round $round differ")
|
||||
logger.info("Pairings for round $round match OpenGotha")
|
||||
logger.info("Weights for round $round match OpenGotha")
|
||||
|
||||
forcedGames = Json.parse(pairings[round-1])!!.asArray()
|
||||
for (j in 0..forcedGames.size-1) {
|
||||
game = forcedGames.getJson(j)!!.asObject()
|
||||
TestAPI.put("/api/tour/$id/pair/$round", game)
|
||||
}
|
||||
|
||||
// Enter results
|
||||
firstGameID = (games.getJson(0)!!.asObject()["id"] as Long?)!!.toInt()
|
||||
for (gameID in firstGameID..firstGameID + 15) {
|
||||
resp = TestAPI.put("/api/tour/$id/res/$round", Json.parse("""{"id":$gameID,"result":"b"}""")).asObject()
|
||||
// Extract results
|
||||
val results = forcedGames.map { game -> game.toString().split("r\":\"")[1][0] }
|
||||
for (j in 0 .. forcedGames.size-1) {
|
||||
resp = TestAPI.put("/api/tour/$id/res/$round", Json.parse("""{"id":${firstGameID + j},"result":"${results[j]}"}""")).asObject()
|
||||
assertTrue(resp.getBoolean("success") == true, "expecting success")
|
||||
}
|
||||
|
||||
logger.info("Results succesfully entered for round $round")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user