Tenative pass at getting prior layer working. Found out about division by zero and closure differences.

This commit is contained in:
Jeff Moser
2010-09-25 18:25:56 -04:00
parent 086d94865f
commit fa10d276d6
11 changed files with 36 additions and 23 deletions

View File

@ -31,7 +31,7 @@ abstract class GaussianFactor extends Factor
public function createVariableToMessageBinding(Variable &$variable)
{
return parent::createVariableToMessageBinding($variable,
return parent::createVariableToMessageBindingWithMessage($variable,
new Message(
GaussianDistribution::fromPrecisionMean(0, 0),
"message from {0} to {1}", $this));

View File

@ -23,11 +23,11 @@ class GaussianPriorFactor extends GaussianFactor
{
parent::__construct("Prior value going to {0}");
$this->_newMessage = new GaussianDistribution($mean, sqrt($variance));
$this->createVariableToMessageBinding($variable,
new Message(
GaussianDistribution::fromPrecisionMean(0, 0),
$newMessage = new Message(GaussianDistribution::fromPrecisionMean(0, 0),
"message from {0} to {1}",
$this, variable));
$this, $variable);
$this->createVariableToMessageBindingWithMessage($variable, $newMessage);
}
protected function updateMessageVariable(Message &$message, Variable &$variable)

View File

@ -35,11 +35,12 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
{
$currentTeamPlayerRating = $currentTeam->getRating($currentTeamPlayer);
$playerSkill = $this->createSkillOutputVariable($currentTeamPlayer);
$this->addLayerFactor($this->createPriorFactor($currentTeamPlayer, $currentTeamPlayerRating, $playerSkill));
$priorFactor = $this->createPriorFactor($currentTeamPlayer, $currentTeamPlayerRating, $playerSkill);
$this->addLayerFactor($priorFactor);
$currentTeamSkills[] = $playerSkill;
}
$outputVariablesGroups = $this->getOutputVariablesGroups();
$outputVariablesGroups = &$this->getOutputVariablesGroups();
$outputVariablesGroups[] = $currentTeamSkills;
}
}

View File

@ -52,7 +52,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
array_map(
function($likelihood)
{
return $this->scheduleStep("Skill to Perf step", $likelihood, 0);
return new ScheduleStep("Skill to Perf step", $likelihood, 0);
},
$this->getLocalFactors()),
"All skill to performance sending");

View File

@ -15,6 +15,7 @@ require_once(dirname(__FILE__) . '/Layers/PlayerSkillsToPerformancesLayer.php');
require_once(dirname(__FILE__) . '/Layers/TeamDifferencesComparisonLayer.php');
require_once(dirname(__FILE__) . '/Layers/TeamPerformancesToTeamPerformanceDifferencesLayer.php');
use Moserware\Numerics\GaussianDistribution;
use Moserware\Skills\GameInfo;
use Moserware\Skills\Rating;
use Moserware\Skills\FactorGraphs\FactorGraph;
@ -32,8 +33,7 @@ class TrueSkillFactorGraph extends FactorGraph
{
private $_gameInfo;
private $_layers;
private $_priorLayer;
private $_variableFactory;
private $_priorLayer;
public function __construct(GameInfo &$gameInfo, &$teams, array $teamRanks)
{
@ -44,8 +44,8 @@ class TrueSkillFactorGraph extends FactorGraph
{
return GaussianDistribution::fromPrecisionMean(0, 0);
});
$this->setVariableFactory($newFactory);
$this->_layers = array(
$this->_priorLayer,
new PlayerSkillsToPerformancesLayer($this),