mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-19 20:34:28 +00:00
More type work
This commit is contained in:
@ -7,9 +7,12 @@ namespace DNW\Skills\FactorGraphs;
|
||||
*/
|
||||
class FactorList
|
||||
{
|
||||
/**
|
||||
* @var Factor[] $list
|
||||
*/
|
||||
private array $list = [];
|
||||
|
||||
public function getLogNormalization()
|
||||
public function getLogNormalization(): float
|
||||
{
|
||||
$list = $this->list;
|
||||
foreach ($list as &$currentFactor) {
|
||||
@ -39,12 +42,12 @@ class FactorList
|
||||
return $sumLogZ + $sumLogS;
|
||||
}
|
||||
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->list);
|
||||
}
|
||||
|
||||
public function addFactor(Factor $factor)
|
||||
public function addFactor(Factor $factor): Factor
|
||||
{
|
||||
$this->list[] = $factor;
|
||||
|
||||
|
@ -8,10 +8,10 @@ abstract class Schedule implements \Stringable
|
||||
{
|
||||
}
|
||||
|
||||
abstract public function visit(int $depth = -1, int $maxDepth = 0);
|
||||
abstract public function visit(int $depth = -1, int $maxDepth = 0): float;
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string) $this->name;
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ class ScheduleLoop extends Schedule
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
public function visit(int $depth = -1, int $maxDepth = 0)
|
||||
public function visit(int $depth = -1, int $maxDepth = 0): float
|
||||
{
|
||||
$totalIterations = 1;
|
||||
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
|
||||
|
@ -4,12 +4,12 @@ namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
class ScheduleSequence extends Schedule
|
||||
{
|
||||
public function __construct($name, private readonly array $schedules)
|
||||
public function __construct(string $name, private readonly array $schedules)
|
||||
{
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
public function visit($depth = -1, $maxDepth = 0)
|
||||
public function visit(int $depth = -1, int $maxDepth = 0): float
|
||||
{
|
||||
$maxDelta = 0;
|
||||
|
||||
|
@ -4,12 +4,12 @@ namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
class ScheduleStep extends Schedule
|
||||
{
|
||||
public function __construct($name, private readonly Factor $factor, private $index)
|
||||
public function __construct(string $name, private readonly Factor $factor, private $index)
|
||||
{
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
public function visit(int $depth = -1, int $maxDepth = 0)
|
||||
public function visit(int $depth = -1, int $maxDepth = 0): float
|
||||
{
|
||||
$currentFactor = $this->factor;
|
||||
|
||||
|
Reference in New Issue
Block a user