mixle.task.propose module

Budgeted propose-verify-retrain loop over a discrete structured design space.

This module handles structured and discrete candidates such as short protein-like sequences or compact program sketches. It uses a proposal distribution over short fixed-length symbol sequences, with one CategoricalDistribution per position, then samples K candidates per round, verifies every one against a VerifiableOracle, keeps the verifiably-better ones, and refits the proposal on the winners (reweighted MLE through the shared mixle.inference.optimize() EM driver – no hand-rolled counting) for a fixed number of rounds under a hard oracle-call budget (k_per_round * rounds). Every candidate tried is retained in the round log, dead ends included; only keep_frac of each round feeds the refit.

Same “no verifiable objective, no optimization” precondition as optimize_under_oracle: oracle=None refuses immediately rather than fabricating a candidate.

class SequenceProposal(alphabet, length, pseudo_count=1.0, position_models=<factory>)[source]

Bases: object

A position-independent categorical proposal over fixed-length sequences from alphabet.

Parameters:
  • alphabet (tuple[Any, ...])

  • length (int)

  • pseudo_count (float)

  • position_models (list[CategoricalDistribution])

sample(k, rng)[source]

Draw k i.i.d. sequences (each length symbols) from the current proposal.

Parameters:
Return type:

list[tuple]

refit(sequences, weights)[source]

Reweighted MLE: refit each position’s categorical on sequences, replicated in that position’s training multiset proportional to weights, through the shared optimize EM driver – never a hand-rolled frequency count.

Parameters:
Return type:

SequenceProposal

class RoundLog(round_index, candidates, results, kept_indices)[source]

Bases: object

One round’s full record: every candidate tried and its oracle result, plus which were kept.

Parameters:
class ProposeVerifyResult(proposal, rounds=<factory>, best_candidate=None, best_result=None)[source]

Bases: object

The full receipted history of a propose-verify-retrain run.

Parameters:
  • proposal (SequenceProposal)

  • rounds (list[RoundLog])

  • best_candidate (tuple | None)

  • best_result (OracleResult | None)

property oracle_calls: int

Return the total number of candidate evaluations sent to the oracle.

all_candidates()[source]

Every candidate tried across every round, in order – dead ends included, none dropped.

Return type:

list[tuple[tuple, OracleResult]]

propose_verify_retrain(proposal, oracle, *, k_per_round, rounds, keep_frac=0.25, seed=None)[source]

Sample, verify, keep, and refit under a fixed oracle-call budget.

Each round draws k_per_round candidates from proposal, verifies every one with oracle, keeps the top keep_frac by oracle score, and refits proposal on the kept winners weighted by score. The exact oracle-call budget is k_per_round * rounds. oracle=None raises immediately because this routine requires a verifiable objective rather than fabricating one.

Parameters:
  • proposal (SequenceProposal)

  • oracle (VerifiableOracle | None)

  • k_per_round (int)

  • rounds (int)

  • keep_frac (float)

  • seed (int | None)

Return type:

ProposeVerifyResult