Files
trueskill/src/FactorGraphs/Variable.php

37 lines
645 B
PHP
Raw Normal View History

<?php
2022-07-05 15:55:47 +02:00
2022-07-05 15:33:34 +02:00
namespace DNW\Skills\FactorGraphs;
2022-07-05 16:21:06 +02:00
class Variable implements \Stringable
{
2023-08-01 13:53:19 +00:00
private string $name;
2022-07-05 15:55:47 +02:00
2023-08-01 13:53:19 +00:00
private mixed $value;
2023-08-01 13:53:19 +00:00
public function __construct(string $name, private mixed $prior)
{
2023-08-01 13:53:19 +00:00
$this->name = 'Variable[' . $name . ']';
$this->resetToPrior();
}
2023-08-01 12:13:24 +00:00
public function getValue(): mixed
{
2023-08-01 13:53:19 +00:00
return $this->value;
}
2023-08-01 12:13:24 +00:00
public function setValue(mixed $value): void
{
2023-08-01 13:53:19 +00:00
$this->value = $value;
}
public function resetToPrior(): void
{
2023-08-01 13:53:19 +00:00
$this->value = $this->prior;
}
2022-07-05 16:21:06 +02:00
public function __toString(): string
{
2023-08-01 13:53:19 +00:00
return $this->name;
}
2022-07-05 15:55:47 +02:00
}