From fb2ad11347d9a0531447d759ec9b9921a16f1d05 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Tue, 19 Sep 2017 17:45:10 -0700 Subject: [PATCH] Improve AddressDecoder optimization function This function is better 27% of the time but worse 6% of the time. --- src/main/scala/diplomacy/AddressDecoder.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/diplomacy/AddressDecoder.scala b/src/main/scala/diplomacy/AddressDecoder.scala index 1b2ed837..9000c7ab 100644 --- a/src/main/scala/diplomacy/AddressDecoder.scala +++ b/src/main/scala/diplomacy/AddressDecoder.scala @@ -70,10 +70,10 @@ object AddressDecoder def bitScore(partitions: Partitions): Seq[Int] = { val maxPortsPerPartition = partitions.map(_.size).max - val sumPortsPerPartition = partitions.map(_.size).sum val maxSetsPerPartition = partitions.map(_.map(_.size).sum).max - val sumSetsPerPartition = partitions.map(_.map(_.size).sum).sum - Seq(maxPortsPerPartition, sumPortsPerPartition, maxSetsPerPartition, sumSetsPerPartition) + val sumSquarePortsPerPartition = partitions.map(p => p.size * p.size).sum + val sumSquareSetsPerPartition = partitions.map(_.map(p => p.size * p.size).sum).max + Seq(maxPortsPerPartition, maxSetsPerPartition, sumSquarePortsPerPartition, sumSquareSetsPerPartition) } def partitionPort(port: Port, bit: BigInt): (Port, Port) = {