Skip to content

Commit

Permalink
deterministic heuristic for dist alg
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Mar 29, 2017
1 parent 889423b commit 1733eeb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/com/github/sybila/DistComponents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,21 @@ class DistAlgorithm(
var maxWeight: Double = 0.0
map.entries().forEach { (state, p) ->
val weight = p.weight()
if (weight > maxWeight) {
if (weight > maxWeight || (weight == maxWeight && state > max?.first ?: -1)) {
max = state to p
maxWeight = weight
}
}
max
}
}.fold<Future<Pair<Int, Params>?>, Pair<Int, Params>?>(null) { current, future ->
/*future.get()?.let { new ->
current?.assuming {
val max = it.second.weight()
val newMax = new.second.weight()
max > newMax || (max == newMax && it.first < new.first)
} ?: new
} ?: current*/
val new = future.get()
current?.assuming { it.second.weight() > new?.second?.weight() ?: 0.0 } ?: new
}!!
Expand Down

0 comments on commit 1733eeb

Please sign in to comment.