You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
847 B

  1. import model.Customer
  2. import util._
  3. class HHCSim(
  4. private val epsilonMax: Int,
  5. private val iterations: Int,
  6. // private val customers: IndexedSeq[Customer],
  7. private val WLDMax: Float
  8. ) {
  9. // private val graph: Array[Array[T]]
  10. def go(
  11. customers: Either[String, IndexedSeq[Customer]]
  12. ): String Either Map[Int, IndexedSeq[(Int, Double)]] =
  13. customers
  14. .map(Util.formAdjMatrix)
  15. .map(edges => Util.mstUsingPrims(edges))
  16. .map(mst => Util.findCentroids(mst))
  17. .map(
  18. e =>
  19. e match {
  20. case (mst, centroids, removed) =>
  21. Util.findClusters(mst, centroids, removed)
  22. }
  23. )
  24. .map(
  25. e =>
  26. e match {
  27. case (centroids, clusters, removed) =>
  28. Util.groupClusters(centroids, clusters, removed)
  29. }
  30. )
  31. }