Completed given algorithm
This commit is contained in:
parent
7d045e79b6
commit
365c028fbc
13
src/main/resources/logback.xml
Normal file
13
src/main/resources/logback.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- encoders are assigned the type
|
||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
||||
<encoder>
|
||||
<pattern>%msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="trace">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
@ -76,59 +76,71 @@ object Main {
|
||||
customers = customers
|
||||
)
|
||||
|
||||
val x = hhc.go()
|
||||
// val x = hhc.go()
|
||||
|
||||
x match {
|
||||
case Left(value) => println(value)
|
||||
case Right(value) =>
|
||||
}
|
||||
val x2 = hhc.go()
|
||||
|
||||
x.foreach(d => {
|
||||
val (a, b, c, g) = d
|
||||
println(c)
|
||||
// x match {
|
||||
// case Left(value) => println(value)
|
||||
// case Right(value) =>
|
||||
// }
|
||||
|
||||
println
|
||||
// x.foreach(d => {
|
||||
// val (a, b, c, g, groups) = d
|
||||
// // println(c)
|
||||
|
||||
for (i <- 0 until b.length) {
|
||||
if (!b(i).isEmpty) {
|
||||
print(s"$i ")
|
||||
print(b(i))
|
||||
// edgeMappings
|
||||
// b(i).foreach(e => {
|
||||
// print(f"(${e.toNode}%d, ${e.weight}%.2f), ")
|
||||
// })
|
||||
println
|
||||
}
|
||||
}
|
||||
println
|
||||
// // println
|
||||
|
||||
for (i <- 0 until g.length) {
|
||||
if (!g(i)._2.isEmpty) {
|
||||
print(s"$i ")
|
||||
print(g(i))
|
||||
// edgeMappings
|
||||
// b(i).foreach(e => {
|
||||
// print(f"(${e.toNode}%d, ${e.weight}%.2f), ")
|
||||
// })
|
||||
println
|
||||
}
|
||||
}
|
||||
println
|
||||
// // println(b)
|
||||
// // for (i <- 0 until b.length) {
|
||||
// // if (!b(i).isEmpty) {
|
||||
// // print(s"$i ")
|
||||
// // print(b(i))
|
||||
// // // edgeMappings
|
||||
// // // b(i).foreach(e => {
|
||||
// // // print(f"(${e.toNode}%d, ${e.weight}%.2f), ")
|
||||
// // // })
|
||||
// // println
|
||||
// // }
|
||||
// // }
|
||||
// // println
|
||||
|
||||
var i = 0
|
||||
a.foreach(e => {
|
||||
if (!e.isEmpty) {
|
||||
print(s"Cluster-$i: ")
|
||||
i += 1
|
||||
e.foreach(f => { print(s"$f ") })
|
||||
println
|
||||
}
|
||||
})
|
||||
// // for (i <- 0 until g.length) {
|
||||
// // if (!g(i)._2.isEmpty) {
|
||||
// // print(s"$i ")
|
||||
// // print(g(i))
|
||||
// // // edgeMappings
|
||||
// // // b(i).foreach(e => {
|
||||
// // // print(f"(${e.toNode}%d, ${e.weight}%.2f), ")
|
||||
// // // })
|
||||
// // println
|
||||
// // }
|
||||
// // }
|
||||
// println
|
||||
|
||||
})
|
||||
// // var i = 0
|
||||
// // b.foreach(e => {
|
||||
// // // if (!e.isEmpty) {
|
||||
// // print(s"Cluster-$i: ")
|
||||
// // i += 1
|
||||
// // e.foreach(f => { print(s"$f ") })
|
||||
// // println
|
||||
// // // }
|
||||
// // })
|
||||
|
||||
val x2 = hhc.go2()
|
||||
x2.map(_.map(println))
|
||||
// // i = 0
|
||||
// // groups.foreach(e => {
|
||||
// // // if (!e.isEmpty) {
|
||||
// // print(s"Cluster-$i: ")
|
||||
// // i += 1
|
||||
// // e.foreach(f => { print(f"(${f._1}%d, ${f._2}%.2f), ") })
|
||||
// // println
|
||||
// // // }
|
||||
// // })
|
||||
|
||||
// })
|
||||
|
||||
// x2.map(_.map(println))
|
||||
|
||||
// x.map(e => {
|
||||
// val (mst, rm) = e
|
||||
|
@ -10,72 +10,234 @@ import model.Customer
|
||||
import scala.io.BufferedSource
|
||||
import model.Coord
|
||||
import scala.util.Random
|
||||
import com.typesafe.scalalogging.LazyLogging
|
||||
import cats.implicits
|
||||
import scala.util.chaining._
|
||||
|
||||
class HHCSim2(
|
||||
private val epsilonMax: Int = 0,
|
||||
private val iterations: Int = 0,
|
||||
private val WLDMax: Float = 0,
|
||||
private val customers: String Either ArraySeq[Customer]
|
||||
) {
|
||||
) extends LazyLogging {
|
||||
import HHCSim2._
|
||||
import Ordering.Double.IeeeOrdering
|
||||
|
||||
private var adjMatrix: Option[GraphMatrix[Double]] = None
|
||||
def go() = {
|
||||
customers
|
||||
.flatMap(checkEmpty)
|
||||
.map(formAdjMatrix)
|
||||
.tap(logGraph)
|
||||
.tap(_.foreach(e => adjMatrix = Some(e)))
|
||||
.map(e => mstUsingPrims(e))
|
||||
.tap(logMST)
|
||||
.map { case (mst, epsilon) => removeEdges(mst)(epsilon) }
|
||||
.tap(logMST2)
|
||||
.map { case (mstUpdated, removed) => findClusters(mstUpdated)(removed) }
|
||||
.map {
|
||||
case (clusters, edgeMappings, removedEdges) =>
|
||||
groupClusters(clusters, edgeMappings, removedEdges)
|
||||
case (mstUpdated, clusters, edgeMappings, removedEdges) =>
|
||||
printClusters(clusters)
|
||||
val e =
|
||||
groupClusters2(mstUpdated, clusters, edgeMappings, removedEdges)
|
||||
printGroups(e._5)
|
||||
e
|
||||
}
|
||||
.flatMap(value => {
|
||||
val (mst, clusters, edgeMappings, removed, clusterGroups) = value
|
||||
balanceWorkload(clusters, clusterGroups)
|
||||
})
|
||||
}
|
||||
def go2() = {
|
||||
val res = go().flatMap(value => {
|
||||
val (clusters, edgeMappings, removed, clusterGroups) = value
|
||||
workloadBalance(clusters, edgeMappings, removed, clusterGroups)
|
||||
})
|
||||
res
|
||||
// def go2() = {
|
||||
// val res = go().flatMap(value => {
|
||||
// val (mst, clusters, edgeMappings, removed, clusterGroups) = value
|
||||
// balanceWorkload(mst, clusters, clusterGroups)
|
||||
// })
|
||||
// res
|
||||
// }
|
||||
|
||||
def printGraph(graph: GraphMatrix[Double]) = graph.foreach { e =>
|
||||
e.foreach { d =>
|
||||
print(f"$d%.2f, ")
|
||||
}
|
||||
println
|
||||
}
|
||||
|
||||
def workloadBalance[N: Numeric](
|
||||
clusters: Clusters,
|
||||
edgeMappings: ArraySeq[List[HHCEdge2[N]]],
|
||||
removedEdges: RemovedEdges[N],
|
||||
groups: ArraySeq[(Int, List[(Int, N)])]
|
||||
) = {
|
||||
customers.map { c =>
|
||||
val k = clusters.size
|
||||
val mutClusters = clusters.toArray
|
||||
val worlkLoads =
|
||||
mutClusters.map(_.map(j => c(j)).foldLeft(0f)((x, y) => x + y.workload))
|
||||
val sortedClusters =
|
||||
mutClusters.map(_.sortWith((x, y) => c(x).workload < c(y).workload))
|
||||
val minWL =
|
||||
c.foldLeft(c(0).workload)(_ min _.workload)
|
||||
val maxWL =
|
||||
c.foldLeft(0f)(_ max _.workload)
|
||||
val WLD = maxWL - minWL
|
||||
if (WLD > WLDMax) {
|
||||
var t = Random.between(((k / 2) + 1), k)
|
||||
while (!mutClusters(t).isEmpty) t = Random.between(((k / 2) + 1), k)
|
||||
val Ds = groups(t)._2(0)
|
||||
mutClusters.updated(Ds._1, t)
|
||||
}
|
||||
for (_ <- 0 until iterations) {
|
||||
// val workloads = clusters.flatMap(_.map(j => c(j)))
|
||||
|
||||
def printGraph(graph: Graph[Double]) = {
|
||||
for (i <- 0 until graph.size) {
|
||||
print(s"$i: ")
|
||||
for (edge <- graph(i)) {
|
||||
print(f"(${edge.toNode}, ${edge.weight}%.2f), ")
|
||||
}
|
||||
println
|
||||
}
|
||||
}
|
||||
|
||||
def checkAveragePairwiseDistance[T](
|
||||
lst: List[(Int, T)]
|
||||
)(implicit num: Numeric[T]) = {
|
||||
val sum = lst.foldLeft(0)((x, y) => x + num.toInt(y._2))
|
||||
val avg = sum / lst.length
|
||||
if (avg < epsilonMax) true else false
|
||||
def logGraph(maybeGraph: Either[String, GraphMatrix[Double]]): Unit =
|
||||
maybeGraph.foreach(
|
||||
graph => {
|
||||
logger.whenDebugEnabled {
|
||||
logger.debug("Graph: ")
|
||||
printGraph(graph)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def logMST(maybeMST: Either[String, (Graph[Double], Double)]): Unit =
|
||||
maybeMST.foreach(
|
||||
t => {
|
||||
logger.whenDebugEnabled {
|
||||
logger.debug(s"Epsilon = ${t._2}")
|
||||
logger.debug("MST: ")
|
||||
printGraph(graph = t._1)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def logMST2(it: Either[String, (Graph[Double], RemovedEdges[Double])]): Unit =
|
||||
it.foreach(
|
||||
t => {
|
||||
logger.whenDebugEnabled {
|
||||
logger.debug(s"Removed Edges = ${t._2}")
|
||||
logger.debug("MST: ")
|
||||
printGraph(graph = t._1)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def printClusters(clusters: Clusters) = {
|
||||
logger.whenDebugEnabled {
|
||||
logger.debug("Clusters:")
|
||||
var i = 0
|
||||
clusters.foreach(e => {
|
||||
print(s"Cluster-$i: ")
|
||||
i += 1
|
||||
e.foreach(f => print(s"$f "))
|
||||
println
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
def printClusters(clusters: Array[List[Int]]) = {
|
||||
logger.whenDebugEnabled {
|
||||
logger.debug("Clusters:")
|
||||
var i = 0
|
||||
clusters.foreach(e => {
|
||||
print(s"Cluster-$i: ")
|
||||
i += 1
|
||||
e.foreach(f => print(s"$f "))
|
||||
println
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
def printGroups(groups: ArraySeq[List[(Int, Double)]]) = {
|
||||
logger.whenDebugEnabled {
|
||||
logger.debug("Neighbours: ")
|
||||
var i = 0
|
||||
groups.foreach(e => {
|
||||
print(s"Cluster-$i: ")
|
||||
i += 1
|
||||
e.foreach(f => { print(f"(${f._1}%d, ${f._2}%.2f), ") })
|
||||
println
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
def balanceWorkload[N: Numeric](
|
||||
clusters: Clusters,
|
||||
groups: ArraySeq[List[(Int, N)]]
|
||||
) = {
|
||||
customers.map(c => {
|
||||
val mutClusters =
|
||||
clusters.toArray
|
||||
val clusterOrder = (0 until clusters.length).toArray
|
||||
logger.debug(s"Initial order: $clusterOrder")
|
||||
val k = mutClusters.size
|
||||
for (_ <- 0 until iterations) {
|
||||
val WL = mutClusters.view
|
||||
.map(nodes => {
|
||||
val customers = nodes.map(node => c(node))
|
||||
val wl = customers.foldLeft(0f)(_ + _.workload)
|
||||
wl
|
||||
})
|
||||
.to(ArraySeq)
|
||||
logger.debug(s"$WL")
|
||||
clusterOrder.sortInPlaceWith((x, y) => WL(x) < WL(y))
|
||||
logger.debug(s"Current order $clusterOrder")
|
||||
val (minWL, maxWL) = WL.foldLeft((99999f, 0f))((acc, wl) => {
|
||||
val (currMin, currMax) = acc
|
||||
if (wl < currMin) (wl, currMax)
|
||||
else if (wl > currMax) (currMin, wl)
|
||||
else acc
|
||||
})
|
||||
val WLD = maxWL - minWL
|
||||
|
||||
logger.debug(s"maxWL = $maxWL, minWL = $minWL")
|
||||
logger.debug(s"WLD = $WLD")
|
||||
if (WLD > WLDMax) {
|
||||
val randNum = Random.between(((k / 2) + 1), k)
|
||||
logger.debug(s"Rand Num=$randNum")
|
||||
val effectiveNum = clusterOrder(randNum)
|
||||
logger.debug(s"Chosen cluster = $effectiveNum")
|
||||
val (s, _) = groups(effectiveNum)(0)
|
||||
logger.debug(s"Nearest neighbour = $s")
|
||||
// val avg = averagePairwiseDistance(mst(s))
|
||||
val avg = adjMatrix
|
||||
.map(m => averagePairwiseDistance(m)(clusters(s)))
|
||||
.getOrElse(9999d)
|
||||
// if (avg < epsilonMax) true else false
|
||||
|
||||
logger.debug(s"Pairwise average = $avg")
|
||||
|
||||
if (avg < epsilonMax) {
|
||||
logger.debug("Average less than epsilonMax. Updating Clusters.")
|
||||
if (!mutClusters(s).contains(effectiveNum)) {
|
||||
mutClusters(s) = effectiveNum :: mutClusters(s)
|
||||
}
|
||||
// mutClusters.foreach(println)
|
||||
printClusters(mutClusters)
|
||||
}
|
||||
}
|
||||
}
|
||||
ArraySeq.unsafeWrapArray(mutClusters)
|
||||
})
|
||||
}
|
||||
|
||||
// def averagePairwiseDistance[T](
|
||||
// lst: List[HHCEdge2[T]]
|
||||
// )(implicit num: Numeric[T]) = {
|
||||
// val it = lst.combinations(2)
|
||||
// val sum = lst.foldLeft(0)((x, y) => x + num.toInt(y.weight))
|
||||
// val n = if (lst.length == 0) 1 else lst.length
|
||||
// val avg = sum / n
|
||||
|
||||
// // it.map()
|
||||
// avg
|
||||
// }
|
||||
|
||||
def averagePairwiseDistance(graph: GraphMatrix[Double])(
|
||||
cluster: List[Int]
|
||||
) = {
|
||||
// val iter = cluster.combinations(2)
|
||||
// var sum = 0d
|
||||
// for (pair <- iter) {
|
||||
// val (i, j) = pair(0) -> pair(1)
|
||||
// sum += graph(i)(j)
|
||||
// }
|
||||
// val n = if (iter.length == 0) 1 else iter.length
|
||||
val (sum, size) = cluster
|
||||
.combinations(2)
|
||||
.foldLeft((0d, 0))((acc, pair) => {
|
||||
val (sum, size) = acc
|
||||
val (i, j) = pair(0) -> pair(1)
|
||||
logger.trace(s"$i $j - ")
|
||||
logger.trace(s"weight = ${graph(i)(j)}")
|
||||
(sum + graph(i)(j), size + 1)
|
||||
})
|
||||
|
||||
val n = if (size == 0) 1 else size
|
||||
sum / n
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,19 +266,29 @@ object HHCSim2 extends HHCTypes {
|
||||
arr match {
|
||||
case Array(latitude, longitude, workLoad) => {
|
||||
val cust =
|
||||
Customer(
|
||||
Coord(latitude.toDouble, longitude.toDouble),
|
||||
workLoad.toFloat
|
||||
)
|
||||
loop(lst += cust, iter)
|
||||
// Customer(
|
||||
// Coord(latitude.toDouble, longitude.toDouble),
|
||||
// workLoad.toFloat
|
||||
// )
|
||||
for {
|
||||
lat <- latitude.toDoubleOption
|
||||
lon <- longitude.toDoubleOption
|
||||
coord = Coord(lat, lon)
|
||||
wl <- workLoad.toFloatOption
|
||||
} yield (Customer(coord, wl))
|
||||
cust match {
|
||||
case Some(c) => loop(lst += c, iter)
|
||||
case None => Left(s"Error reading customers at line - $line")
|
||||
}
|
||||
// loop(lst += cust, iter)
|
||||
}
|
||||
case _ => {
|
||||
if (arr.mkString.equals(" ") || arr.mkString.contains("\n"))
|
||||
if (line.equals(" ") || line.contains("\n"))
|
||||
Left("Error newline")
|
||||
else {
|
||||
Left(
|
||||
"Error reading customers from" +
|
||||
s" file - ${arr.mkString(", ")}"
|
||||
s" file at line - $line}"
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -188,7 +360,6 @@ object HHCSim2 extends HHCTypes {
|
||||
min = num.toInt(edges(i)(j))
|
||||
x = i
|
||||
y = j
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -200,11 +371,11 @@ object HHCSim2 extends HHCTypes {
|
||||
selected(y) = true
|
||||
}
|
||||
val adjList2 = adjList.map(l => {
|
||||
count += 1
|
||||
count += l.size
|
||||
l.toList
|
||||
})
|
||||
adjList2.foreach(println)
|
||||
(ArraySeq.unsafeWrapArray(adjList2), num.fromInt(sum / count))
|
||||
// adjList2.foreach(println)
|
||||
(ArraySeq.unsafeWrapArray(adjList2), num.fromInt(sum / (count / 2)))
|
||||
}
|
||||
|
||||
def removeEdges[N: Ordering](
|
||||
@ -226,8 +397,8 @@ object HHCSim2 extends HHCTypes {
|
||||
filtered
|
||||
}
|
||||
println
|
||||
result.foreach(println)
|
||||
println
|
||||
// result.foreach(println)
|
||||
// println
|
||||
(result, removed.toList)
|
||||
}
|
||||
|
||||
@ -259,11 +430,12 @@ object HHCSim2 extends HHCTypes {
|
||||
|
||||
def findClusters[T: Numeric](mstUpdated: Graph[T])(
|
||||
removedEdges: RemovedEdges[T]
|
||||
): (Clusters, ArraySeq[List[HHCEdge2[T]]], RemovedEdges[T]) = {
|
||||
): (Graph[T], Clusters, ArraySeq[List[HHCEdge2[T]]], RemovedEdges[T]) = {
|
||||
val visited = Array.fill[Boolean](mstUpdated.length)(false)
|
||||
var removedEdges2 = removedEdges
|
||||
val egdeMappings =
|
||||
Array.fill(mstUpdated.length)(List.empty[HHCEdge2[T]])
|
||||
val nodeToClusterMappings = Array.fill(mstUpdated.length)(0)
|
||||
val result = ArraySeq.tabulate(mstUpdated.length) { i =>
|
||||
{
|
||||
val buf = ListBuffer[Int]()
|
||||
@ -304,8 +476,13 @@ object HHCSim2 extends HHCTypes {
|
||||
// println(s"Removed edges size: ${removedEdges2.size}")
|
||||
|
||||
// result
|
||||
(result, ArraySeq.unsafeWrapArray(egdeMappings), removedEdges)
|
||||
// (result.filterNot(_.isEmpty), ArraySeq.unsafeWrapArray(egdeMappings), removedEdges)
|
||||
// (result, ArraySeq.unsafeWrapArray(egdeMappings), removedEdges)
|
||||
(
|
||||
mstUpdated,
|
||||
result.filterNot(_.isEmpty),
|
||||
ArraySeq.unsafeWrapArray(egdeMappings.filterNot(_.isEmpty)),
|
||||
removedEdges
|
||||
)
|
||||
}
|
||||
|
||||
def assignEdges[T: Ordering](
|
||||
@ -313,6 +490,7 @@ object HHCSim2 extends HHCTypes {
|
||||
removedEdges: RemovedEdges[T]
|
||||
) = {
|
||||
val it = nodes.iterator
|
||||
@annotation.tailrec
|
||||
def loop(
|
||||
nodes: List[Int],
|
||||
removedEdges: RemovedEdges[T],
|
||||
@ -353,13 +531,25 @@ object HHCSim2 extends HHCTypes {
|
||||
(edges, removedEdgesUpdated)
|
||||
}
|
||||
|
||||
def mapNodestoClusters[N: Ordering](mst: Graph[N], clusters: Clusters) = {
|
||||
val arr = Array.fill(mst.size)(0)
|
||||
for (i <- 0 until clusters.size) {
|
||||
val nodes = clusters(i)
|
||||
for (node <- nodes) {
|
||||
arr(node) = i
|
||||
}
|
||||
}
|
||||
ArraySeq.unsafeWrapArray(arr)
|
||||
}
|
||||
|
||||
def groupClusters[N: Ordering](
|
||||
clusters: Clusters,
|
||||
edgeMappings: ArraySeq[List[HHCEdge2[N]]],
|
||||
removed: RemovedEdges[N]
|
||||
) = {
|
||||
var k = -1
|
||||
val x = ArraySeq.tabulate(edgeMappings.size)(i => {
|
||||
val clustMap = collection.mutable.Map.empty[Int, Int]
|
||||
val groups = ArraySeq.tabulate(edgeMappings.size)(i => {
|
||||
val buf = ListBuffer.empty[(Int, N)]
|
||||
val lst = edgeMappings(i)
|
||||
val y = lst.foreach(e => {
|
||||
@ -368,7 +558,7 @@ object HHCSim2 extends HHCTypes {
|
||||
for (j <- 0 until clusters.size) {
|
||||
for (edge <- clusters(j)) {
|
||||
if (edge == e.toNode)
|
||||
buf += ((j, e.weight))
|
||||
buf += (j -> e.weight)
|
||||
}
|
||||
}
|
||||
// Left(buf.toList)
|
||||
@ -379,17 +569,185 @@ object HHCSim2 extends HHCTypes {
|
||||
// case HHCEdge2(fromNode, toNode, weight) => (toNode, weight)
|
||||
// })
|
||||
})
|
||||
if (!clusters(i).isEmpty) k += 1
|
||||
if (!clusters(i).isEmpty) {
|
||||
k += 1
|
||||
clustMap += k -> i
|
||||
}
|
||||
// val lst2 = lst.map {
|
||||
// case HHCEdge2(fromNode, toNode, weight) => (toNode, weight)
|
||||
// }
|
||||
// if (buf.isEmpty) lst2 else buf.toList ::: lst2
|
||||
// if (lt.isEmpty) rt else lt
|
||||
(k, buf.toList.sortWith {
|
||||
(k, buf.sortWith {
|
||||
case ((_, weight1), (_, weight2)) =>
|
||||
weight1 < weight2
|
||||
})
|
||||
}.toList)
|
||||
})
|
||||
(clusters, edgeMappings, removed, x)
|
||||
(clusters, clustMap.toMap, removed, groups)
|
||||
}
|
||||
|
||||
def groupClusters2[N: Ordering](
|
||||
mst: Graph[N],
|
||||
clusters: Clusters,
|
||||
edgeMappings: ArraySeq[List[HHCEdge2[N]]],
|
||||
removed: RemovedEdges[N]
|
||||
) = {
|
||||
val nodeMap = mapNodestoClusters(mst, clusters)
|
||||
val groups = ArraySeq.tabulate(edgeMappings.size)(i => {
|
||||
val buf = ListBuffer.empty[(Int, N)]
|
||||
val lst = edgeMappings(i)
|
||||
lst.foreach(e => {
|
||||
buf += nodeMap(e.toNode) -> e.weight
|
||||
})
|
||||
buf.sortWith {
|
||||
case ((_, weight1), (_, weight2)) =>
|
||||
weight1 < weight2
|
||||
}.toList
|
||||
})
|
||||
(mst, clusters, edgeMappings, removed, groups)
|
||||
}
|
||||
}
|
||||
// def fun2[N: Numeric](
|
||||
// clusters: Clusters,
|
||||
// clustMap: Map[Int, Int],
|
||||
// removedEdges: RemovedEdges[N],
|
||||
// groups: ArraySeq[(Int, List[(Int, N)])]
|
||||
// ) = {
|
||||
// customers.map(c => {
|
||||
// val mutClusters =
|
||||
// clusters.view.filterNot(_.isEmpty).zipWithIndex.toArray
|
||||
// val k = mutClusters.size
|
||||
// // val k = clustMap.size
|
||||
// for (_ <- 0 until iterations) {
|
||||
// val WL = mutClusters.view
|
||||
// // .filter(!_._1.isEmpty)
|
||||
// .map(e => {
|
||||
// val (clust, _) = e
|
||||
// val customers = clust.map(j => c(j))
|
||||
// val wl = customers.foldLeft(0f)(_ + _.workload)
|
||||
// wl
|
||||
// })
|
||||
// .to(ArraySeq)
|
||||
// // logger.debug(s"$mutClusters")
|
||||
// logger.debug(s"$WL")
|
||||
// var counter = 0
|
||||
// mutClusters.sortInPlaceWith((x, y) => {
|
||||
// val l = WL(counter)
|
||||
// if (counter < mutClusters.length - 1) counter += 1
|
||||
// println(s"$counter")
|
||||
// val r = WL(counter)
|
||||
// l < r
|
||||
// // WL(x._2) < WL(y._2)
|
||||
// })
|
||||
// val (minWL, maxWL) = WL.foldLeft((99999f, 0f))((x, y) => {
|
||||
// val (currMin, currMax) = x
|
||||
// if (y < currMin) (y, currMax)
|
||||
// else if (y > currMax) (currMin, y)
|
||||
// else x
|
||||
// })
|
||||
// // val mutSortedClust = mutClusters.sort
|
||||
// val WLD = maxWL - minWL
|
||||
// // logger.debug(s"Iterations = $iterations")
|
||||
|
||||
// logger.debug(s"maxWL = $maxWL, minWL = $minWL")
|
||||
// logger.debug(s"WLD = $WLD")
|
||||
// if (WLD > WLDMax) {
|
||||
// val clustNum = Random.between(((k / 2) + 1), k)
|
||||
// // while (clusters(groupNum).isEmpty) {
|
||||
// // print(s"num = $groupNum")
|
||||
// // groupNum = Random.between(((k / 2) + 1), k)
|
||||
// // }
|
||||
// // val clustT = mutClusters(groupNum)
|
||||
// logger.debug(s"Chosen Num=$clustNum")
|
||||
// // val t = groups(groupNum)._1
|
||||
// val p = mutClusters(clustNum)._2
|
||||
// logger.debug(s"Clust num =$p")
|
||||
// val t = clustMap(p)
|
||||
// // val t = mutClusters(clustNum)._2
|
||||
// logger.debug(s"T=$t")
|
||||
// val s = groups(t)._2(0)
|
||||
// logger.debug(s"Nearest neighbour = ${s._1}")
|
||||
// }
|
||||
// }
|
||||
// ArraySeq.unsafeWrapArray(mutClusters)
|
||||
// })
|
||||
// }
|
||||
// def workloadBalance[N: Numeric](
|
||||
// clusters: Clusters,
|
||||
// edgeMappings: ArraySeq[List[HHCEdge2[N]]],
|
||||
// removedEdges: RemovedEdges[N],
|
||||
// groups: ArraySeq[(Int, List[(Int, N)])]
|
||||
// ) =
|
||||
// customers.map { c =>
|
||||
// val k = clusters.size
|
||||
// val mutClusters = clusters.toArray
|
||||
// for (_ <- 0 until iterations) {
|
||||
// val worlkLoads =
|
||||
// mutClusters.map(
|
||||
// _.map(j => c(j)).foldLeft(0f)((x, y) => x + y.workload)
|
||||
// )
|
||||
// val sortedClusters =
|
||||
// mutClusters.map(_.sortWith((x, y) => c(x).workload < c(y).workload))
|
||||
// val minWL =
|
||||
// c.foldLeft(c(0).workload)(_ min _.workload)
|
||||
// val maxWL =
|
||||
// c.foldLeft(0f)(_ max _.workload)
|
||||
// val WLD = maxWL - minWL
|
||||
// if (WLD > WLDMax) {
|
||||
// var t = Random.between(((k / 2) + 1), k)
|
||||
// while (!mutClusters(t).isEmpty) t = Random.between(((k / 2) + 1), k)
|
||||
// val Ds = groups(t)._2(0)
|
||||
// mutClusters.updated(Ds._1, t)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// def fun[N: Numeric](
|
||||
// clusters: Clusters,
|
||||
// clustMap: Map[Int, Int],
|
||||
// removedEdges: RemovedEdges[N],
|
||||
// groups: ArraySeq[(Int, List[(Int, N)])]
|
||||
// ) = {
|
||||
// customers.map(c => {
|
||||
// val mutClusters = clusters.toArray
|
||||
// // val k = mutClusters.size
|
||||
// val k = clustMap.size
|
||||
// for (_ <- 0 until iterations) {
|
||||
// val WL = mutClusters.view
|
||||
// .filter(!_.isEmpty)
|
||||
// .map(clust => {
|
||||
// val customers = clust.map(j => c(j))
|
||||
// val wl = customers.foldLeft(0f)(_ + _.workload)
|
||||
// wl
|
||||
// })
|
||||
// .to(ArraySeq)
|
||||
// val (minWL, maxWL) = WL.foldLeft((99999f, 0f))((x, y) => {
|
||||
// val (currMin, currMax) = x
|
||||
// if (y < currMin) (y, currMax)
|
||||
// else if (y > currMax) (currMin, y)
|
||||
// else x
|
||||
// })
|
||||
// // val mutSortedClust = mutClusters.sort
|
||||
// val WLD = maxWL - minWL
|
||||
// // logger.debug(s"Iterations = $iterations")
|
||||
// logger.debug(s"$WL")
|
||||
// logger.debug(s"maxWL = $maxWL, minWL = $minWL")
|
||||
// logger.debug(s"WLD = $WLD")
|
||||
// if (WLD > WLDMax) {
|
||||
// var clustNum = Random.between(((k / 2) + 1), k)
|
||||
// // while (clusters(groupNum).isEmpty) {
|
||||
// // print(s"num = $groupNum")
|
||||
// // groupNum = Random.between(((k / 2) + 1), k)
|
||||
// // }
|
||||
// // val clustT = mutClusters(groupNum)
|
||||
// logger.debug(s"Clust Num=$clustNum")
|
||||
// // val t = groups(groupNum)._1
|
||||
// val t = clustMap(clustNum)
|
||||
// logger.debug(s"T=$t")
|
||||
// val s = groups(t)._2(0)
|
||||
// logger.debug(s"Nearest neighbour = ${s._1}")
|
||||
// }
|
||||
// }
|
||||
// ArraySeq.unsafeWrapArray(mutClusters)
|
||||
// })
|
||||
// }
|
||||
|
300
test-output2.txt
Normal file
300
test-output2.txt
Normal file
@ -0,0 +1,300 @@
|
||||
Graph:
|
||||
0.00, 1169.81, 464.59, 945.75, 1282.33, 1037.66, 640.89, 335.29, 111.67, 1142.56, 876.33, 845.31, 1211.84, 587.31, 735.31, 497.33, 994.87, 922.07, 767.10, 1206.08,
|
||||
1169.81, 0.00, 722.99, 682.83, 191.14, 527.48, 777.24, 929.62, 1122.63, 195.17, 605.52, 512.54, 221.44, 833.01, 862.90, 703.24, 856.59, 540.04, 634.58, 278.41,
|
||||
464.59, 722.99, 0.00, 724.38, 859.17, 599.15, 302.60, 218.49, 402.17, 732.89, 621.64, 398.11, 747.67, 294.91, 643.37, 234.41, 848.21, 485.90, 527.86, 813.31,
|
||||
945.75, 682.83, 724.38, 0.00, 637.37, 1033.19, 987.82, 912.29, 968.32, 509.20, 110.33, 883.65, 881.27, 1003.66, 270.07, 509.33, 176.62, 969.29, 197.94, 488.88,
|
||||
1282.33, 191.14, 859.17, 637.37, 0.00, 718.08, 951.89, 1073.97, 1248.13, 148.33, 586.96, 697.31, 390.07, 1004.07, 862.04, 793.34, 797.85, 730.02, 646.87, 152.85,
|
||||
1037.66, 527.48, 599.15, 1033.19, 718.08, 0.00, 429.37, 711.89, 949.07, 688.28, 927.00, 202.18, 362.68, 495.69, 1097.48, 749.46, 1204.22, 115.60, 891.82, 786.43,
|
||||
640.89, 777.24, 302.60, 987.82, 951.89, 429.37, 0.00, 305.61, 540.80, 858.29, 879.23, 283.82, 711.61, 66.61, 940.60, 532.22, 1128.59, 321.60, 799.37, 953.47,
|
||||
335.29, 929.62, 218.49, 912.29, 1073.97, 711.89, 305.61, 0.00, 237.99, 950.40, 816.13, 528.89, 927.99, 253.89, 785.04, 403.11, 1016.59, 597.07, 714.52, 1031.72,
|
||||
111.67, 1122.63, 402.17, 968.32, 1248.13, 949.07, 540.80, 237.99, 0.00, 1113.40, 889.10, 762.34, 1146.42, 484.14, 780.69, 486.64, 1035.62, 833.92, 780.22, 1183.88,
|
||||
1142.56, 195.17, 732.89, 509.20, 148.33, 688.28, 858.29, 950.40, 1113.40, 0.00, 447.69, 626.97, 415.82, 905.04, 719.84, 649.85, 677.65, 676.77, 500.88, 99.83,
|
||||
876.33, 605.52, 621.64, 110.33, 586.96, 927.00, 879.23, 816.13, 889.10, 447.69, 0.00, 774.18, 793.21, 896.67, 276.70, 415.77, 277.38, 860.62, 109.33, 447.88,
|
||||
845.31, 512.54, 398.11, 883.65, 697.31, 202.18, 283.82, 528.89, 762.34, 626.97, 774.18, 0.00, 427.82, 347.93, 916.77, 551.90, 1047.64, 95.72, 723.98, 726.38,
|
||||
1211.84, 221.44, 747.67, 881.27, 390.07, 362.68, 711.61, 927.99, 1146.42, 415.82, 793.21, 427.82, 0.00, 775.20, 1030.70, 795.38, 1057.48, 415.82, 802.10, 499.04,
|
||||
587.31, 833.01, 294.91, 1003.66, 1004.07, 495.69, 66.61, 253.89, 484.14, 905.04, 896.67, 347.93, 775.20, 0.00, 938.28, 529.17, 1137.55, 388.20, 811.29, 998.51,
|
||||
735.31, 862.90, 643.37, 270.07, 862.04, 1097.48, 940.60, 785.04, 780.69, 719.84, 276.70, 916.77, 1030.70, 938.28, 0.00, 409.27, 260.66, 1010.99, 229.37, 724.57,
|
||||
497.33, 703.24, 234.41, 509.33, 793.34, 749.46, 532.22, 403.11, 486.64, 649.85, 415.77, 551.90, 795.38, 529.17, 409.27, 0.00, 618.90, 647.39, 311.83, 709.32,
|
||||
994.87, 856.59, 848.21, 176.62, 797.85, 1204.22, 1128.59, 1016.59, 1035.62, 677.65, 277.38, 1047.64, 1057.48, 1137.55, 260.66, 618.90, 0.00, 1135.78, 330.72, 646.05,
|
||||
922.07, 540.04, 485.90, 969.29, 730.02, 115.60, 321.60, 597.07, 833.92, 676.77, 860.62, 95.72, 415.82, 388.20, 1010.99, 647.39, 1135.78, 0.00, 814.86, 776.56,
|
||||
767.10, 634.58, 527.86, 197.94, 646.87, 891.82, 799.37, 714.52, 780.22, 500.88, 109.33, 723.98, 802.10, 811.29, 229.37, 311.83, 330.72, 814.86, 0.00, 519.68,
|
||||
1206.08, 278.41, 813.31, 488.88, 152.85, 786.43, 953.47, 1031.72, 1183.88, 99.83, 447.88, 726.38, 499.04, 998.51, 724.57, 709.32, 646.05, 776.56, 519.68, 0.00,
|
||||
Epsilon = 187.0
|
||||
MST:
|
||||
0: (8, 111.67),
|
||||
1: (12, 221.44), (4, 191.14),
|
||||
2: (7, 218.49), (15, 234.41),
|
||||
3: (10, 110.33), (16, 176.62),
|
||||
4: (1, 191.14), (9, 148.33),
|
||||
5: (17, 115.60), (12, 362.68),
|
||||
6: (13, 66.61), (11, 283.82),
|
||||
7: (8, 237.99), (2, 218.49), (13, 253.89),
|
||||
8: (0, 111.67), (7, 237.99),
|
||||
9: (4, 148.33), (19, 99.83),
|
||||
10: (18, 109.33), (3, 110.33),
|
||||
11: (6, 283.82), (17, 95.72),
|
||||
12: (5, 362.68), (1, 221.44),
|
||||
13: (7, 253.89), (6, 66.61),
|
||||
14: (18, 229.37),
|
||||
15: (2, 234.41), (18, 311.83),
|
||||
16: (3, 176.62),
|
||||
17: (11, 95.72), (5, 115.60),
|
||||
18: (15, 311.83), (10, 109.33), (14, 229.37),
|
||||
19: (9, 99.83),
|
||||
|
||||
Removed Edges = List(HHCEdge2(1,12,221.437941520422), HHCEdge2(1,4,191.1371918225627), HHCEdge2(2,7,218.49036137013215), HHCEdge2(2,15,234.40677699868428), HHCEdge2(4,1,191.1371918225627), HHCEdge2(5,12,362.6802853094028), HHCEdge2(6,11,283.817433688036), HHCEdge2(7,8,237.98544482631425), HHCEdge2(7,2,218.49036137013215), HHCEdge2(7,13,253.88652915186032), HHCEdge2(8,7,237.98544482631425), HHCEdge2(11,6,283.817433688036), HHCEdge2(12,5,362.6802853094028), HHCEdge2(12,1,221.437941520422), HHCEdge2(13,7,253.88652915186032), HHCEdge2(14,18,229.36669205588458), HHCEdge2(15,2,234.40677699868428), HHCEdge2(15,18,311.8336340813276), HHCEdge2(18,15,311.8336340813276), HHCEdge2(18,14,229.36669205588458))
|
||||
MST:
|
||||
0: (8, 111.67),
|
||||
1:
|
||||
2:
|
||||
3: (10, 110.33), (16, 176.62),
|
||||
4: (9, 148.33),
|
||||
5: (17, 115.60),
|
||||
6: (13, 66.61),
|
||||
7:
|
||||
8: (0, 111.67),
|
||||
9: (4, 148.33), (19, 99.83),
|
||||
10: (18, 109.33), (3, 110.33),
|
||||
11: (17, 95.72),
|
||||
12:
|
||||
13: (6, 66.61),
|
||||
14:
|
||||
15:
|
||||
16: (3, 176.62),
|
||||
17: (11, 95.72), (5, 115.60),
|
||||
18: (10, 109.33),
|
||||
19: (9, 99.83),
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 7
|
||||
Cluster-8: 12
|
||||
Cluster-9: 14
|
||||
Cluster-10: 15
|
||||
Neighbours:
|
||||
Cluster-0: (7, 237.99),
|
||||
Cluster-1: (4, 191.14), (8, 221.44),
|
||||
Cluster-2: (7, 218.49), (10, 234.41),
|
||||
Cluster-3: (9, 229.37), (10, 311.83),
|
||||
Cluster-4: (1, 191.14),
|
||||
Cluster-5: (8, 362.68),
|
||||
Cluster-6: (5, 283.82),
|
||||
Cluster-7: (2, 218.49), (0, 237.99), (6, 253.89),
|
||||
Cluster-8: (1, 221.44), (5, 362.68),
|
||||
Cluster-9: (3, 229.37),
|
||||
Cluster-10: (2, 234.41), (3, 311.83),
|
||||
Initial order: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 42.29, 55.81, 23.83, 55.61)
|
||||
Current order [2, 1, 9, 7, 10, 8, 4, 6, 0, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=10
|
||||
Chosen cluster = 3
|
||||
Nearest neighbour = 9
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 7
|
||||
Cluster-8: 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 42.29, 55.81, 112.740005, 55.61)
|
||||
Current order [2, 1, 7, 10, 8, 4, 6, 9, 0, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=9
|
||||
Chosen cluster = 5
|
||||
Nearest neighbour = 8
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 7
|
||||
Cluster-8: 5 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 42.29, 89.44, 112.740005, 55.61)
|
||||
Current order [2, 1, 7, 10, 4, 6, 8, 9, 0, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=8
|
||||
Chosen cluster = 0
|
||||
Nearest neighbour = 7
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 0 7
|
||||
Cluster-8: 5 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 125.17, 89.44, 112.740005, 55.61)
|
||||
Current order [2, 1, 10, 4, 6, 8, 9, 0, 7, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=6
|
||||
Chosen cluster = 9
|
||||
Nearest neighbour = 3
|
||||
3 10 -
|
||||
weight = 110.32563662919385
|
||||
3 18 -
|
||||
weight = 197.93532036986213
|
||||
3 16 -
|
||||
weight = 176.6244692117106
|
||||
10 18 -
|
||||
weight = 109.32984942622367
|
||||
10 16 -
|
||||
weight = 277.38062276155625
|
||||
18 16 -
|
||||
weight = 330.7167343396919
|
||||
Pairwise average = 200.3854387897064
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 125.17, 89.44, 112.740005, 55.61)
|
||||
Current order [2, 1, 10, 4, 6, 8, 9, 0, 7, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=10
|
||||
Chosen cluster = 3
|
||||
Nearest neighbour = 9
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 0 7
|
||||
Cluster-8: 5 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 125.17, 89.44, 112.740005, 55.61)
|
||||
Current order [2, 1, 10, 4, 6, 8, 9, 0, 7, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=10
|
||||
Chosen cluster = 3
|
||||
Nearest neighbour = 9
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 0 7
|
||||
Cluster-8: 5 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 125.17, 89.44, 112.740005, 55.61)
|
||||
Current order [2, 1, 10, 4, 6, 8, 9, 0, 7, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=9
|
||||
Chosen cluster = 5
|
||||
Nearest neighbour = 8
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 0 7
|
||||
Cluster-8: 5 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 125.17, 89.44, 112.740005, 55.61)
|
||||
Current order [2, 1, 10, 4, 6, 8, 9, 0, 7, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=9
|
||||
Chosen cluster = 5
|
||||
Nearest neighbour = 8
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 0 7
|
||||
Cluster-8: 5 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 125.17, 89.44, 112.740005, 55.61)
|
||||
Current order [2, 1, 10, 4, 6, 8, 9, 0, 7, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=9
|
||||
Chosen cluster = 5
|
||||
Nearest neighbour = 8
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 0 7
|
||||
Cluster-8: 5 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
||||
ArraySeq(115.13, 21.65, 2.66, 338.0, 66.130005, 136.32, 79.13, 125.17, 89.44, 112.740005, 55.61)
|
||||
Current order [2, 1, 10, 4, 6, 8, 9, 0, 7, 5, 3]
|
||||
maxWL = 338.0, minWL = 2.66
|
||||
WLD = 335.34
|
||||
Rand Num=9
|
||||
Chosen cluster = 5
|
||||
Nearest neighbour = 8
|
||||
Pairwise average = 0.0
|
||||
Average less than epsilonMax. Updating Clusters.
|
||||
Clusters:
|
||||
Cluster-0: 0 8
|
||||
Cluster-1: 1
|
||||
Cluster-2: 2
|
||||
Cluster-3: 3 10 18 16
|
||||
Cluster-4: 4 9 19
|
||||
Cluster-5: 5 17 11
|
||||
Cluster-6: 6 13
|
||||
Cluster-7: 0 7
|
||||
Cluster-8: 5 12
|
||||
Cluster-9: 3 14
|
||||
Cluster-10: 15
|
Loading…
Reference in New Issue
Block a user