final class CompletionFrontier

Orders pending completions by their admissible lower bound and prunes equivalent more expensive states.

Methods§

public function __construct(
    private CompletionCosts $costs,
    private int $budget,
    private bool $minimum = true,
)

Binds one bounded search; callers cannot change the queue extraction mode.

Parameters

$costsCompletionCosts
$budgetint
$minimumbool
Test cases 3
Calls 3
  • new SplPriorityQueue line 32
  • method-call SplPriorityQueue::setExtractFlags() line 33
  • class-const SplPriorityQueue::EXTR_DATA() line 33
public function take(): ?CompletionState

Returns and removes the least estimated-cost state, or null when no feasible frontier remains.

Throws

LogicException When the priority queue does not return its configured data payload
Test cases 4
Called from 1
Calls 3
  • method-call SplPriorityQueue::isEmpty() line 43
  • method-call SplPriorityQueue::extract() line 46
  • new LogicException line 47
public function offer(
    list<Symbol> $symbols,
    array<string, int> $occurrences,
    bool $nonEmpty,
    int $spent,
    ?CompletionState $parent = null,
): void

Erases emitted terminals only after remembering whether they discharge the output requirement.

Parameters

$symbolslist<Symbol>
$occurrencesarray<string, int>
$nonEmptybool
$spentint
$parent?CompletionState
Test cases 3
Called from 5
Calls 8

Private surface 5§

Implementation details, listed for orientation only.

private SplPriorityQueue<array{int, int}, CompletionState> $queue
private array<string, int> $visited = []
private CompletionCosts $costs
private int $budget
private bool $minimum = true

Test cases 23§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 3
Other tests reaching this symbol 20

Relations§

Instantiated in 1
Method calls 6
Type declarations 1