2022-07-05 15:55:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace DNW\Skills\FactorGraphs;
|
2023-08-03 13:08:04 +00:00
|
|
|
use DNW\Skills\FactorGraphs\ScheduleSequence;
|
2022-07-05 15:55:47 +02:00
|
|
|
|
2010-09-18 11:11:44 -04:00
|
|
|
abstract class FactorGraphLayer
|
|
|
|
{
|
2023-08-02 12:39:42 +00:00
|
|
|
/**
|
|
|
|
* @var Factor[] $localFactors
|
|
|
|
*/
|
2023-08-01 14:02:12 +00:00
|
|
|
private array $localFactors = [];
|
2022-07-05 15:55:47 +02:00
|
|
|
|
2023-08-03 13:08:04 +00:00
|
|
|
/**
|
|
|
|
* @var array<int,array<int,object>>
|
|
|
|
*/
|
2023-08-01 14:02:12 +00:00
|
|
|
private array $outputVariablesGroups = [];
|
2023-08-03 13:08:04 +00:00
|
|
|
/**
|
|
|
|
* @var array<int,array<int,object>>
|
|
|
|
*/
|
2023-08-01 14:02:12 +00:00
|
|
|
private $inputVariablesGroups = [];
|
2022-07-05 15:55:47 +02:00
|
|
|
|
2023-08-01 14:02:12 +00:00
|
|
|
protected function __construct(private readonly FactorGraph $parentFactorGraph)
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-08-03 13:08:04 +00:00
|
|
|
/**
|
|
|
|
* @return array<int,array<int,object>>
|
|
|
|
*/
|
|
|
|
protected function getInputVariablesGroups(): array
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
2023-08-01 14:02:12 +00:00
|
|
|
return $this->inputVariablesGroups;
|
2010-09-18 11:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HACK
|
|
|
|
|
2023-08-02 10:10:57 +00:00
|
|
|
public function getParentFactorGraph(): FactorGraph
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
2023-08-01 14:02:12 +00:00
|
|
|
return $this->parentFactorGraph;
|
2010-09-18 11:11:44 -04:00
|
|
|
}
|
|
|
|
|
2016-05-24 16:31:21 +02:00
|
|
|
/**
|
|
|
|
* This reference is still needed
|
2023-08-03 13:08:04 +00:00
|
|
|
* @return array<int,array<int,object>>
|
2016-05-24 16:31:21 +02:00
|
|
|
*/
|
2023-08-01 12:26:38 +00:00
|
|
|
public function &getOutputVariablesGroups(): array
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
2023-08-01 14:02:12 +00:00
|
|
|
return $this->outputVariablesGroups;
|
2010-09-18 11:11:44 -04:00
|
|
|
}
|
|
|
|
|
2023-08-02 12:39:42 +00:00
|
|
|
/**
|
|
|
|
* @return Factor[]
|
|
|
|
*/
|
2023-08-01 12:26:38 +00:00
|
|
|
public function getLocalFactors(): array
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
2023-08-01 14:02:12 +00:00
|
|
|
return $this->localFactors;
|
2010-09-18 11:11:44 -04:00
|
|
|
}
|
|
|
|
|
2023-08-03 13:08:04 +00:00
|
|
|
/**
|
|
|
|
* @param array<int,array<int,object>> $value
|
|
|
|
*/
|
2023-08-01 12:26:38 +00:00
|
|
|
public function setInputVariablesGroups(array $value): void
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
2023-08-01 14:02:12 +00:00
|
|
|
$this->inputVariablesGroups = $value;
|
2010-09-18 11:11:44 -04:00
|
|
|
}
|
|
|
|
|
2023-08-03 13:08:04 +00:00
|
|
|
/**
|
|
|
|
* @param Schedule[] $itemsToSequence
|
|
|
|
*/
|
2023-08-01 12:26:38 +00:00
|
|
|
protected function scheduleSequence(array $itemsToSequence, string $name): ScheduleSequence
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
2010-09-27 22:26:28 -04:00
|
|
|
return new ScheduleSequence($name, $itemsToSequence);
|
2010-09-18 11:11:44 -04:00
|
|
|
}
|
|
|
|
|
2023-08-01 12:26:38 +00:00
|
|
|
protected function addLayerFactor(Factor $factor): void
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
2023-08-01 14:02:12 +00:00
|
|
|
$this->localFactors[] = $factor;
|
2010-09-18 11:11:44 -04:00
|
|
|
}
|
|
|
|
|
2023-08-02 14:14:10 +00:00
|
|
|
abstract public function buildLayer(): void;
|
2010-09-18 11:11:44 -04:00
|
|
|
|
2023-08-02 14:14:10 +00:00
|
|
|
public function createPriorSchedule(): ?ScheduleSequence
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-08-02 14:14:10 +00:00
|
|
|
public function createPosteriorSchedule(): ?ScheduleSequence
|
2010-09-18 11:11:44 -04:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2022-07-05 15:55:47 +02:00
|
|
|
}
|