mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-19 12:24:28 +00:00
Some minor documentation cleanup (e.g. converted C# comments to PHPDocumentor comments)
This commit is contained in:
@ -30,9 +30,9 @@ use Moserware\Skills\SkillCalculator;
|
||||
use Moserware\Skills\SkillCalculatorSupportedOptions;
|
||||
use Moserware\Skills\TeamsRange;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates TrueSkill using a full factor graph.
|
||||
/// </summary>
|
||||
/**
|
||||
* Calculates TrueSkill using a full factor graph.
|
||||
*/
|
||||
class FactorGraphTrueSkillCalculator extends SkillCalculator
|
||||
{
|
||||
public function __construct()
|
||||
|
@ -19,7 +19,9 @@ abstract class GaussianFactor extends Factor
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
/// Sends the factor-graph message with and returns the log-normalization constant
|
||||
/**
|
||||
* Sends the factor-graph message with and returns the log-normalization constant.
|
||||
*/
|
||||
protected function sendMessageVariable(Message &$message, Variable &$variable)
|
||||
{
|
||||
$marginal = &$variable->getValue();
|
||||
|
@ -1,21 +1,22 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../TruncatedGaussianCorrectionFunctions.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/../TruncatedGaussianCorrectionFunctions.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\TrueSkill\TruncatedGaussianCorrectionFunctions;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
/// <summary>
|
||||
/// Factor representing a team difference that has exceeded the draw margin.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Factor representing a team difference that has exceeded the draw margin.
|
||||
*
|
||||
* See the accompanying math paper for more details.
|
||||
*/
|
||||
class GaussianGreaterThanFactor extends GaussianFactor
|
||||
{
|
||||
private $_epsilon;
|
||||
@ -72,12 +73,12 @@ class GaussianGreaterThanFactor extends GaussianFactor
|
||||
GaussianDistribution::multiply($oldMessage, $newMarginal),
|
||||
$oldMarginal);
|
||||
|
||||
/// Update the message and marginal
|
||||
// Update the message and marginal
|
||||
$message->setValue($newMessage);
|
||||
|
||||
$variable->setValue($newMarginal);
|
||||
|
||||
/// Return the difference in the new marginal
|
||||
// Return the difference in the new marginal
|
||||
return GaussianDistribution::subtract($newMarginal, $oldMarginal);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
/// <summary>
|
||||
/// Connects two variables and adds uncertainty.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Connects two variables and adds uncertainty.
|
||||
*
|
||||
* See the accompanying math paper for more details.
|
||||
*/
|
||||
class GaussianLikelihoodFactor extends GaussianFactor
|
||||
{
|
||||
private $_precision;
|
||||
@ -55,12 +56,12 @@ class GaussianLikelihoodFactor extends GaussianFactor
|
||||
|
||||
$newMarginal = GaussianDistribution::multiply($oldMarginalWithoutMessage, $newMessage);
|
||||
|
||||
/// Update the message and marginal
|
||||
// Update the message and marginal
|
||||
|
||||
$message1->setValue($newMessage);
|
||||
$variable1->setValue($newMarginal);
|
||||
|
||||
/// Return the difference in the new marginal
|
||||
// Return the difference in the new marginal
|
||||
return GaussianDistribution::subtract($newMarginal, $marginal1);
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Supplies the factor graph with prior information.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Supplies the factor graph with prior information.
|
||||
*
|
||||
* See the accompanying math paper for more details.
|
||||
*/
|
||||
class GaussianPriorFactor extends GaussianFactor
|
||||
{
|
||||
private $_newMessage;
|
||||
|
@ -1,22 +1,23 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../../Guard.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/BasicMath.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\Guard;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
/// <summary>
|
||||
/// Factor that sums together multiple Gaussians.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Factor that sums together multiple Gaussians.
|
||||
*
|
||||
* See the accompanying math paper for more details.s
|
||||
*/
|
||||
class GaussianWeightedSumFactor extends GaussianFactor
|
||||
{
|
||||
private $_variableIndexOrdersForWeights = array();
|
||||
@ -189,12 +190,12 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
|
||||
$newMarginal = GaussianDistribution::multiply($oldMarginalWithoutMessage, $newMessage);
|
||||
|
||||
/// Update the message and marginal
|
||||
// Update the message and marginal
|
||||
|
||||
$messages[0]->setValue($newMessage);
|
||||
$variables[0]->setValue($newMarginal);
|
||||
|
||||
/// Return the difference in the new marginal
|
||||
// Return the difference in the new marginal
|
||||
$finalDiff = GaussianDistribution::subtract($newMarginal, $marginal0);
|
||||
return $finalDiff;
|
||||
}
|
||||
|
@ -1,21 +1,22 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../TruncatedGaussianCorrectionFunctions.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\TrueSkill\TruncatedGaussianCorrectionFunctions;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
/// <summary>
|
||||
/// Factor representing a team difference that has not exceeded the draw margin.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Factor representing a team difference that has not exceeded the draw margin.
|
||||
*
|
||||
* See the accompanying math paper for more details.
|
||||
*/
|
||||
class GaussianWithinFactor extends GaussianFactor
|
||||
{
|
||||
private $_epsilon;
|
||||
@ -71,11 +72,11 @@ class GaussianWithinFactor extends GaussianFactor
|
||||
GaussianDistribution::multiply($oldMessage, $newMarginal),
|
||||
$oldMarginal);
|
||||
|
||||
/// Update the message and marginal
|
||||
// Update the message and marginal
|
||||
$message->setValue($newMessage);
|
||||
$variable->setValue($newMarginal);
|
||||
|
||||
/// Return the difference in the new marginal
|
||||
// Return the difference in the new marginal
|
||||
return GaussianDistribution::subtract($newMarginal, $oldMarginal);
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
||||
}
|
||||
|
||||
public function createPriorSchedule()
|
||||
{
|
||||
// BLOG about $loop
|
||||
{
|
||||
switch (count($this->getInputVariablesGroups()))
|
||||
{
|
||||
case 0:
|
||||
|
@ -73,8 +73,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
|
||||
}
|
||||
|
||||
public function createPosteriorSchedule()
|
||||
{
|
||||
// BLOG
|
||||
{
|
||||
$allFactors = array();
|
||||
$localFactors = &$this->getLocalFactors();
|
||||
foreach($localFactors as &$currentFactor)
|
||||
|
@ -9,14 +9,14 @@ class TruncatedGaussianCorrectionFunctions
|
||||
{
|
||||
// These functions from the bottom of page 4 of the TrueSkill paper.
|
||||
|
||||
/// <summary>
|
||||
/// The "V" function where the team performance difference is greater than the draw margin.
|
||||
/// </summary>
|
||||
/// <remarks>In the reference F# implementation, this is referred to as "the additive
|
||||
/// correction of a single-sided truncated Gaussian with unit variance."</remarks>
|
||||
/// <param name="teamPerformanceDifference"></param>
|
||||
/// <param name="drawMargin">In the paper, it's referred to as just "ε".</param>
|
||||
/// <returns></returns>
|
||||
/**
|
||||
* The "V" function where the team performance difference is greater than the draw margin.
|
||||
*
|
||||
* In the reference F# implementation, this is referred to as "the additive
|
||||
* correction of a single-sided truncated Gaussian with unit variance."
|
||||
*
|
||||
* @param number $drawMargin In the paper, it's referred to as just "ε".
|
||||
*/
|
||||
public static function vExceedsMarginScaled($teamPerformanceDifference, $drawMargin, $c)
|
||||
{
|
||||
return self::vExceedsMargin($teamPerformanceDifference/$c, $drawMargin/$c);
|
||||
@ -34,15 +34,13 @@ class TruncatedGaussianCorrectionFunctions
|
||||
return GaussianDistribution::at($teamPerformanceDifference - $drawMargin)/$denominator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "W" function where the team performance difference is greater than the draw margin.
|
||||
/// </summary>
|
||||
/// <remarks>In the reference F# implementation, this is referred to as "the multiplicative
|
||||
/// correction of a single-sided truncated Gaussian with unit variance."</remarks>
|
||||
/// <param name="teamPerformanceDifference"></param>
|
||||
/// <param name="drawMargin"></param>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
/**
|
||||
* The "W" function where the team performance difference is greater than the draw margin.
|
||||
*
|
||||
* In the reference F# implementation, this is referred to as "the multiplicative
|
||||
* correction of a single-sided truncated Gaussian with unit variance."
|
||||
*/
|
||||
|
||||
public static function wExceedsMarginScaled($teamPerformanceDifference, $drawMargin, $c)
|
||||
{
|
||||
return self::wExceedsMargin($teamPerformanceDifference/$c, $drawMargin/$c);
|
||||
|
@ -30,13 +30,13 @@ use Moserware\Skills\SkillCalculatorSupportedOptions;
|
||||
use Moserware\Skills\PlayersRange;
|
||||
use Moserware\Skills\TeamsRange;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the new ratings for only two players.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When you only have two players, a lot of the math simplifies. The main purpose of this class
|
||||
/// is to show the bare minimum of what a TrueSkill implementation should have.
|
||||
/// </remarks>
|
||||
/**
|
||||
* Calculates the new ratings for only two players.
|
||||
*
|
||||
* When you only have two players, a lot of the math simplifies. The main purpose of this class
|
||||
* is to show the bare minimum of what a TrueSkill implementation should have.
|
||||
*/
|
||||
|
||||
class TwoPlayerTrueSkillCalculator extends SkillCalculator
|
||||
{
|
||||
public function __construct()
|
||||
@ -139,7 +139,9 @@ class TwoPlayerTrueSkillCalculator extends SkillCalculator
|
||||
return new Rating($newMean, $newStdDev);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function calculateMatchQuality(GameInfo &$gameInfo, array &$teams)
|
||||
{
|
||||
Guard::argumentNotNull($gameInfo, "gameInfo");
|
||||
|
@ -34,12 +34,11 @@ use Moserware\Skills\TeamsRange;
|
||||
|
||||
use Moserware\Skills\Team;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates new ratings for only two teams where each team has 1 or more players.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When you only have two teams, the math is still simple: no factor graphs are used yet.
|
||||
/// </remarks>
|
||||
/**
|
||||
* Calculates new ratings for only two teams where each team has 1 or more players.
|
||||
*
|
||||
* When you only have two teams, the math is still simple: no factor graphs are used yet.
|
||||
*/
|
||||
class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
{
|
||||
public function __construct()
|
||||
@ -165,7 +164,9 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function calculateMatchQuality(GameInfo &$gameInfo,
|
||||
array &$teams)
|
||||
{
|
||||
|
Reference in New Issue
Block a user