Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build changes and parallel collections experiment #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "EstCC"

scalaVersion := "2.11.0"
scalaVersion := "2.10.2"

scalacOptions += "-feature"

Expand Down
2 changes: 0 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
addSbtPlugin("org.scala-sbt.plugins" % "sbt-onejar" % "0.8")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
2 changes: 1 addition & 1 deletion src/main/scala/infcalcs/InfConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ trait InfConfig {
val rand = true

//initialize PRNG
val rEngine = new MersenneTwister
def rEngine() = {new MersenneTwister}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this random number generator work? Is it ok to use a new instance in each thread?


}
15 changes: 11 additions & 4 deletions src/main/scala/infcalcs/InfMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package infcalcs
import annotation.tailrec
import math._
import TreeDef._
import scala.collection.parallel._

object CTBuild extends InfConfig {

Expand Down Expand Up @@ -78,6 +79,7 @@ object CTBuild extends InfConfig {

object EstimateMI extends InfConfig {
import CTBuild.{ buildTable, getBinDelims, weightSignalData }
val tasksupport = new ForkJoinTaskSupport(new scala.concurrent.forkjoin.ForkJoinPool(100))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be needed


// generates all (row, col) bin number tuples
def genBins(binList: List[Int], otherBinList: List[Int] = List()): List[Pair[Int]] = {
Expand Down Expand Up @@ -168,9 +170,14 @@ object EstimateMI extends InfConfig {
val invFracs = fracList map invSS

// generates data with jackknife method
val subSamples = fracList map (x => jackknife(x, pl))
val tables = subSamples map (x => buildTable(!rand)(x, bt, rowDelims, colDelims, wts))
val randTables = for (n <- 0 until numRandTables) yield subSamples map (x => buildTable(rand)(x, bt, rowDelims, colDelims, wts))
val subSamplesX = fracList.par
subSamplesX.tasksupport = tasksupport
val subSamples = subSamplesX.map (x => jackknife(x, pl))
val tables2 = subSamples map (x => buildTable(!rand)(x, bt, rowDelims, colDelims, wts))
val tables = tables2.toList
val randTablesX = (0 until numRandTables).par
randTablesX.tasksupport = tasksupport
val randTables = randTablesX.map(n => subSamples map (x => buildTable(rand)(x, bt, rowDelims, colDelims, wts)))

val l = wts match {
case None => "n"
Expand All @@ -182,7 +189,7 @@ object EstimateMI extends InfConfig {
if (fracList(f) < 1.0)
} yield s"${l}_r${bt._1}_c${bt._2}_${roundFrac(fracList(f))}_${f % numReps}"

(invFracs, tables, randTables.toList, tags :+ s"${l}_r${bt._1}_c${bt._2}")
(invFracs, tables, randTables.toList.map(a=>a.toList), tags :+ s"${l}_r${bt._1}_c${bt._2}")

}

Expand Down