Write weights to file to compare with opengotha
This commit is contained in:
@@ -9,6 +9,7 @@ import org.jgrapht.alg.matching.blossom.v5.ObjectiveSense
|
|||||||
import org.jgrapht.graph.DefaultWeightedEdge
|
import org.jgrapht.graph.DefaultWeightedEdge
|
||||||
import org.jgrapht.graph.SimpleDirectedWeightedGraph
|
import org.jgrapht.graph.SimpleDirectedWeightedGraph
|
||||||
import org.jgrapht.graph.builder.GraphBuilder
|
import org.jgrapht.graph.builder.GraphBuilder
|
||||||
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@@ -114,6 +115,12 @@ sealed class Solver(
|
|||||||
// check that at this stage, we have an even number of pairables
|
// check that at this stage, we have an even number of pairables
|
||||||
if (pairables.size % 2 != 0) throw Error("expecting an even number of pairables")
|
if (pairables.size % 2 != 0) throw Error("expecting an even number of pairables")
|
||||||
val builder = GraphBuilder(SimpleDirectedWeightedGraph<Pairable, DefaultWeightedEdge>(DefaultWeightedEdge::class.java))
|
val builder = GraphBuilder(SimpleDirectedWeightedGraph<Pairable, DefaultWeightedEdge>(DefaultWeightedEdge::class.java))
|
||||||
|
var WEIGHTS_FILE = "src/test/resources/weights.txt"
|
||||||
|
if (DEBUG_EXPORT_WEIGHT){
|
||||||
|
if (round==1) File(WEIGHTS_FILE).writeText("Round 1\n")
|
||||||
|
else File(WEIGHTS_FILE).appendText("Round "+round.toString()+"\n")
|
||||||
|
File(WEIGHTS_FILE).appendText("Costs\n")
|
||||||
|
}
|
||||||
for (i in sortedPairables.indices) {
|
for (i in sortedPairables.indices) {
|
||||||
for (j in i + 1 until pairables.size) {
|
for (j in i + 1 until pairables.size) {
|
||||||
val p = pairables[i]
|
val p = pairables[i]
|
||||||
@@ -122,13 +129,18 @@ sealed class Solver(
|
|||||||
weight(q, p).let { if (it != Double.NaN) builder.addEdge(q, p, it) }
|
weight(q, p).let { if (it != Double.NaN) builder.addEdge(q, p, it) }
|
||||||
if (DEBUG_EXPORT_WEIGHT)
|
if (DEBUG_EXPORT_WEIGHT)
|
||||||
{
|
{
|
||||||
println("Player1Name="+p.nameSeed())
|
File(WEIGHTS_FILE).appendText("Player1Name="+p.nameSeed()+"\n")
|
||||||
println("Player2Name="+q.nameSeed())
|
File(WEIGHTS_FILE).appendText("Player2Name="+q.nameSeed()+"\n")
|
||||||
println("BaseCost="+pairing.base.apply(p, q).toString())
|
File(WEIGHTS_FILE).appendText("baseDuplicateGameCost="+pairing.base.avoidDuplicatingGames(p, q).toString()+"\n")
|
||||||
println("MainCost="+pairing.main.apply(p, q).toString())
|
File(WEIGHTS_FILE).appendText("baseRandomCost="+pairing.base.applyRandom(p, q).toString()+"\n")
|
||||||
println("SecoCost="+pairing.secondary.apply(p, q).toString())
|
File(WEIGHTS_FILE).appendText("baseBWBalanceCost="+pairing.base.applyColorBalance(p, q).toString()+"\n")
|
||||||
println("Geo_Cost="+pairing.geo.apply(p, q).toString())
|
File(WEIGHTS_FILE).appendText("mainCategoryCost="+pairing.main.avoidMixingCategory(p, q).toString()+"\n")
|
||||||
println("Sum_Cost="+weight(p,q).toString())
|
File(WEIGHTS_FILE).appendText("mainScoreDiffCost="+pairing.main.minimizeScoreDifference(p, q).toString()+"\n")
|
||||||
|
File(WEIGHTS_FILE).appendText("mainDUDDCost="+pairing.main.applyDUDD(p, q).toString()+"\n")
|
||||||
|
File(WEIGHTS_FILE).appendText("mainSeedCost="+pairing.main.applySeeding(p, q).toString()+"\n")
|
||||||
|
File(WEIGHTS_FILE).appendText("secHandiCost="+pairing.handicap.handicap(p, q).toString()+"\n")
|
||||||
|
File(WEIGHTS_FILE).appendText("secGeoCost="+pairing.geo.apply(p, q).toString()+"\n")
|
||||||
|
File(WEIGHTS_FILE).appendText("totalCost="+weight(p,q).toString()+"\n")
|
||||||
//println(weight(q,p))
|
//println(weight(q,p))
|
||||||
logWeights("total", p, q, weight(p,q))
|
logWeights("total", p, q, weight(p,q))
|
||||||
//weightsToFile(p, q)
|
//weightsToFile(p, q)
|
||||||
@@ -209,13 +221,13 @@ sealed class Solver(
|
|||||||
var score = 0.0
|
var score = 0.0
|
||||||
|
|
||||||
// Main criterion 1 avoid mixing category is moved to Swiss with category
|
// Main criterion 1 avoid mixing category is moved to Swiss with category
|
||||||
// TODO
|
score += avoidMixingCategory(p1, p2)
|
||||||
|
|
||||||
// Main criterion 2 minimize score difference
|
// Main criterion 2 minimize score difference
|
||||||
score += minimizeScoreDifference(p1, p2)
|
score += minimizeScoreDifference(p1, p2)
|
||||||
|
|
||||||
// Main criterion 3 If different groups, make a directed Draw-up/Draw-down
|
// Main criterion 3 If different groups, make a directed Draw-up/Draw-down
|
||||||
// TODO
|
score += applyDUDD(p1, p2)
|
||||||
|
|
||||||
// Main criterion 4 seeding
|
// Main criterion 4 seeding
|
||||||
score += applySeeding(p1, p2)
|
score += applySeeding(p1, p2)
|
||||||
@@ -223,6 +235,14 @@ sealed class Solver(
|
|||||||
return score
|
return score
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun MainCritParams.avoidMixingCategory(p1: Pairable, p2: Pairable): Double {
|
||||||
|
var score = 0.0
|
||||||
|
|
||||||
|
// TODO check category equality if category are used in SwissCat
|
||||||
|
|
||||||
|
return score
|
||||||
|
}
|
||||||
|
|
||||||
open fun MainCritParams.minimizeScoreDifference(p1: Pairable, p2: Pairable): Double {
|
open fun MainCritParams.minimizeScoreDifference(p1: Pairable, p2: Pairable): Double {
|
||||||
var score = 0.0
|
var score = 0.0
|
||||||
val scoreRange: Int = groupsCount
|
val scoreRange: Int = groupsCount
|
||||||
@@ -237,6 +257,14 @@ sealed class Solver(
|
|||||||
return score
|
return score
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun MainCritParams.applyDUDD(p1: Pairable, p2: Pairable): Double {
|
||||||
|
var score = 0.0
|
||||||
|
|
||||||
|
// TODO apply Drawn-Up/Drawn-Down if needed
|
||||||
|
|
||||||
|
return score
|
||||||
|
}
|
||||||
|
|
||||||
fun MainCritParams.applySeeding(p1: Pairable, p2: Pairable): Double {
|
fun MainCritParams.applySeeding(p1: Pairable, p2: Pairable): Double {
|
||||||
var score = 0.0
|
var score = 0.0
|
||||||
// Apply seeding for players in the same group
|
// Apply seeding for players in the same group
|
||||||
|
5954
api-webapp/src/test/resources/weights.txt
Normal file
5954
api-webapp/src/test/resources/weights.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user