From 930444a0f78ea4e81de7a75b25dc05c4af64e784 Mon Sep 17 00:00:00 2001 From: Jeff Moser Date: Sun, 3 Oct 2010 19:21:55 -0400 Subject: [PATCH] Removed some debugging code --- PHPSkills/FactorGraphs/Factor.php | 17 +++++------------ PHPSkills/FactorGraphs/Message.php | 4 +--- PHPSkills/FactorGraphs/Schedule.php | 4 +--- PHPSkills/FactorGraphs/Variable.php | 10 ++-------- .../Factors/GaussianLikelihoodFactor.php | 8 +------- .../Factors/GaussianWeightedSumFactor.php | 18 +++--------------- PHPSkills/TrueSkill/TrueSkillFactorGraph.php | 3 +-- .../TrueSkill/TrueSkillCalculatorTests.php | 9 ++++++--- 8 files changed, 20 insertions(+), 53 deletions(-) diff --git a/PHPSkills/FactorGraphs/Factor.php b/PHPSkills/FactorGraphs/Factor.php index 2609b73..a9a6441 100644 --- a/PHPSkills/FactorGraphs/Factor.php +++ b/PHPSkills/FactorGraphs/Factor.php @@ -34,15 +34,13 @@ abstract class Factor { return count($this->_messages); } - - // DEBUG: make protected - public function &getVariables() + + protected function &getVariables() { return $this->_variables; } - - // DEBUG: make protected - public function &getMessages() + + protected function &getMessages() { return $this->_messages; } @@ -52,12 +50,7 @@ abstract class Factor { Guard::argumentIsValidIndex($messageIndex, count($this->_messages), "messageIndex"); $message = &$this->_messages[$messageIndex]; - $variable = &$this->_messageToVariableBinding->getValue($message); - // DEBUG - $selfName = (string)$this; - $debugName = (string)$variable; - $debugHash = \spl_object_hash($variable); - $debugValue = $variable->getValue(); + $variable = &$this->_messageToVariableBinding->getValue($message); return $this->updateMessageVariable($message, $variable); } diff --git a/PHPSkills/FactorGraphs/Message.php b/PHPSkills/FactorGraphs/Message.php index b2ba80a..6768a8b 100644 --- a/PHPSkills/FactorGraphs/Message.php +++ b/PHPSkills/FactorGraphs/Message.php @@ -19,9 +19,7 @@ class Message } public function setValue(&$value) - { - // DEBUG - $selfName = (string)$this; + { $this->_value = &$value; } diff --git a/PHPSkills/FactorGraphs/Schedule.php b/PHPSkills/FactorGraphs/Schedule.php index 68450e4..34b64ee 100644 --- a/PHPSkills/FactorGraphs/Schedule.php +++ b/PHPSkills/FactorGraphs/Schedule.php @@ -34,9 +34,7 @@ class ScheduleStep extends Schedule public function visit($depth = -1, $maxDepth = 0) { - $currentFactor = &$this->_factor; - // DEBUG - $currentFactorName = (string)$currentFactor; + $currentFactor = &$this->_factor; $delta = $currentFactor->updateMessageIndex($this->_index); return $delta; } diff --git a/PHPSkills/FactorGraphs/Variable.php b/PHPSkills/FactorGraphs/Variable.php index 9e5a2be..5f464ad 100644 --- a/PHPSkills/FactorGraphs/Variable.php +++ b/PHPSkills/FactorGraphs/Variable.php @@ -16,18 +16,12 @@ class Variable public function &getValue() { - $value = &$this->_value; - // DEBUG - $selfHash = \spl_object_hash($this); - $selfName = (string)$this; + $value = &$this->_value; return $value; } public function setValue(&$value) - { - // DEBUG - $selfName = (string)$this; - $selfHash = \spl_object_hash($this); + { $this->_value = &$value; } diff --git a/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php b/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php index 7a97a21..28d1a4e 100644 --- a/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php +++ b/PHPSkills/TrueSkill/Factors/GaussianLikelihoodFactor.php @@ -38,13 +38,7 @@ class GaussianLikelihoodFactor extends GaussianFactor private function updateHelper(Message &$message1, Message &$message2, Variable &$variable1, Variable &$variable2) - { - // DEBUG - $message1ValueTest = $message1->getValue(); - $variable1ValueTest = $variable1->getValue(); - $message2ValueTest = $message2->getValue(); - $variable2ValueTest = $variable2->getValue(); - + { $message1Value = clone $message1->getValue(); $message2Value = clone $message2->getValue(); diff --git a/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php b/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php index 23d9d21..8d55670 100644 --- a/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php +++ b/PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php @@ -121,11 +121,7 @@ class GaussianWeightedSumFactor extends GaussianFactor { $localCurrentVariable = &$currentVariable; $this->createVariableToMessageBinding($localCurrentVariable); - } - - // DEBUG - $selfName = (string)$this; - $selfVars = &$this->getVariables(); + } } public function getLogNormalization() @@ -204,9 +200,7 @@ class GaussianWeightedSumFactor extends GaussianFactor } public function updateMessageIndex($messageIndex) - { - // DEBUG - $currentFactorName = (string)$this; + { $allMessages = &$this->getMessages(); $allVariables = &$this->getVariables(); @@ -226,13 +220,7 @@ class GaussianWeightedSumFactor extends GaussianFactor $updatedMessages[] = &$allMessages[$indicesToUse[$i]]; $updatedVariables[] = &$allVariables[$indicesToUse[$i]]; } - - // DEBUG - foreach($allVariables as &$currentVariable) - { - $currentVarVal = &$currentVariable->getValue(); - } - + return $this->updateHelper($this->_weights[$messageIndex], $this->_weightsSquared[$messageIndex], $updatedMessages, diff --git a/PHPSkills/TrueSkill/TrueSkillFactorGraph.php b/PHPSkills/TrueSkill/TrueSkillFactorGraph.php index 3b79994..9f81015 100644 --- a/PHPSkills/TrueSkill/TrueSkillFactorGraph.php +++ b/PHPSkills/TrueSkill/TrueSkillFactorGraph.php @@ -144,8 +144,7 @@ class TrueSkillFactorGraph extends FactorGraph { foreach ($currentTeam as &$currentPlayer) { - $localCurrentPlayer = &$currentPlayer->getKey(); - $test = \spl_object_hash($localCurrentPlayer); + $localCurrentPlayer = &$currentPlayer->getKey(); $newRating = new Rating($currentPlayer->getValue()->getMean(), $currentPlayer->getValue()->getStandardDeviation()); diff --git a/UnitTests/TrueSkill/TrueSkillCalculatorTests.php b/UnitTests/TrueSkill/TrueSkillCalculatorTests.php index b554502..0224ba9 100644 --- a/UnitTests/TrueSkill/TrueSkillCalculatorTests.php +++ b/UnitTests/TrueSkill/TrueSkillCalculatorTests.php @@ -81,9 +81,7 @@ class TrueSkillCalculatorTests private static function twoPlayerTestNotDrawn($testClass, SkillCalculator $calculator) { $player1 = new Player(1); - $player2 = new Player(2); - $p1Key = \spl_object_hash($player1); - $p2Key = \spl_object_hash($player2); + $player2 = new Player(2); $gameInfo = new GameInfo(); $team1 = new Team($player1, $gameInfo->getDefaultRating()); @@ -200,6 +198,10 @@ class TrueSkillCalculatorTests self::assertMatchQuality($testClass, 0.135, $calculator->calculateMatchQuality($gameInfo, $teams)); } + //------------------------------------------------------------------------------ + // Two Team Tests + //------------------------------------------------------------------------------ + private static function twoOnTwoSimpleTest($testClass, SkillCalculator $calculator) { $player1 = new Player(1); @@ -586,6 +588,7 @@ class TrueSkillCalculatorTests self::assertMatchQuality($testClass, 0.447, $calculator->calculateMatchQuality($gameInfo, $teams)); } + private static function threeTeamsOfOneNotDrawn($testClass, SkillCalculator $calculator) { $player1 = new Player(1);