mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Fixed some debugging messages on factors
This commit is contained in:
@ -3,14 +3,12 @@ namespace Moserware\Skills\FactorGraphs;
|
||||
|
||||
class Message
|
||||
{
|
||||
private $_nameFormat;
|
||||
private $_nameFormatArgs;
|
||||
private $_name;
|
||||
private $_value;
|
||||
|
||||
public function __construct($value = null, $nameFormat = null, $args = null)
|
||||
public function __construct($value = null, $name = null)
|
||||
{
|
||||
$this->_nameFormat = $nameFormat;
|
||||
$this->_nameFormatArgs = $args;
|
||||
$this->_name = $name;
|
||||
$this->_value = $value;
|
||||
}
|
||||
|
||||
@ -21,7 +19,7 @@ class Message
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->_nameFormat; //return (_NameFormat == null) ? base.ToString() : String.Format(_NameFormat, _NameFormatArgs);
|
||||
return $this->_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ abstract class GaussianFactor extends Factor
|
||||
return parent::createVariableToMessageBindingWithMessage($variable,
|
||||
new Message(
|
||||
GaussianDistribution::fromPrecisionMean(0, 0),
|
||||
"message from {0} to {1}", $this));
|
||||
sprintf("message from %s to %s", $this, $variable)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class GaussianGreaterThanFactor extends GaussianFactor
|
||||
|
||||
public function __construct($epsilon, Variable &$variable)
|
||||
{
|
||||
parent::__construct("{0} > {1:0.000}");
|
||||
parent::__construct(\sprintf("%s > %.2f", $variable, $epsilon));
|
||||
$this->_epsilon = $epsilon;
|
||||
$this->createVariableToMessageBinding($variable);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class GaussianLikelihoodFactor extends GaussianFactor
|
||||
|
||||
public function __construct($betaSquared, Variable &$variable1, Variable &$variable2)
|
||||
{
|
||||
parent::__construct("Likelihood of {0} going to {1}");
|
||||
parent::__construct(sprintf("Likelihood of %s going to %s", $variable2, $variable1));
|
||||
$this->_precision = 1.0/$betaSquared;
|
||||
$this->createVariableToMessageBinding($variable1);
|
||||
$this->createVariableToMessageBinding($variable2);
|
||||
|
@ -21,11 +21,10 @@ class GaussianPriorFactor extends GaussianFactor
|
||||
|
||||
public function __construct($mean, $variance, Variable &$variable)
|
||||
{
|
||||
parent::__construct("Prior value going to {0}");
|
||||
parent::__construct(sprintf("Prior value going to %s", $variable));
|
||||
$this->_newMessage = new GaussianDistribution($mean, sqrt($variance));
|
||||
$newMessage = new Message(GaussianDistribution::fromPrecisionMean(0, 0),
|
||||
"message from {0} to {1}",
|
||||
$this, $variable);
|
||||
sprintf("message from %s to %s", $this, $variable));
|
||||
|
||||
$this->createVariableToMessageBindingWithMessage($variable, $newMessage);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ class GaussianWithinFactor extends GaussianFactor
|
||||
|
||||
public function __construct($epsilon, Variable &$variable)
|
||||
{
|
||||
parent::__construct(sprintf("%s <= %.2f", $variable, $epsilon));
|
||||
$this->_epsilon = $epsilon;
|
||||
$this->createVariableToMessageBinding($variable);
|
||||
}
|
||||
|
Reference in New Issue
Block a user