diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/Solver.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/Solver.kt index e2af397..1f1d973 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/Solver.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/Solver.kt @@ -173,13 +173,19 @@ sealed class Solver( val graph = builder.build() val matching = KolmogorovWeightedPerfectMatching(graph, ObjectiveSense.MAXIMIZE) val solution = matching.matching - + val sorted = solution.map{ listOf(graph.getEdgeSource(it), graph.getEdgeTarget(it)) - }.sortedWith(compareBy({ 0.5*(it[0].place + it[1].place) }, { min(it[0].place, it[1].place) })) + }.sortedWith(compareBy({ min(it[0].place, it[1].place) })) val result = sorted.flatMap { games(white = it[0], black = it[1]) } + if (DEBUG_EXPORT_WEIGHT) { + for (it in sorted) { + println(it[0].nameSeed() + " " + it[0].place.toString() + " vs " +it[1].nameSeed() + " " +it[1].place.toString()) + } + } + return result } diff --git a/api-webapp/src/test/kotlin/BasicTests.kt b/api-webapp/src/test/kotlin/BasicTests.kt index dc88e5b..0058248 100644 --- a/api-webapp/src/test/kotlin/BasicTests.kt +++ b/api-webapp/src/test/kotlin/BasicTests.kt @@ -278,6 +278,11 @@ class BasicTests: TestBase() { return identical } + fun compare_games(games:String, pairings:String): Boolean{ + println("Compare games ") + return false + } + fun compare_string(string1:String, string2:String): String{ for (i in 0..string1.length) { // Check if key exists in both @@ -292,7 +297,7 @@ class BasicTests: TestBase() { fun `008 simple swiss tournament`() { /* // read tournament with pairing - var file = getTestFile("opengotha/tournamentfiles/simpleswiss.xml") + var file = getTestFile("opengotha/tournamentfiles/simpleswiss_orderTableNumberScoreRating.xml") logger.info("read from file $file") val resource = file.readText(StandardCharsets.UTF_8) val resp = TestAPI.post("/api/tour", resource) @@ -331,10 +336,11 @@ class BasicTests: TestBase() { val pairings_R1 = """[{"id":843,"w":525,"b":530,"h":0,"r":"?","dd":0},{"id":844,"w":516,"b":514,"h":0,"r":"?","dd":0},{"id":845,"w":532,"b":524,"h":0,"r":"?","dd":0},{"id":846,"w":513,"b":509,"h":0,"r":"?","dd":0},{"id":847,"w":533,"b":508,"h":0,"r":"?","dd":0},{"id":848,"w":504,"b":517,"h":0,"r":"?","dd":0},{"id":849,"w":507,"b":506,"h":0,"r":"?","dd":0},{"id":850,"w":523,"b":529,"h":0,"r":"?","dd":0},{"id":851,"w":503,"b":518,"h":0,"r":"?","dd":0},{"id":852,"w":512,"b":528,"h":0,"r":"?","dd":0},{"id":853,"w":515,"b":510,"h":0,"r":"?","dd":0},{"id":854,"w":502,"b":531,"h":0,"r":"?","dd":0},{"id":855,"w":505,"b":519,"h":0,"r":"?","dd":0},{"id":856,"w":522,"b":511,"h":0,"r":"?","dd":0},{"id":857,"w":521,"b":526,"h":0,"r":"?","dd":0},{"id":858,"w":527,"b":520,"h":0,"r":"?","dd":0}]""" val pairings_R2 = """[{"id":859,"w":526,"b":530,"h":0,"r":"?","dd":0},{"id":860,"w":524,"b":514,"h":0,"r":"?","dd":0},{"id":861,"w":509,"b":517,"h":0,"r":"?","dd":0},{"id":862,"w":508,"b":518,"h":0,"r":"?","dd":0},{"id":863,"w":510,"b":506,"h":0,"r":"?","dd":0},{"id":864,"w":531,"b":529,"h":0,"r":"?","dd":0},{"id":865,"w":511,"b":528,"h":0,"r":"?","dd":0},{"id":866,"w":520,"b":519,"h":0,"r":"?","dd":0},{"id":867,"w":532,"b":516,"h":0,"r":"?","dd":0},{"id":868,"w":513,"b":504,"h":0,"r":"?","dd":0},{"id":869,"w":503,"b":533,"h":0,"r":"?","dd":0},{"id":870,"w":515,"b":507,"h":0,"r":"?","dd":0},{"id":871,"w":523,"b":502,"h":0,"r":"?","dd":0},{"id":872,"w":522,"b":512,"h":0,"r":"?","dd":0},{"id":873,"w":527,"b":505,"h":0,"r":"?","dd":0},{"id":874,"w":521,"b":525,"h":0,"r":"?","dd":0}]""" - val pairings_R3 = """[{"id":875,"w":519,"b":530,"h":0,"r":"?","dd":0},{"id":876,"w":514,"b":517,"h":0,"r":"?","dd":0},{"id":877,"w":529,"b":506,"h":0,"r":"?","dd":0},{"id":878,"w":518,"b":528,"h":0,"r":"?","dd":0},{"id":879,"w":510,"b":509,"h":0,"r":"?","dd":0},{"id":880,"w":505,"b":504,"h":0,"r":"?","dd":0},{"id":881,"w":526,"b":511,"h":0,"r":"?","dd":0},{"id":882,"w":525,"b":520,"h":0,"r":"?","dd":0},{"id":883,"w":507,"b":508,"h":0,"r":"?","dd":0},{"id":884,"w":531,"b":512,"h":0,"r":"?","dd":0},{"id":885,"w":516,"b":502,"h":0,"r":"?","dd":0},{"id":886,"w":524,"b":533,"h":0,"r":"?","dd":0},{"id":887,"w":513,"b":532,"h":0,"r":"?","dd":0},{"id":888,"w":521,"b":515,"h":0,"r":"?","dd":0},{"id":889,"w":522,"b":503,"h":0,"r":"?","dd":0},{"id":890,"w":527,"b":523,"h":0,"r":"?","dd":0}]""" + val pairings_R3 = """[{"id":875,"w":519,"b":530,"h":0,"r":"?","dd":0},{"id":876,"w":514,"b":517,"h":0,"r":"?","dd":0},{"id":877,"w":529,"b":506,"h":0,"r":"?","dd":0},{"id":878,"w":518,"b":528,"h":0,"r":"?","dd":0},{"id":879,"w":507,"b":508,"h":0,"r":"?","dd":0},{"id":880,"w":531,"b":512,"h":0,"r":"?","dd":0},{"id":881,"w":510,"b":509,"h":0,"r":"?","dd":0},{"id":882,"w":505,"b":504,"h":0,"r":"?","dd":0},{"id":883,"w":526,"b":511,"h":0,"r":"?","dd":0},{"id":884,"w":525,"b":520,"h":0,"r":"?","dd":0},{"id":885,"w":516,"b":502,"h":0,"r":"?","dd":0},{"id":886,"w":524,"b":533,"h":0,"r":"?","dd":0},{"id":887,"w":522,"b":503,"h":0,"r":"?","dd":0},{"id":888,"w":527,"b":523,"h":0,"r":"?","dd":0},{"id":889,"w":513,"b":532,"h":0,"r":"?","dd":0},{"id":890,"w":521,"b":515,"h":0,"r":"?","dd":0}]""" val pairings_R4 = """[{"id":891,"w":506,"b":528,"h":0,"r":"?","dd":0},{"id":892,"w":517,"b":530,"h":0,"r":"?","dd":0},{"id":893,"w":518,"b":512,"h":0,"r":"?","dd":0},{"id":894,"w":511,"b":519,"h":0,"r":"?","dd":0},{"id":895,"w":508,"b":504,"h":0,"r":"?","dd":0},{"id":896,"w":533,"b":514,"h":0,"r":"?","dd":0},{"id":897,"w":529,"b":502,"h":0,"r":"?","dd":0},{"id":898,"w":520,"b":509,"h":0,"r":"?","dd":0},{"id":899,"w":531,"b":516,"h":0,"r":"?","dd":0},{"id":900,"w":507,"b":503,"h":0,"r":"?","dd":0},{"id":901,"w":510,"b":505,"h":0,"r":"?","dd":0},{"id":902,"w":523,"b":524,"h":0,"r":"?","dd":0},{"id":903,"w":532,"b":526,"h":0,"r":"?","dd":0},{"id":904,"w":515,"b":525,"h":0,"r":"?","dd":0},{"id":905,"w":522,"b":527,"h":0,"r":"?","dd":0},{"id":906,"w":513,"b":521,"h":0,"r":"?","dd":0}]""" val pairings_R5 = """[{"id":907,"w":528,"b":530,"h":0,"r":"?","dd":0},{"id":908,"w":512,"b":517,"h":0,"r":"?","dd":0},{"id":909,"w":504,"b":519,"h":0,"r":"?","dd":0},{"id":910,"w":514,"b":509,"h":0,"r":"?","dd":0},{"id":911,"w":506,"b":502,"h":0,"r":"?","dd":0},{"id":912,"w":516,"b":518,"h":0,"r":"?","dd":0},{"id":913,"w":511,"b":505,"h":0,"r":"?","dd":0},{"id":914,"w":520,"b":526,"h":0,"r":"?","dd":0},{"id":915,"w":525,"b":533,"h":0,"r":"?","dd":0},{"id":916,"w":524,"b":508,"h":0,"r":"?","dd":0},{"id":917,"w":503,"b":529,"h":0,"r":"?","dd":0},{"id":918,"w":531,"b":532,"h":0,"r":"?","dd":0},{"id":919,"w":527,"b":510,"h":0,"r":"?","dd":0},{"id":920,"w":523,"b":515,"h":0,"r":"?","dd":0},{"id":921,"w":507,"b":521,"h":0,"r":"?","dd":0},{"id":922,"w":513,"b":522,"h":0,"r":"?","dd":0}]""" + //logger.info(compare_string(pairings_R1, games_np.toString())) // val games = TestAPI.get("/api/tour/$id/res/1").asArray() //logger.info("Compare pairings for round 1") @@ -369,6 +375,8 @@ class BasicTests: TestBase() { logger.info("Pairings for round 3 match OpenGotha") + + } } \ No newline at end of file diff --git a/api-webapp/src/test/resources/opengotha/tournamentfiles/simpleswiss.xml b/api-webapp/src/test/resources/opengotha/tournamentfiles/simpleswiss_orderTableNumberScoreRating.xml similarity index 97% rename from api-webapp/src/test/resources/opengotha/tournamentfiles/simpleswiss.xml rename to api-webapp/src/test/resources/opengotha/tournamentfiles/simpleswiss_orderTableNumberScoreRating.xml index c9c12e4..3f533a1 100644 --- a/api-webapp/src/test/resources/opengotha/tournamentfiles/simpleswiss.xml +++ b/api-webapp/src/test/resources/opengotha/tournamentfiles/simpleswiss_orderTableNumberScoreRating.xml @@ -1,5 +1,5 @@ - + @@ -87,18 +87,18 @@ - - - - - - + + + + + + - - - - + + + + @@ -117,7 +117,7 @@ - +