mirror of
https://github.com/furyfire/trueskill.git
synced 2025-05-12 06:07:50 +00:00
String based "name" for Variable class removed for performance
This commit is contained in:
@ -6,9 +6,9 @@ namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
class KeyedVariable extends Variable
|
||||
{
|
||||
public function __construct(private readonly mixed $key, string $name, mixed $prior)
|
||||
public function __construct(private readonly mixed $key, mixed $prior)
|
||||
{
|
||||
parent::__construct($name, $prior);
|
||||
parent::__construct($prior);
|
||||
}
|
||||
|
||||
public function getKey(): mixed
|
||||
|
@ -6,15 +6,12 @@ namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
use DNW\Skills\Numerics\GaussianDistribution;
|
||||
|
||||
class Variable implements \Stringable
|
||||
class Variable
|
||||
{
|
||||
private readonly string $name;
|
||||
|
||||
private mixed $value;
|
||||
|
||||
public function __construct(string $name, private GaussianDistribution $prior)
|
||||
public function __construct(private GaussianDistribution $prior)
|
||||
{
|
||||
$this->name = 'Variable[' . $name . ']';
|
||||
$this->resetToPrior();
|
||||
}
|
||||
|
||||
@ -32,9 +29,4 @@ class Variable implements \Stringable
|
||||
{
|
||||
$this->value = $this->prior;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
@ -10,17 +10,17 @@ class VariableFactory
|
||||
{
|
||||
}
|
||||
|
||||
public function createBasicVariable(string $name): Variable
|
||||
public function createBasicVariable(): Variable
|
||||
{
|
||||
$initializer = $this->variablePriorInitializer;
|
||||
|
||||
return new Variable($name, $initializer());
|
||||
return new Variable($initializer());
|
||||
}
|
||||
|
||||
public function createKeyedVariable(mixed $key, string $name): KeyedVariable
|
||||
public function createKeyedVariable(mixed $key): KeyedVariable
|
||||
{
|
||||
$initializer = $this->variablePriorInitializer;
|
||||
|
||||
return new KeyedVariable($key, $name, $initializer());
|
||||
return new KeyedVariable($key, $initializer());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user