pub trait GenomePrior:
Clone
+ Send
+ Sync
+ 'static {
type Genome: TraceGenome;
// Required method
fn model(&self) -> Model<Self::Genome>;
// Provided methods
fn trace_of(&self, genome: &Self::Genome) -> Trace { ... }
fn validate(&self, genome: &Self::Genome) -> Result<(), GenomeError> { ... }
}Expand description
A prior distribution over genomes, expressed as a probabilistic program.
The program must sample the genome’s canonical trace sites (the same
addresses TraceGenome::to_trace writes — gene#i, bit#i, perm#i,
…) and return the assembled genome. Anything expressible as a fugue
Model is a valid prior: correlated coordinates, hierarchical scales,
variable-length genomes (a length site followed by that many coordinate
sites — fugue’s MH treats the resulting births/deaths as reversible-jump
moves with no extra code here).
Required Associated Types§
Sourcetype Genome: TraceGenome
type Genome: TraceGenome
The genome type this prior generates.
Required Methods§
Provided Methods§
Sourcefn trace_of(&self, genome: &Self::Genome) -> Trace
fn trace_of(&self, genome: &Self::Genome) -> Trace
Encode a genome as a trace under this prior’s address scheme — the
inverse direction of running Self::model. The default delegates to
the genome’s canonical TraceGenome::to_trace encoding, which is
correct whenever the prior samples exactly the canonical sites (all the
vector priors here). Priors with their own generative scheme — e.g.
ArithmeticGrammarPrior’s
tree-path grammar — override this so that scoring, weighted traces, and
chain warm-starts work for any genome the prior can express.
Sourcefn validate(&self, genome: &Self::Genome) -> Result<(), GenomeError>
fn validate(&self, genome: &Self::Genome) -> Result<(), GenomeError>
Check that genome has the shape this prior generates, before its
encoding is replayed through a program. The vector priors here report
GenomeError::DimensionMismatch for a genome whose length differs
from the prior’s dimension — a shorter one would leave the program
visiting sites the encoding lacks, a longer one would carry sites the
program never visits (previously replay panicked on the former and
silently truncated the latter). The default accepts everything; priors
whose trace_of is total over their genome type (the grammar prior)
need nothing more, because structural mismatches are caught by the
replay itself in EvolutionModel::score.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".