Created
March 31, 2015 16:35
-
-
Save dat-vikash/6f21ef2721147b09be55 to your computer and use it in GitHub Desktop.
SIM Distribution: defineSenatorTrack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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