More type work

This commit is contained in:
Jens True 2023-08-03 09:13:19 +00:00
parent 50bd2b152a
commit 75829ddd60
6 changed files with 24 additions and 5 deletions

@ -44,6 +44,9 @@ abstract class SkillCalculator
return (bool)($this->supportedOptions & $option) == $option;
}
/**
* @param Team[] $teamsOfPlayerToRatings
*/
protected function validateTeamCountAndPlayersCountPerTeam(array $teamsOfPlayerToRatings): void
{
self::validateTeamCountAndPlayersCountPerTeamWithRanges($teamsOfPlayerToRatings, $this->totalTeamsAllowed, $this->playersPerTeamAllowed);

@ -17,8 +17,12 @@ class GaussianWeightedSumFactor extends GaussianFactor
{
private array $variableIndexOrdersForWeights = [];
// This following is used for convenience, for example, the first entry is [0, 1, 2]
// corresponding to v[0] = a1*v[1] + a2*v[2]
/**
* This following is used for convenience, for example, the first entry is [0, 1, 2]
* corresponding to v[0] = a1*v[1] + a2*v[2]
* @var array<int[]> $weights
*/
private array $weights = [];
private array $weightsSquared = [];

@ -5,6 +5,7 @@ namespace DNW\Skills\TrueSkill\Layers;
use DNW\Skills\FactorGraphs\ScheduleStep;
use DNW\Skills\FactorGraphs\ScheduleSequence;
use DNW\Skills\PartialPlay;
use DNW\Skills\Player;
use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
use DNW\Skills\FactorGraphs\Variable;
@ -39,6 +40,9 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
);
}
/**
* @param Team[] $teamMembers
*/
protected function createPlayerToTeamSumFactor(array $teamMembers, Variable $sumVariable): GaussianWeightedSumFactor
{
$weights = array_map(

@ -7,6 +7,7 @@ use DNW\Skills\FactorGraphs\Variable;
use DNW\Skills\FactorGraphs\KeyedVariable;
use DNW\Skills\Numerics\BasicMath;
use DNW\Skills\Rating;
use DNW\Skills\Team;
use DNW\Skills\TrueSkill\Factors\GaussianPriorFactor;
use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
use DNW\Skills\FactorGraphs\ScheduleSequence;
@ -15,6 +16,9 @@ use DNW\Skills\FactorGraphs\ScheduleSequence;
// start the process.
class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
{
/**
* @param Team[] $teams
*/
public function __construct(TrueSkillFactorGraph $parentGraph, private readonly array $teams)
{
parent::__construct($parentGraph);

@ -11,6 +11,9 @@ class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
{
private float $epsilon;
/**
* @param int[] $teamRanks
*/
public function __construct(TrueSkillFactorGraph $parentGraph, private readonly array $teamRanks)
{
parent::__construct($parentGraph);

@ -9,6 +9,7 @@ use DNW\Skills\FactorGraphs\VariableFactory;
use DNW\Skills\GameInfo;
use DNW\Skills\Numerics\GaussianDistribution;
use DNW\Skills\Rating;
use DNW\Skills\Team;
use DNW\Skills\RatingContainer;
use DNW\Skills\FactorGraphs\FactorGraphLayer;
use DNW\Skills\TrueSkill\Layers\IteratedTeamDifferencesInnerLayer;
@ -28,9 +29,9 @@ class TrueSkillFactorGraph extends FactorGraph
private PlayerPriorValuesToSkillsLayer $priorLayer;
/**
* @param GameInfo $gameInfo Parameters for the game.
* @param Team[] $teamsOfPlayerToRatings A mapping of team players and their ratings.
* @param int[] $teamRanks The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2).
* @param GameInfo $gameInfo Parameters for the game.
* @param Team[] $teams A mapping of team players and their ratings.
* @param int[] $teamRanks The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2).
*/
public function __construct(private readonly GameInfo $gameInfo, array $teams, array $teamRanks)
{