mirror of
https://github.com/furyfire/trueskill.git
synced 2025-05-12 06:07:50 +00:00
PHPMD reintroduced.
This commit is contained in:
@ -15,7 +15,7 @@ abstract class Factor
|
||||
*/
|
||||
private array $messages = [];
|
||||
|
||||
private readonly HashMap $messageToVariableBinding;
|
||||
private readonly HashMap $msgToVariableBinding;
|
||||
|
||||
/**
|
||||
* @var Variable[] $variables
|
||||
@ -24,7 +24,7 @@ abstract class Factor
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->messageToVariableBinding = new HashMap();
|
||||
$this->msgToVariableBinding = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@ abstract class Factor
|
||||
{
|
||||
Guard::argumentIsValidIndex($messageIndex, count($this->messages), 'messageIndex');
|
||||
$message = $this->messages[$messageIndex];
|
||||
$variable = $this->messageToVariableBinding->getValue($message);
|
||||
$variable = $this->msgToVariableBinding->getValue($message);
|
||||
|
||||
return $this->updateMessageVariable($message, $variable);
|
||||
}
|
||||
@ -85,7 +85,7 @@ abstract class Factor
|
||||
*/
|
||||
public function resetMarginals(): void
|
||||
{
|
||||
$allValues = $this->messageToVariableBinding->getAllValues();
|
||||
$allValues = $this->msgToVariableBinding->getAllValues();
|
||||
foreach ($allValues as $currentVariable) {
|
||||
$currentVariable->resetToPrior();
|
||||
}
|
||||
@ -101,7 +101,7 @@ abstract class Factor
|
||||
Guard::argumentIsValidIndex($messageIndex, count($this->messages), 'messageIndex');
|
||||
|
||||
$message = $this->messages[$messageIndex];
|
||||
$variable = $this->messageToVariableBinding->getValue($message);
|
||||
$variable = $this->msgToVariableBinding->getValue($message);
|
||||
|
||||
return $this->sendMessageVariable($message, $variable);
|
||||
}
|
||||
@ -112,7 +112,7 @@ abstract class Factor
|
||||
|
||||
protected function createVariableToMessageBindingWithMessage(Variable $variable, Message $message): Message
|
||||
{
|
||||
$this->messageToVariableBinding->setValue($message, $variable);
|
||||
$this->msgToVariableBinding->setValue($message, $variable);
|
||||
$this->messages[] = $message;
|
||||
$this->variables[] = $variable;
|
||||
|
||||
|
@ -17,7 +17,7 @@ abstract class FactorGraphLayer
|
||||
/**
|
||||
* @var array<int,array<int,Variable>>
|
||||
*/
|
||||
private array $outputVariablesGroups = [];
|
||||
private array $outputVarGroups = [];
|
||||
|
||||
/**
|
||||
* @var array<int,array<int,Variable>>
|
||||
@ -48,7 +48,7 @@ abstract class FactorGraphLayer
|
||||
*/
|
||||
public function &getOutputVariablesGroups(): array
|
||||
{
|
||||
return $this->outputVariablesGroups;
|
||||
return $this->outputVarGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,12 +26,12 @@ class FactorList
|
||||
$listCount = count($this->list);
|
||||
|
||||
for ($i = 0; $i < $listCount; ++$i) {
|
||||
$f = $this->list[$i];
|
||||
$factor = $this->list[$i];
|
||||
|
||||
$numberOfMessages = $f->getNumberOfMessages();
|
||||
$numberOfMessages = $factor->getNumberOfMessages();
|
||||
|
||||
for ($j = 0; $j < $numberOfMessages; ++$j) {
|
||||
$sumLogZ += $f->sendMessageIndex($j);
|
||||
$sumLogZ += $factor->sendMessageIndex($j);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,20 +6,20 @@ namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
class VariableFactory
|
||||
{
|
||||
public function __construct(private \Closure $variablePriorInitializer)
|
||||
public function __construct(private \Closure $varPriorInitializer)
|
||||
{
|
||||
}
|
||||
|
||||
public function createBasicVariable(): Variable
|
||||
{
|
||||
$initializer = $this->variablePriorInitializer;
|
||||
$initializer = $this->varPriorInitializer;
|
||||
|
||||
return new Variable($initializer());
|
||||
}
|
||||
|
||||
public function createKeyedVariable(mixed $key): KeyedVariable
|
||||
{
|
||||
$initializer = $this->variablePriorInitializer;
|
||||
$initializer = $this->varPriorInitializer;
|
||||
|
||||
return new KeyedVariable($key, $initializer());
|
||||
}
|
||||
|
Reference in New Issue
Block a user