First time of no blatant syntax errors

This commit is contained in:
Jeff Moser 2010-09-18 15:24:36 -04:00
parent e434696b44
commit 4748e7453a
4 changed files with 41 additions and 26 deletions

@ -47,16 +47,17 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
$totalTeamDifferences = count($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors()); $totalTeamDifferences = count($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors());
$totalTeams = $totalTeamDifferences + 1; $totalTeams = $totalTeamDifferences + 1;
$localFactors = $this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
$innerSchedule = new ScheduleSequence( $innerSchedule = new ScheduleSequence(
"inner schedule", "inner schedule",
array( array(
$loop, $loop,
new ScheduleStep( new ScheduleStep(
"teamPerformanceToPerformanceDifferenceFactors[0] @ 1", "teamPerformanceToPerformanceDifferenceFactors[0] @ 1",
($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[0], 1), $localFactors[0], 1),
new ScheduleStep( new ScheduleStep(
"teamPerformanceToPerformanceDifferenceFactors[teamTeamDifferences = {0} - 1] @ 2", "teamPerformanceToPerformanceDifferenceFactors[teamTeamDifferences = {0} - 1] @ 2",
($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$totalTeamDifferences - 1], 2) $localFactors[$totalTeamDifferences - 1], 2)
) )
); );
@ -65,15 +66,18 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
private function createTwoTeamInnerPriorLoopSchedule() private function createTwoTeamInnerPriorLoopSchedule()
{ {
$teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors = $this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
$teamDifferencesComparisonLayerLocalFactors = $this->_TeamDifferencesComparisonLayer->getLocalFactors();
return $this->scheduleSequence( return $this->scheduleSequence(
array( array(
new ScheduleStep( new ScheduleStep(
"send team perf to perf differences", "send team perf to perf differences",
($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[0], $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[0],
0), 0),
new ScheduleStep( new ScheduleStep(
"send to greater than or within factor", "send to greater than or within factor",
($this->_TeamDifferencesComparisonLayer->getLocalFactors())[0], $teamDifferencesComparisonLayerLocalFactors[0],
0) 0)
), ),
"loop of just two teams inner sequence"); "loop of just two teams inner sequence");
@ -87,19 +91,22 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
for ($i = 0; $i < $totalTeamDifferences - 1; $i++) for ($i = 0; $i < $totalTeamDifferences - 1; $i++)
{ {
$teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors = $this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
$teamDifferencesComparisonLayerLocalFactors = $this->_TeamDifferencesComparisonLayer->getLocalFactors();
$currentForwardSchedulePiece = $currentForwardSchedulePiece =
$this->scheduleSequence( $this->scheduleSequence(
array( array(
new ScheduleStep( new ScheduleStep(
sprintf("team perf to perf diff %d", $i), sprintf("team perf to perf diff %d", $i),
($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$i], 0), $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[$i], 0),
new ScheduleStep( new ScheduleStep(
sprintf("greater than or within result factor %d", $i), sprintf("greater than or within result factor %d", $i),
($this->_TeamDifferencesComparisonLayer->getLocalFactors())[$i], 0), $teamDifferencesComparisonLayerLocalFactors[$i], 0),
new ScheduleStep( new ScheduleStep(
sprintf("team perf to perf diff factors [%d], 2", $i), sprintf("team perf to perf diff factors [%d], 2", $i),
($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$i], 2) $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[$i], 2)
), sprintf("current forward schedule piece %d", $i); ), sprintf("current forward schedule piece %d", $i));
$forwardScheduleList[] = $currentForwardSchedulePiece; $forwardScheduleList[] = $currentForwardSchedulePiece;
} }
@ -110,19 +117,22 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
for ($i = 0; $i < $totalTeamDifferences - 1; $i++) for ($i = 0; $i < $totalTeamDifferences - 1; $i++)
{ {
$teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors = $this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
$teamDifferencesComparisonLayerLocalFactors = $this->_TeamDifferencesComparisonLayer->getLocalFactors();
$currentBackwardSchedulePiece = new ScheduleSequence( $currentBackwardSchedulePiece = new ScheduleSequence(
"current backward schedule piece", "current backward schedule piece",
array( array(
new ScheduleStep( new ScheduleStep(
sprintf("teamPerformanceToPerformanceDifferenceFactors[totalTeamDifferences - 1 - %d] @ 0", $i), sprintf("teamPerformanceToPerformanceDifferenceFactors[totalTeamDifferences - 1 - %d] @ 0", $i),
($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$totalTeamDifferences - 1 - $i], 0), $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[$totalTeamDifferences - 1 - $i], 0),
new ScheduleStep( new ScheduleStep(
sprintf("greaterThanOrWithinResultFactors[totalTeamDifferences - 1 - %d] @ 0", $i), sprintf("greaterThanOrWithinResultFactors[totalTeamDifferences - 1 - %d] @ 0", $i),
($this->_TeamDifferencesComparisonLayer->getLocalFactors())[$totalTeamDifferences - 1 - $i], 0), $teamDifferencesComparisonLayerLocalFactors[$totalTeamDifferences - 1 - $i], 0),
new ScheduleStep( new ScheduleStep(
sprintf("teamPerformanceToPerformanceDifferenceFactors[totalTeamDifferences - 1 - %d] @ 1", $i), sprintf("teamPerformanceToPerformanceDifferenceFactors[totalTeamDifferences - 1 - %d] @ 1", $i),
($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$totalTeamDifferences - 1 - $i], 1) $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[$totalTeamDifferences - 1 - $i], 1)
); ));
$backwardScheduleList[] = $currentBackwardSchedulePiece; $backwardScheduleList[] = $currentBackwardSchedulePiece;
} }

@ -50,21 +50,24 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
public function createPosteriorSchedule() public function createPosteriorSchedule()
{ {
// BLOG // BLOG
return $this->scheduleSequence( $allFactors = array();
from currentFactor in LocalFactors foreach($this->getLocalFactors() as $currentFactor)
from currentIteration in {
Enumerable.Range(1, currentFactor.NumberOfMessages - 1) $numberOfMessages = $currentFactor->getNumberOfMessages();
select new ScheduleStep<GaussianDistribution>( for($currentIteration = 1; $currentIteration < $numberOfMessages; $currentIteration++)
"team sum perf @" + currentIteration, {
currentFactor, $allFactors[] = new ScheduleStep("team sum perf @" + $currentIteration,
currentIteration), $currentFactor, $currentIteration);
"all of the team's sum iterations"); }
}
return $this->scheduleSequence($allFactors, "all of the team's sum iterations");
} }
private function createOutputVariable($team) private function createOutputVariable($team)
{ {
$teamMemberNames = String.Join(", ", team.Select(teamMember => teamMember.Key.ToString()).ToArray()); ///$teamMemberNames = String.Join(", ", team.Select(teamMember => teamMember.Key.ToString()).ToArray());
return ParentFactorGraph.VariableFactory.CreateBasicVariable("Team[{0}]'s performance", teamMemberNames); $teamMemberNames = "TODO";
return $this->getParentFactorGraph()->getVariableFactory()->createBasicVariable("Team[{0}]'s performance", $teamMemberNames);
} }
} }

@ -21,8 +21,9 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
$this->addLayerFactor($this->createLikelihood($playerSkillVariable, $playerPerformance)); $this->addLayerFactor($this->createLikelihood($playerSkillVariable, $playerPerformance));
$currentTeamPlayerPerformances[] = $playerPerformance; $currentTeamPlayerPerformances[] = $playerPerformance;
} }
$this->getOutputVariablesGroups()[] = $currentTeamPlayerPerformances; $outputVariablesGroups = $this->getOutputVariablesGroups();
$outputVariablesGroups[] = $currentTeamPlayerPerformances;
} }
} }

@ -23,7 +23,8 @@ class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorG
$this->addLayerFactor($this->createTeamPerformanceToDifferenceFactor($strongerTeam, $weakerTeam, currentDifference)); $this->addLayerFactor($this->createTeamPerformanceToDifferenceFactor($strongerTeam, $weakerTeam, currentDifference));
// REVIEW: Does it make sense to have groups of one? // REVIEW: Does it make sense to have groups of one?
$this->getOutputVariablesGroups()[] = $currentDifference; $outputVariablesGroup = $this->getOutputVariablesGroups();
$outputVariablesGroup[] = $currentDifference;
} }
} }