Added checkempty stage to pipeline
This commit is contained in:
parent
69a0c3ce63
commit
216d3f08ff
@ -11,6 +11,7 @@ class HHCSim(
|
|||||||
customers: Either[String, IndexedSeq[Customer]]
|
customers: Either[String, IndexedSeq[Customer]]
|
||||||
): String Either Map[Int, IndexedSeq[(Int, Double)]] =
|
): String Either Map[Int, IndexedSeq[(Int, Double)]] =
|
||||||
customers
|
customers
|
||||||
|
.flatMap(checkEmpty)
|
||||||
.map(Util.formAdjMatrix)
|
.map(Util.formAdjMatrix)
|
||||||
.map(edges => Util.mstUsingPrims(edges))
|
.map(edges => Util.mstUsingPrims(edges))
|
||||||
.map(mst => Util.findCentroids(mst))
|
.map(mst => Util.findCentroids(mst))
|
||||||
@ -28,4 +29,13 @@ class HHCSim(
|
|||||||
Util.groupClusters(centroids, clusters, removed)
|
Util.groupClusters(centroids, clusters, removed)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def checkEmpty(
|
||||||
|
customers: IndexedSeq[Customer]
|
||||||
|
): Either[String, IndexedSeq[Customer]] =
|
||||||
|
customers.length match {
|
||||||
|
case 0 => Left("Error input was empty")
|
||||||
|
case _ => Right(customers)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,26 @@ object Main {
|
|||||||
|
|
||||||
val customers = Util.getCustomers(bufferedSource)
|
val customers = Util.getCustomers(bufferedSource)
|
||||||
bufferedSource.close()
|
bufferedSource.close()
|
||||||
|
|
||||||
|
val hhc = new HHCSim(epsilonMax = 40, iterations = 10, WLDMax = 10)
|
||||||
|
val fnl2 = hhc.go(customers)
|
||||||
// customers.map(println(_))
|
// customers.map(println(_))
|
||||||
|
|
||||||
// val edges3 = customers.map(Util.formAdjMatrix)
|
// val edges3 = customers.map(Util.formAdjMatrix)
|
||||||
|
|
||||||
// val fnl2 = go(customers)
|
// val fnl2 = go(customers)
|
||||||
|
|
||||||
// fnl2 match {
|
fnl2 match {
|
||||||
// case Left(value) => println(value)
|
case Left(value) => println(value)
|
||||||
// case Right(value) => println(value)
|
case Right(groups) =>
|
||||||
// }
|
groups.foreach(c => {
|
||||||
|
print(s"${c._1} -> ")
|
||||||
|
c._2.foreach(e => {
|
||||||
|
print(f"(${e._1}%d, ${e._2}%.2f), ")
|
||||||
|
})
|
||||||
|
println
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// edges3 match {
|
// edges3 match {
|
||||||
// case Right(e) =>
|
// case Right(e) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user