diff --git a/PHPSkills/FactorGraphs/Factor.php b/PHPSkills/FactorGraphs/Factor.php
index 90e3b76..c421b4f 100644
--- a/PHPSkills/FactorGraphs/Factor.php
+++ b/PHPSkills/FactorGraphs/Factor.php
@@ -36,12 +36,12 @@ abstract class Factor
return count($this->_messages);
}
- protected function getVariables()
+ protected function &getVariables()
{
return $this->_variables;
}
- protected function getMessages()
+ protected function &getMessages()
{
return $this->_messages;
}
@@ -77,11 +77,11 @@ abstract class Factor
return $this->sendMessageVariable($message, $variable);
}
- protected abstract function sendMessageVariable(Message $message, Variable $variable);
+ protected abstract function sendMessageVariable(Message &$message, Variable &$variable);
- public abstract function createVariableToMessageBinding(Variable $variable);
+ public abstract function createVariableToMessageBinding(Variable &$variable);
- protected function createVariableToMessageBindingWithMessage(Variable $variable, Variable $message)
+ protected function createVariableToMessageBindingWithMessage(Variable &$variable, Variable &$message)
{
$index = count($this->_messages);
$this->_messages[] = $message;
diff --git a/PHPSkills/FactorGraphs/FactorGraph.php b/PHPSkills/FactorGraphs/FactorGraph.php
index 813ae65..b8fe431 100644
--- a/PHPSkills/FactorGraphs/FactorGraph.php
+++ b/PHPSkills/FactorGraphs/FactorGraph.php
@@ -5,14 +5,14 @@ class FactorGraph
{
private $_variableFactory;
- public function getVariableFactory()
+ public function &getVariableFactory()
{
return $this->_variableFactory;
}
- public function setVariableFactory($factory)
+ public function setVariableFactory(&$factory)
{
- $this->_variableFactory = $factory;
+ $this->_variableFactory = &$factory;
}
}
?>
diff --git a/PHPSkills/FactorGraphs/FactorGraphLayer.php b/PHPSkills/FactorGraphs/FactorGraphLayer.php
index 5a01a30..26558a6 100644
--- a/PHPSkills/FactorGraphs/FactorGraphLayer.php
+++ b/PHPSkills/FactorGraphs/FactorGraphLayer.php
@@ -1,6 +1,7 @@
_parentFactorGraph = $parentGraph;
+ $this->_parentFactorGraph = &$parentGraph;
}
- protected function getInputVariablesGroups()
+ protected function &getInputVariablesGroups()
{
return $this->_inputVariablesGroups;
}
// HACK
- public function getParentFactorGraph()
+ public function &getParentFactorGraph()
{
return $this->_parentFactorGraph;
}
- public function getOutputVariablesGroups()
+ public function &getOutputVariablesGroups()
{
return $this->_outputVariablesGroups;
}
- public function getLocalFactors()
+ public function &getLocalFactors()
{
return $this->_localFactors;
}
- public function setInputVariablesGroups($value)
+ public function &setInputVariablesGroups(&$value)
{
$this->_inputVariablesGroups = $value;
}
- protected function scheduleSequence($itemsToSequence)
+ protected function scheduleSequence(&$itemsToSequence)
{
return new ScheduleSequence("TODO", $itemsToSequence);
}
- protected function addLayerFactor($factor)
+ protected function addLayerFactor(&$factor)
{
$this->_localFactors[] = $factor;
}
diff --git a/PHPSkills/FactorGraphs/FactorList.php b/PHPSkills/FactorGraphs/FactorList.php
index e998826..527591c 100644
--- a/PHPSkills/FactorGraphs/FactorList.php
+++ b/PHPSkills/FactorGraphs/FactorList.php
@@ -49,7 +49,7 @@ class FactorList
return count($this->_list);
}
- public function addFactor(Factor $factor)
+ public function addFactor(Factor &$factor)
{
$this->_list[] = $factor;
return $factor;
diff --git a/PHPSkills/FactorGraphs/Variable.php b/PHPSkills/FactorGraphs/Variable.php
index ccd65d3..bad9cbb 100644
--- a/PHPSkills/FactorGraphs/Variable.php
+++ b/PHPSkills/FactorGraphs/Variable.php
@@ -14,12 +14,12 @@ class Variable
$this->resetToPrior();
}
- public function getValue()
+ public function &getValue()
{
return $this->_value;
}
- public function setValue($value)
+ public function setValue(&$value)
{
$this->_value = $value;
}
diff --git a/PHPSkills/SkillCalculator.php b/PHPSkills/SkillCalculator.php
index 4d2fec3..dbbb292 100644
--- a/PHPSkills/SkillCalculator.php
+++ b/PHPSkills/SkillCalculator.php
@@ -14,7 +14,7 @@ abstract class SkillCalculator
private $_playersPerTeamAllowed;
private $_totalTeamsAllowed;
- protected function __construct($supportedOptions, TeamsRange $totalTeamsAllowed, PlayersRange $playerPerTeamAllowed)
+ protected function __construct($supportedOptions, TeamsRange &$totalTeamsAllowed, PlayersRange &$playerPerTeamAllowed)
{
$this->_supportedOptions = $supportedOptions;
$this->_totalTeamsAllowed = $totalTeamsAllowed;
@@ -29,7 +29,7 @@ abstract class SkillCalculator
/// A mapping of team players and their ratings.
/// The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2)
/// All the players and their new ratings.
- public abstract function calculateNewRatings(GameInfo $gameInfo,
+ public abstract function calculateNewRatings(GameInfo &$gameInfo,
array $teamsOfPlayerToRatings,
array $teamRanks);
@@ -40,23 +40,23 @@ abstract class SkillCalculator
/// Parameters for the game.
/// A mapping of team players and their ratings.
/// The quality of the match between the teams as a percentage (0% = bad, 100% = well matched).
- public abstract function calculateMatchQuality(GameInfo $gameInfo,
- array $teamsOfPlayerToRatings);
+ public abstract function calculateMatchQuality(GameInfo &$gameInfo,
+ array &$teamsOfPlayerToRatings);
public function isSupported($option)
{
return ($this->_supportedOptions & $option) == $option;
}
- protected function validateTeamCountAndPlayersCountPerTeam(array $teamsOfPlayerToRatings)
+ protected function validateTeamCountAndPlayersCountPerTeam(array &$teamsOfPlayerToRatings)
{
self::validateTeamCountAndPlayersCountPerTeamWithRanges($teamsOfPlayerToRatings, $this->_totalTeamsAllowed, $this->_playersPerTeamAllowed);
}
private static function validateTeamCountAndPlayersCountPerTeamWithRanges(
- array $teams,
- TeamsRange $totalTeams,
- PlayersRange $playersPerTeam)
+ array &$teams,
+ TeamsRange &$totalTeams,
+ PlayersRange &$playersPerTeam)
{
$countOfTeams = 0;
diff --git a/PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php b/PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php
index 2dc6a03..b1833e1 100644
--- a/PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php
+++ b/PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php
@@ -40,7 +40,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
parent::__construct(SkillCalculatorSupportedOptions::PARTIAL_PLAY | SkillCalculatorSupportedOptions::PARTIAL_UPDATE, TeamsRange::atLeast(2), PlayersRange::atLeast(1));
}
- public function calculateNewRatings(GameInfo $gameInfo,
+ public function calculateNewRatings(GameInfo &$gameInfo,
array $teams,
array $teamRanks)
{
@@ -58,8 +58,8 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
return $factorGraph->getUpdatedRatings();
}
- public function calculateMatchQuality(GameInfo $gameInfo,
- array $teams)
+ public function calculateMatchQuality(GameInfo &$gameInfo,
+ array &$teams)
{
// We need to create the A matrix which is the player team assigments.
$teamAssignmentsList = $teams;
@@ -100,7 +100,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
return $result;
}
- private static function getPlayerMeansVector(array $teamAssignmentsList)
+ private static function getPlayerMeansVector(array &$teamAssignmentsList)
{
// A simple vector of all the player means.
return new Vector($this->getPlayerRatingValues($teamAssignmentsList,
@@ -110,7 +110,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
}));
}
- private static function getPlayerCovarianceMatrix(array $teamAssignmentsList)
+ private static function getPlayerCovarianceMatrix(array &$teamAssignmentsList)
{
// This is a square matrix whose diagonal values represent the variance (square of standard deviation) of all
// players.
@@ -123,7 +123,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
}
// Helper function that gets a list of values for all player ratings
- private static function getPlayerRatingValues(array $teamAssignmentsList,
+ private static function getPlayerRatingValues(array &$teamAssignmentsList,
$playerRatingFunction)
{
$playerRatingValues = array();
@@ -139,7 +139,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
return $playerRatingValues;
}
- private static function createPlayerTeamAssignmentMatrix($teamAssignmentsList, $totalPlayers)
+ private static function createPlayerTeamAssignmentMatrix(&$teamAssignmentsList, &$totalPlayers)
{
// The team assignment matrix is often referred to as the "A" matrix. It's a matrix whose rows represent the players
// and the columns represent teams. At Matrix[row, column] represents that player[row] is on team[col]
diff --git a/PHPSkills/TrueSkill/Factors/GaussianFactor.php b/PHPSkills/TrueSkill/Factors/GaussianFactor.php
index e7599cf..a525a05 100644
--- a/PHPSkills/TrueSkill/Factors/GaussianFactor.php
+++ b/PHPSkills/TrueSkill/Factors/GaussianFactor.php
@@ -20,7 +20,7 @@ abstract class GaussianFactor extends Factor
}
/// Sends the factor-graph message with and returns the log-normalization constant
- protected function sendMessageVariable(Message $message, Variable $variable)
+ protected function sendMessageVariable(Message &$message, Variable &$variable)
{
$marginal = $variable->getValue();
$messageValue = $message->getValue();
@@ -29,7 +29,7 @@ abstract class GaussianFactor extends Factor
return $logZ;
}
- public function createVariableToMessageBinding(Variable $variable)
+ public function createVariableToMessageBinding(Variable &$variable)
{
return parent::createVariableToMessageBinding($variable,
new Message(
diff --git a/PHPSkills/TrueSkill/Factors/GaussianGreaterThanFactor.php b/PHPSkills/TrueSkill/Factors/GaussianGreaterThanFactor.php
index 130d0e5..a4dfbba 100644
--- a/PHPSkills/TrueSkill/Factors/GaussianGreaterThanFactor.php
+++ b/PHPSkills/TrueSkill/Factors/GaussianGreaterThanFactor.php
@@ -20,7 +20,7 @@ class GaussianGreaterThanFactor extends GaussianFactor
{
private $_epsilon;
- public function __construct($epsilon, Variable $variable)
+ public function __construct($epsilon, Variable &$variable)
{
parent::_construct("{0} > {1:0.000}");
$this->_epsilon = $epsilon;
@@ -42,7 +42,7 @@ class GaussianGreaterThanFactor extends GaussianFactor
}
- protected function updateMessageVariable(Message $message, Variable $variable)
+ protected function updateMessageVariable(Message &$message, Variable &$variable)
{
$oldMarginal = clone $variable->getValue();
$oldMessage = clone $message->getValue();
diff --git a/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php b/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php
index 4fac94d..614b1d9 100644
--- a/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php
+++ b/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php
@@ -18,7 +18,7 @@ class GaussianLikelihoodFactor extends GaussianFactor
{
private $_precision;
- public function __construct($betaSquared, Variable $variable1, Variable $variable2)
+ public function __construct($betaSquared, Variable &$variable1, Variable &$variable2)
{
parent::__construct("Likelihood of {0} going to {1}");
$this->_precision = 1.0/$betaSquared;
@@ -36,8 +36,8 @@ class GaussianLikelihoodFactor extends GaussianFactor
$messages[0]->getValue());
}
- private function updateHelper(Message $message1, Message $message2,
- Variable $variable1, Variable $variable2)
+ private function updateHelper(Message &$message1, Message &$message2,
+ Variable &$variable1, Variable &$variable2)
{
$message1Value = clone $message1->getValue();
$message2Value = clone $message2->getValue();
diff --git a/PHPSkills/TrueSkill/Factors/GaussianPriorFactor.php b/PHPSkills/TrueSkill/Factors/GaussianPriorFactor.php
index d22b734..445845b 100644
--- a/PHPSkills/TrueSkill/Factors/GaussianPriorFactor.php
+++ b/PHPSkills/TrueSkill/Factors/GaussianPriorFactor.php
@@ -19,7 +19,7 @@ class GaussianPriorFactor extends GaussianFactor
{
private $_newMessage;
- public function __construct($mean, $variance, Variable $variable)
+ public function __construct($mean, $variance, Variable &$variable)
{
parent::__construct("Prior value going to {0}");
$this->_newMessage = new GaussianDistribution($mean, sqrt($variance));
@@ -27,10 +27,10 @@ class GaussianPriorFactor extends GaussianFactor
new Message(
GaussianDistribution::fromPrecisionMean(0, 0),
"message from {0} to {1}",
- this, variable));
+ $this, variable));
}
- protected function updateMessageVariable(Message $message, Variable $variable)
+ protected function updateMessageVariable(Message &$message, Variable &$variable)
{
$oldMarginal = clone $variable->getValue();
$oldMessage = $message;
diff --git a/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php b/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php
index 7c425ca..caf55da 100644
--- a/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php
+++ b/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php
@@ -23,7 +23,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
private $_weights;
private $_weightsSquared;
- public function __construct(Variable $sumVariable, array $variablesToSum, array $variableWeights = null)
+ public function __construct(Variable &$sumVariable, array &$variablesToSum, array &$variableWeights = null)
{
parent::__construct($this->createName($sumVariable, $variablesToSum, $variableWeights));
$this->_weights = array();
@@ -133,9 +133,9 @@ class GaussianWeightedSumFactor extends GaussianFactor
return $result;
}
- private function updateHelper(array $weights, array $weightsSquared,
- array $messages,
- array $variables)
+ private function updateHelper(array &$weights, array &$weightsSquared,
+ array &$messages,
+ array &$variables)
{
// Potentially look at http://mathworld.wolfram.com/NormalSumDistribution.html for clues as
// to what it's doing
diff --git a/PHPSkills/TrueSkill/Factors/GaussianWithinFactor.php b/PHPSkills/TrueSkill/Factors/GaussianWithinFactor.php
index 76a09b1..2ad86ea 100644
--- a/PHPSkills/TrueSkill/Factors/GaussianWithinFactor.php
+++ b/PHPSkills/TrueSkill/Factors/GaussianWithinFactor.php
@@ -20,7 +20,7 @@ class GaussianWithinFactor extends GaussianFactor
{
private $_epsilon;
- public function __construct($epsilon, Variable $variable)
+ public function __construct($epsilon, Variable &$variable)
{
$this->_epsilon = $epsilon;
$this->createVariableToMessageBinding($variable);
@@ -43,7 +43,7 @@ class GaussianWithinFactor extends GaussianFactor
return -GaussianDistribution::logProductNormalization($messageFromVariable, $message) + log($z);
}
- protected function updateMessage(Message $message, Variable $variable)
+ protected function updateMessage(Message &$message, Variable &$variable)
{
$oldMarginal = clone $variable->getValue();
$oldMessage = clone $message->getValue();
diff --git a/PHPSkills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php b/PHPSkills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php
index e1c36c7..6554ea7 100644
--- a/PHPSkills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php
+++ b/PHPSkills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php
@@ -18,9 +18,9 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
private $_TeamDifferencesComparisonLayer;
private $_TeamPerformancesToTeamPerformanceDifferencesLayer;
- public function __construct(TrueSkillFactorGraph $parentGraph,
- TeamPerformancesToTeamPerformanceDifferencesLayer $teamPerformancesToPerformanceDifferences,
- TeamDifferencesComparisonLayer $teamDifferencesComparisonLayer)
+ public function __construct(TrueSkillFactorGraph &$parentGraph,
+ TeamPerformancesToTeamPerformanceDifferencesLayer &$teamPerformancesToPerformanceDifferences,
+ TeamDifferencesComparisonLayer &$teamDifferencesComparisonLayer)
{
parent::__construct($parentGraph);
$this->_TeamPerformancesToTeamPerformanceDifferencesLayer = $teamPerformancesToPerformanceDifferences;
diff --git a/PHPSkills/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php b/PHPSkills/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php
index b047b71..30578ae 100644
--- a/PHPSkills/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php
+++ b/PHPSkills/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php
@@ -14,7 +14,7 @@ use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLayer
{
- public function __construct(TrueSkillFactorGraph $parentGraph)
+ public function __construct(TrueSkillFactorGraph &$parentGraph)
{
parent::__construct($parentGraph);
}
@@ -44,7 +44,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
"all player perf to team perf schedule");
}
- protected function createPlayerToTeamSumFactor($teamMembers, $sumVariable)
+ protected function createPlayerToTeamSumFactor(&$teamMembers, &$sumVariable)
{
return new GaussianWeightedSumFactor(
$sumVariable,
@@ -74,7 +74,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
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 = "TODO";
diff --git a/PHPSkills/TrueSkill/Layers/PlayerPriorValuesToSkillsLayer.php b/PHPSkills/TrueSkill/Layers/PlayerPriorValuesToSkillsLayer.php
index 7668fe5..4de1faf 100644
--- a/PHPSkills/TrueSkill/Layers/PlayerPriorValuesToSkillsLayer.php
+++ b/PHPSkills/TrueSkill/Layers/PlayerPriorValuesToSkillsLayer.php
@@ -19,7 +19,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
{
private $_teams;
- public function __construct(TrueSkillFactorGraph $parentGraph, $teams)
+ public function __construct(TrueSkillFactorGraph &$parentGraph, &$teams)
{
parent::__construct($parentGraph);
$this->_teams = $teams;
@@ -31,10 +31,11 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
{
$currentTeamSkills = array();
- foreach ($currentTeam as $currentTeamPlayer)
+ foreach ($currentTeam->getAllPlayers() as $currentTeamPlayer)
{
- $playerSkill = $this->createSkillOutputVariable($currentTeamPlayer.Key);
- $this->addLayerFactor($this->createPriorFactor($currentTeamPlayer.Key, $currentTeamPlayer.Value, $playerSkill));
+ $currentTeamPlayerRating = $currentTeam->getRating($currentTeamPlayer);
+ $playerSkill = $this->createSkillOutputVariable($currentTeamPlayer);
+ $this->addLayerFactor($this->createPriorFactor($currentTeamPlayer, $currentTeamPlayerRating, $playerSkill));
$currentTeamSkills[] = $playerSkill;
}
@@ -55,7 +56,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
"All priors");
}
- private function createPriorFactor($player, $priorRating, $skillsVariable)
+ private function createPriorFactor(&$player, &$priorRating, &$skillsVariable)
{
return new GaussianPriorFactor($priorRating->getMean(),
square($priorRating->getStandardDeviation()) +
@@ -65,7 +66,9 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
private function createSkillOutputVariable($key)
{
- return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, "{0}'s skill", $key);
+ $parentFactorGraph = $this->getParentFactorGraph();
+ $variableFactory = $parentFactorGraph->getVariableFactory();
+ return $variableFactory->createKeyedVariable($key, "{0}'s skill", $key);
}
}
diff --git a/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php b/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php
index 6c19244..72ce887 100644
--- a/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php
+++ b/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php
@@ -13,7 +13,7 @@ use Moserware\Skills\TrueSkill\Factors\GaussianLikelihoodFactor;
class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
{
- public function __construct(TrueSkillFactorGraph $parentGraph)
+ public function __construct(TrueSkillFactorGraph &$parentGraph)
{
parent::__construct($parentGraph);
}
@@ -36,12 +36,12 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
}
}
- private function createLikelihood($playerSkill, $playerPerformance)
+ private function createLikelihood(&$playerSkill, &$playerPerformance)
{
return new GaussianLikelihoodFactor(square($this->getParentFactorGraph()->getGameInfo()->getBeta()), $playerPerformance, $playerSkill);
}
- private function createOutputVariable($key)
+ private function createOutputVariable(&$key)
{
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, "{0}'s performance", $key);
}
diff --git a/PHPSkills/TrueSkill/Layers/TeamDifferencesComparisonLayer.php b/PHPSkills/TrueSkill/Layers/TeamDifferencesComparisonLayer.php
index 11b3235..fc7384c 100644
--- a/PHPSkills/TrueSkill/Layers/TeamDifferencesComparisonLayer.php
+++ b/PHPSkills/TrueSkill/Layers/TeamDifferencesComparisonLayer.php
@@ -17,7 +17,7 @@ class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
private $_epsilon;
private $_teamRanks;
- public function __construct(TrueSkillFactorGraph $parentGraph, array $teamRanks)
+ public function __construct(TrueSkillFactorGraph &$parentGraph, array &$teamRanks)
{
parent::__construct($parentGraph);
$this->_teamRanks = $teamRanks;
diff --git a/PHPSkills/TrueSkill/Layers/TeamPerformancesToTeamPerformanceDifferencesLayer.php b/PHPSkills/TrueSkill/Layers/TeamPerformancesToTeamPerformanceDifferencesLayer.php
index 4237411..9963224 100644
--- a/PHPSkills/TrueSkill/Layers/TeamPerformancesToTeamPerformanceDifferencesLayer.php
+++ b/PHPSkills/TrueSkill/Layers/TeamPerformancesToTeamPerformanceDifferencesLayer.php
@@ -13,7 +13,7 @@ use Moserware\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorGraphLayer
{
- public function __construct(TrueSkillFactorGraph $parentGraph)
+ public function __construct(TrueSkillFactorGraph &$parentGraph)
{
parent::__construct($parentGraph);
}
@@ -38,7 +38,7 @@ class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorG
}
private function createTeamPerformanceToDifferenceFactor(
- Variable $strongerTeam, Variable $weakerTeam, Variable $output)
+ Variable &$strongerTeam, Variable &$weakerTeam, Variable &$output)
{
return new GaussianWeightedSumFactor($output, array($strongerTeam, $weakerTeam), array(1.0, -1.0));
}
diff --git a/PHPSkills/TrueSkill/Layers/TrueSkillFactorGraphLayer.php b/PHPSkills/TrueSkill/Layers/TrueSkillFactorGraphLayer.php
index 3525ab2..ea5754d 100644
--- a/PHPSkills/TrueSkill/Layers/TrueSkillFactorGraphLayer.php
+++ b/PHPSkills/TrueSkill/Layers/TrueSkillFactorGraphLayer.php
@@ -9,7 +9,7 @@ use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
abstract class TrueSkillFactorGraphLayer extends FactorGraphLayer
{
- public function __construct(TrueSkillFactorGraph $parentGraph)
+ public function __construct(TrueSkillFactorGraph &$parentGraph)
{
parent::__construct($parentGraph);
}
diff --git a/PHPSkills/TrueSkill/TrueSkillFactorGraph.php b/PHPSkills/TrueSkill/TrueSkillFactorGraph.php
index b58bc1d..ef217b7 100644
--- a/PHPSkills/TrueSkill/TrueSkillFactorGraph.php
+++ b/PHPSkills/TrueSkill/TrueSkillFactorGraph.php
@@ -35,15 +35,16 @@ class TrueSkillFactorGraph extends FactorGraph
private $_priorLayer;
private $_variableFactory;
- public function __construct(GameInfo $gameInfo, $teams, array $teamRanks)
+ public function __construct(GameInfo &$gameInfo, &$teams, array $teamRanks)
{
$this->_priorLayer = new PlayerPriorValuesToSkillsLayer($this, $teams);
$this->_gameInfo = $gameInfo;
- $this->_variableFactory = new VariableFactory(
+ $newFactory = new VariableFactory(
function()
{
return GaussianDistribution::fromPrecisionMean(0, 0);
});
+ $this->setVariableFactory($newFactory);
$this->_layers = array(
$this->_priorLayer,