rugnux: offer the standing rotation cell's index-2 sub-lattices as hypotheses

The first pass can only choose among the cells the FFT builds, and two
lattices seen together - a twin domain, or a second crystal whose reciprocal
lattice shares an index-2 sub-lattice with this one's - build the cell that
contains both, twice the volume of either. That cell indexes both domains'
spots and wins every comparison of FFT candidates; the true cell is never
offered, so nothing downstream can pick it.

Each first pass now scores the standing cell's seven index-2 sub-lattices
(same orientation and geometry) on the validation frames. The frame count
only nominates (a sub-lattice must index a majority of the frames and no
fewer than the standing cell); the decision is the pooled-spot comparison
already used between a cell and its axis harmonic (ValidationEvidencePrefers,
each lattice against its own wrong-spindle-angle null). A real superstructure
keeps its cell there because its added class holds reflections; a two-domain
union cell loses because it must place each domain's spots twice as finely
with an orientation fitted to both.

9rci (P1, deposited ~36/39/101 A): from rc173 on rugnux had merged a c-doubled
cell (b+2c, ~199 A; R-free vs model 0.57). The deposited cell was reached only
between 0f9f3a and the part-B commit (5b9144410), because pass 1's orthorhombic-
constrained post-refinement walked the tilt to -0.46 deg and the whole-sweep
re-index happened to land on the short cell there. Part B did not cause the
wrong choice; it removed that accident (rc175 with --prepass-fraction 1 still
gives the doubled cell). Now, on the early range at the file's geometry, the
(0,1/2,1/2) sub-lattice indexes 57/60 frames against 41/60 and puts 1915/5659
pooled spots on itself against 1191 (30 and 35 by chance): adopted. Result:
cell 35.90 39.17 100.78 98.6 90.3 89.9, R-free (model) 0.270, d 1.69 A,
CC1/2 0.988 (was 199 A cell, 0.569, 1.81 A, 0.952).

Battery against rc175 7c9a6c (GPU): p.mtz md5-identical on 5nw5, 8v4o, 5ky6,
insu_I_x06da_low_isa, nothing_1, nothing_2, myob_x06da_powder_2, 7atg, 9qw8,
5reo, 6ze4, 9min, 8v2t, lyso_x06da_ref, insu_H_x06da_twin, myob_x06da_split;
only 9rci changes (now the deposited cell; the verdict read pass before only because P1 matched P1). Cost: tens of ms per first pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVmAWnzCmRKAXVUCdc4iNi
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-08 21:29:25 +02:00
1 parent 7a3bf6c5cb
commit 533969cb7b
1 file changed
+73
+73
View File
@@ -2132,6 +2132,79 @@ bool Rugnux::FirstPassRotationIndexing(PipelineLocals &p) {
}
}
// Sub-lattice hypothesis: the standing cell's seven index-2 sub-lattices, in its own
// orientation and geometry, each scored on the validation frames.
//
// The FFT can only offer the cells its peaks build, and two lattices seen together - a twin
// domain or a second crystal whose reciprocal lattice shares an index-2 sub-lattice with
// this one's - build the lattice that contains them both: a cell twice the size of either,
// which indexes both crystals' spots and so wins every comparison of candidates the FFT
// returns. Where the true cell is then never offered, nothing downstream can choose it.
// Offering it costs seven frame counts.
//
// The frame count only nominates: a coarser lattice asks less accuracy of every spot, so a
// sub-lattice of the true cell can index as many frames as the cell itself, or a few more
// where the cell's own score is depressed. What decides is the comparison this pass already
// makes between a cell and its axis harmonic: the share of the validation frames' pooled
// spots each puts on itself over and above what a wrong spindle angle puts there, each
// against its own null (ValidationEvidencePrefers). A real superstructure keeps its cell on
// that count, because the class it adds holds reflections; a cell built out of two crystals
// loses it, because it has to place every spot of the one it describes twice as accurately
// with an orientation fitted to both. The nominee must also index a majority of the frames,
// the bar the false-promotion test above asks of a cell that "works", and no fewer frames
// than the standing cell: a standing cell that indexes almost nothing is not this crystal's
// lattice, its sub-lattices are not hypotheses about it, and the rescues below are what
// such a run needs.
if (!cancelled_ && best.result.has_value() && best.score > 0) {
const CrystalLattice prim = best.result->lattice
.ToPrimitive(best.result->search_result.centering);
const Coord A = prim.Vec0(), B = prim.Vec1(), C = prim.Vec2();
std::optional<FirstPass> sub_best;
std::string counts;
for (int u = 0; u < 2; u++)
for (int v = 0; v < 2; v++)
for (int w = 0; w < 2; w++) {
if (u + v + w == 0 || cancelled_)
continue;
const Coord t = (A * static_cast<float>(u) + B * static_cast<float>(v)
+ C * static_cast<float>(w)) / 2.0f;
const CrystalLattice sub = (w ? CrystalLattice(A, B, t)
: v ? CrystalLattice(A, t, C)
: CrystalLattice(t, B, C)).NiggliReduce();
RotationIndexerResult cand = *best.result;
cand.lattice = sub;
cand.search_result = LatticeSearchResult{};
cand.search_result.primitive_reduced = sub;
cand.search_result.conventional = sub;
cand.unconstrained.reset();
cand.extra_lattices.clear();
const int score = count_indexed(*indexer, cand);
counts += fmt::format(" ({},{},{}) {}", u, v, w, score);
if (!sub_best || score > sub_best->score)
sub_best = FirstPass{std::move(cand), score,
fmt::format("{} (sub-lattice {}{}{})", best.name, u, v, w),
std::abs(sub.CalcVolume())};
}
bool adopt = false;
std::string verdict = " - none indexes a majority of the frames and as many as the standing cell";
if (sub_best && sub_best->score >= best.score
&& sub_best->score > static_cast<int>(validation.size()) / 2) {
const PooledEvidence at_standing = pooled_evidence(*indexer, *best.result);
const PooledEvidence at_sub = pooled_evidence(*indexer, *sub_best->result);
adopt = ValidationEvidencePrefers(at_standing, at_sub);
verdict = fmt::format(" - the best puts {}/{} pooled spots on itself ({} by chance) against "
"the standing cell's {}/{} ({}), {}",
at_sub.on_lattice, at_sub.spots, at_sub.by_chance,
at_standing.on_lattice, at_standing.spots, at_standing.by_chance,
adopt ? "adopting it" : "keeping the standing cell");
}
logger.Info("Sub-lattice hypothesis: the standing cell ({:.0f} A^3) indexes {}/{} validation "
"frames; its index-2 sub-lattices (half-translation u,v,w):{}{}",
best.vol, best.score, static_cast<int>(validation.size()), counts, verdict);
if (adopt)
best = std::move(*sub_best);
}
// A lattice that indexes almost none of the validation frames is not this crystal's lattice.
// Forcing it anyway integrates every image against it; the few partials that survive yield no
// fulls in the 3D combine, and the run then dies inside the merge complaining about resolution -