Rohan Sircar
4 years ago
6 changed files with 220 additions and 78 deletions
-
20Input.txt
-
8build.sbt
-
31src/main/scala/HHCSim.scala
-
35src/main/scala/Main.scala
-
11src/main/scala/config/Config.scala
-
147src/main/scala/util/Util.scala
@ -0,0 +1,20 @@ |
|||
9.46, 0.90, 82.88 |
|||
1.79, 7.90, 21.65 |
|||
5.90, 2.98, 2.66 |
|||
7.70, 9.18, 88.91 |
|||
2.07, 9.57, 48.59 |
|||
0.61, 3.38, 33.63 |
|||
3.80, 1.31, 7.02 |
|||
6.50, 1.13, 42.29 |
|||
8.53, 0.56, 32.25 |
|||
3.20, 8.90, 5.74 |
|||
7.13, 8.38, 99.00 |
|||
2.40, 3.40, 34.93 |
|||
0.34, 6.58, 55.81 |
|||
4.26, 0.94, 72.11 |
|||
9.42, 7.50, 23.83 |
|||
7.12, 4.67, 55.61 |
|||
9.13, 9.82, 62.38 |
|||
1.60, 3.12, 67.76 |
|||
7.39, 7.44, 87.71 |
|||
3.41, 9.76, 11.80 |
@ -1,19 +1,15 @@ |
|||
name := "scala-hhc" |
|||
version := "1.0" |
|||
version := "0.0.1" |
|||
scalaVersion := "2.13.1" |
|||
|
|||
|
|||
resolvers ++= Seq( |
|||
Resolver.sonatypeRepo("releases"), |
|||
Resolver.sonatypeRepo("snapshots") |
|||
) |
|||
|
|||
|
|||
// https://mvnrepository.com/artifact/org.projectlombok/lombok |
|||
libraryDependencies += "org.projectlombok" % "lombok" % "1.18.10" % "provided" |
|||
libraryDependencies ++= Seq( |
|||
"org.typelevel" %% "cats-core" % "2.0.0", |
|||
"com.softwaremill.quicklens" %% "quicklens" % "1.4.12", |
|||
"com.softwaremill.macwire" %% "macros" % "2.3.3", |
|||
"me.shadaj" %% "scalapy-numpy" % "0.1.0+5-ad550211" |
|||
"org.rogach" %% "scallop" % "3.4.0" |
|||
) |
@ -0,0 +1,31 @@ |
|||
import model.Customer |
|||
import util._ |
|||
class HHCSim( |
|||
private val epsilonMax: Int, |
|||
private val iterations: Int, |
|||
// private val customers: IndexedSeq[Customer], |
|||
private val WLDMax: Float |
|||
) { |
|||
// private val graph: Array[Array[T]] |
|||
def go( |
|||
customers: Either[String, IndexedSeq[Customer]] |
|||
): String Either Map[Int, IndexedSeq[(Int, Double)]] = |
|||
customers |
|||
.map(Util.formAdjMatrix) |
|||
.map(edges => Util.mstUsingPrims(edges)) |
|||
.map(mst => Util.findCentroids(mst)) |
|||
.map( |
|||
e => |
|||
e match { |
|||
case (mst, centroids, removed) => |
|||
Util.findClusters(mst, centroids, removed) |
|||
} |
|||
) |
|||
.map( |
|||
e => |
|||
e match { |
|||
case (centroids, clusters, removed) => |
|||
Util.groupClusters(centroids, clusters, removed) |
|||
} |
|||
) |
|||
} |
@ -0,0 +1,11 @@ |
|||
package config |
|||
|
|||
import org.rogach.scallop._ |
|||
|
|||
class Conf(arguments: Seq[String]) extends ScallopConf(arguments) { |
|||
val infile = |
|||
opt[String](default = Some("Input.txt"), descr = "Input file") |
|||
val outfile = |
|||
opt[String](default = Some("Output.txt"), descr = "Output file") |
|||
verify() |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue