mirror of
https://github.com/furyfire/trueskill.git
synced 2025-03-30 04:34:16 +00:00
It gets a result... unfortunately it's wrong. But hey, that's progress :) Lots of debugging code left in to make up for a less than ideal debugger
This commit is contained in:
@ -31,9 +31,10 @@ abstract class GaussianFactor extends Factor
|
||||
|
||||
public function &createVariableToMessageBinding(Variable &$variable)
|
||||
{
|
||||
$newDistribution = GaussianDistribution::fromPrecisionMean(0, 0);
|
||||
$binding = &parent::createVariableToMessageBindingWithMessage($variable,
|
||||
new Message(
|
||||
GaussianDistribution::fromPrecisionMean(0, 0),
|
||||
$newDistribution,
|
||||
sprintf("message from %s to %s", $this, $variable)));
|
||||
return $binding;
|
||||
}
|
||||
|
@ -39,9 +39,15 @@ class GaussianLikelihoodFactor extends GaussianFactor
|
||||
private function updateHelper(Message &$message1, Message &$message2,
|
||||
Variable &$variable1, Variable &$variable2)
|
||||
{
|
||||
$message1Value = clone $message1->getValue();
|
||||
$message2Value = clone $message2->getValue();
|
||||
// DEBUG
|
||||
$message1ValueTest = $message1->getValue();
|
||||
$variable1ValueTest = $variable1->getValue();
|
||||
$message2ValueTest = $message2->getValue();
|
||||
$variable2ValueTest = $variable2->getValue();
|
||||
|
||||
$message1Value = clone $message1->getValue();
|
||||
$message2Value = clone $message2->getValue();
|
||||
|
||||
$marginal1 = clone $variable1->getValue();
|
||||
$marginal2 = clone $variable2->getValue();
|
||||
|
||||
@ -67,7 +73,7 @@ class GaussianLikelihoodFactor extends GaussianFactor
|
||||
public function updateMessageIndex($messageIndex)
|
||||
{
|
||||
$messages = &$this->getMessages();
|
||||
$vars = &$this->getVariables();
|
||||
$vars = &$this->getVariables();
|
||||
|
||||
switch ($messageIndex)
|
||||
{
|
||||
|
@ -39,7 +39,8 @@ class GaussianPriorFactor extends GaussianFactor
|
||||
$oldMarginal->getPrecision() + $this->_newMessage->getPrecision() - $oldMessage->getValue()->getPrecision());
|
||||
|
||||
$variable->setValue($newMarginal);
|
||||
$message->setValue($this->_newMessage);
|
||||
$newMessage = &$this->_newMessage;
|
||||
$message->setValue($newMessage);
|
||||
return GaussianDistribution::subtract($oldMarginal, $newMarginal);
|
||||
}
|
||||
}
|
||||
|
@ -119,8 +119,13 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
|
||||
foreach ($variablesToSum as &$currentVariable)
|
||||
{
|
||||
$this->createVariableToMessageBinding($currentVariable);
|
||||
$localCurrentVariable = &$currentVariable;
|
||||
$this->createVariableToMessageBinding($localCurrentVariable);
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
$selfName = (string)$this;
|
||||
$selfVars = &$this->getVariables();
|
||||
}
|
||||
|
||||
public function getLogNormalization()
|
||||
@ -201,6 +206,8 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
|
||||
public function updateMessageIndex($messageIndex)
|
||||
{
|
||||
// DEBUG
|
||||
$currentFactorName = (string)$this;
|
||||
$allMessages = &$this->getMessages();
|
||||
$allVariables = &$this->getVariables();
|
||||
|
||||
@ -221,6 +228,12 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
$updatedVariables[] = &$allVariables[$indicesToUse[$i]];
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
foreach($allVariables as &$currentVariable)
|
||||
{
|
||||
$currentVarVal = &$currentVariable->getValue();
|
||||
}
|
||||
|
||||
return $this->updateHelper($this->_weights[$messageIndex],
|
||||
$this->_weightsSquared[$messageIndex],
|
||||
$updatedMessages,
|
||||
|
Reference in New Issue
Block a user