heuristics

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph cluster_abc { graph [label=abc]; node [color=1]; "abc.ABC" [URL="https://docs.python.org/3.10/library/abc.html#abc.ABC", label=ABC, target=_top]; } subgraph "cluster_abjadext.nauert.heuristics" { graph [label="abjadext.nauert.heuristics"]; node [color=2]; "abjadext.nauert.heuristics.DistanceHeuristic" [URL="../api/abjadext/nauert/heuristics.html#abjadext.nauert.heuristics.DistanceHeuristic", color=black, fontcolor=white, label="Distance\nHeuristic", target=_top]; "abjadext.nauert.heuristics.Heuristic" [URL="../api/abjadext/nauert/heuristics.html#abjadext.nauert.heuristics.Heuristic", color=black, fontcolor=white, label=Heuristic, shape=oval, style="bold, filled", target=_top]; "abjadext.nauert.heuristics.Heuristic" -> "abjadext.nauert.heuristics.DistanceHeuristic"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } "abc.ABC" -> "abjadext.nauert.heuristics.Heuristic"; "builtins.object" -> "abc.ABC"; }


Abstract Classes

Heuristic

Abstract heuristic.

abstract class abjadext.nauert.heuristics.Heuristic[source]

Abstract heuristic.

Heuristics rank Q-grids according to the criteria they encapsulate.

They provide the means by which the quantizer selects a single QGrid from all computed QGrids for any given QTargetBeat to represent that beat.


Attributes Summary

__call__

Calls heuristic.


Special methods

overridden __call__(q_target_beats)[source]

Calls heuristic.

Return type:

tuple[QTargetBeat, ...]


Classes

DistanceHeuristic

Distance heuristic.

class abjadext.nauert.heuristics.DistanceHeuristic[source]

Distance heuristic.

Considers only the computed distance of each QGrid and the number of leaves of that QGrid when choosing the optimal QGrid for a given QTargetBeat.

The QGrid with the smallest distance and fewest number of leaves will be selected.

>>> durations = [1000] * 8
>>> pitches = range(8)
>>> q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
...     tuple(zip(durations, pitches))
... )
>>> heuristic = nauert.DistanceHeuristic()
>>> result = nauert.quantize(q_event_sequence, heuristic=heuristic)
>>> abjad.show(result)  

Special methods

(Heuristic).__call__(q_target_beats)

Calls heuristic.

Return type:

tuple[QTargetBeat, ...]