Run the example
The resulting scores are approximately 1.873, 1.019, -0.014, -0.949, and -1.929.
The closest neighbors in this ordering receive more comparisons:
This verifies the mechanism against a deliberately simple population. It does
not establish ranking accuracy for noisy, heterogeneous, or cyclic preferences.
If the agent pool runs out first, the report says
population_exhausted.
Pair selection
assign(respondent_id=...) follows this
policy:
- While any pair has no completed comparison, prioritize the least-compared pairs, breaking ties by smallest absolute score gap and then pair ID.
- After this warm-up, prioritize the smallest score gap, breaking ties by completed pair count and then pair ID.
- After four consecutive score-driven responses, make the next selection an exploration comparison using the first ordering. Repeat this cycle.
explore_every=1 makes every selection an exploration selection. The pair ID
comes from the input item order, so equal-priority ties are deterministic. The
selection mode is bound with let before ranking candidates, avoiding repeated
coverage scans for every candidate.
The Machine then uses seeded_order to choose the pair’s display order, keyed by
the configured seed, trusted study ID, and respondent ID. It stores that order
with the pair and its selection mode. A retry retains the entire assignment,
even after other respondents change the scores. Randomized positions do not
guarantee an exactly balanced number of left/right appearances in a finite run.
Assignments consume neither comparison budget nor pair coverage. An abandoned
pair can therefore be offered to a later respondent. A resumed respondent keeps
their saved pair; previously recorded respondents are not asked again. A budget
smaller than the number of pairs can stop the study before warm-up finishes.
Score updates and atomic accounting
All item scores start at zero.compare(respondent_id=..., winner=...) accepts
one of the two assigned labels. Let w and l denote the winner’s and loser’s
scores immediately before the accepted answer. The update is:
logsumexp
and exp to avoid overflow at extreme score differences. Floating-point scores
conserve their total within numerical precision.
The update, pair count, total comparison count, exploration counter, and response
ledger commit atomically. Scores are updated against the current state at
acceptance, while pair selection and display order remain fixed from assignment.
The response ledger allows one answer per stable respondent ID. A same-ID,
same-choice retry is a no-op, including after completion. Changing that choice
is rejected with answer_changed. An unassigned respondent gets
pair_not_assigned; choosing another known item gets winner_not_in_pair.
Unknown labels fail the declared input schema. None of these invalid attempts
increments the budget or changes scores.
The budget counts accepted answers. New comparisons after exhaustion or an
explicit close are rejected with comparisons_closed. An explicit early close
does not claim that the budget was reached. Item labels must be distinct and
nonempty, budget and exploration interval positive integers, the seed nonempty
text, and the learning rate finite and in (0, 1].
Survey integration and resumption
study_id, stable respondent_id, and numeric
turn. The returned schedule runs whole interviews sequentially within each
study and checks the Machine’s completion condition before further questions.
Before the gate, the survey requests an assignment and reads its view. The gate
ends the interview when no new response is accepted. Otherwise the preference
question receives exactly:
compare
command. No additional respondent question is needed for routing.
Survey and schedule JSON transport preserves state identity, question bindings,
and ordering. Keep that identity to resume the same SQLite state. Tests cover
resuming an unanswered assignment with identical options and resuming an already
answered assignment without presenting the preference question again.
This is a sequential allocation policy. Concurrent answer commits cannot exceed
the budget, but overlapping interviews can receive stale selections or have an
answer rejected when another respondent uses the last place. Concurrent adaptive
selection needs a separate reservation and scheduling policy.
Tests and design findings
The focused tests compare mixed-winner streams against an independent selection/scoring reference, including abandoned assignments. They check exploration boundaries, conserved score totals, extreme score gaps, exact stopping, retries, concurrent budget bounds, independent scopes, SQLite restart, and fresh-process replay without the authoring module. End-to-end tests reverse the supplied agent list to check schedule ordering and inspect the actual choices received by scripted agents. Those choices must also matchrow.get_question_options("preference") and the
saved assignment. The Runner preserves their order and the observed read/version
in per-question presentation metadata,
including after Results serialization. This closes the reporting gap first
exposed by this example without changing Survey navigation.
This application exposes two further boundaries:
- Decision policy versus statistical uncertainty. Similar scores are a selection heuristic. They are not confidence intervals or evidence that a pair is poorly measured. The fixed budget does not claim convergence. Ties, respondent-specific tastes, and preference cycles need explicit models.
- Candidate-set growth. The definition enumerates all unordered pairs, so candidate storage grows quadratically with the number of items. A much larger catalog should probe candidate generation, evaluation budgets, and bounded history rather than assuming this five-item construction scales unchanged.
python -m edsl.examples.shared_state.machine_primitives.profile_corpus. They are not portable
cost guarantees or a claim of bit-identical floating-point scoring across hosts.
The local demonstration establishes neither live-model preference validity nor
hosted human-survey deployment support. Remaining design work is tracked in
issue #2665.