Skip to content

Instantly share code, notes, and snippets.

@dat-vikash
Created March 31, 2015 16:35
Show Gist options
  • Save dat-vikash/6f21ef2721147b09be55 to your computer and use it in GitHub Desktop.
Save dat-vikash/6f21ef2721147b09be55 to your computer and use it in GitHub Desktop.
SIM Distribution: defineSenatorTrack
[1] def defineSenatorTrack() =
{
// for every committee
[2] committeeIssueSenatorMap.foreach( committee => {
committee._2.foreach(issueConf => {
issueConf._2.foreach( senator => {
[3] val max = committee._2.foldLeft(0)( (result, current) => result + current._2.filter(_.faction.name.equalsIgnoreCase(senator.faction.name)).size) / 2
// does the senator fit in subcommittee 1
[4] if(doesSenatorFitInSubCommittee(senator.faction.name, max, senator, committee._1.name,SUBCOMMITTEE_1_KEY)) {
// add
[5] senatorTrackMap += ((senator,Map[String,String](COMMITTEE_KEY->committee._1.name, SUBCOMMITTEE_KEY->SUBCOMMITTEE_1_KEY, ISSUE_CONFERENCE_KEY-> issueConf._1)))
}
// or subcommittee 2
[6] else if(doesSenatorFitInSubCommittee(senator.faction.name, max, senator, committee._1.name,SUBCOMMITTEE_2_KEY)) {
// add
[7] senatorTrackMap += ((senator,Map[String,String](COMMITTEE_KEY->committee._1.name, SUBCOMMITTEE_KEY->SUBCOMMITTEE_2_KEY, ISSUE_CONFERENCE_KEY-> issueConf._1)))
} else {
[8] Logger.info("Could not fit senator")
}
})
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment