Refinement: a Refit's solvent grid starts around where the context's last one ended
Logic change (deterministic), kept on evidence. Every Refit searched the whole k_sol/b_sol box - an 88-point coarse pass of plain least squares, then the robust fine pass around its winner. ModelScaleBox (and ModelScaleGPUPool::Fit / ModelScaleGPU::FitSolvent) take an optional start; with one, the coarse pass is skipped and the fine pass is laid around it. Refinement passes the grid winner of the context's previous Refit (before MoveOverallB moves the overall B into b_sol); it travels with a trial's fit, and a trial's first Refit without one (Context::ForgetStarts, which also clears the likelihood's D start) searches the whole box, so a trial still depends on nothing its slot ran before (side by side = one at a time, md5). Evidence (GPU, -N 8): full refinement of the 14 parity sets from their placed models - 12 refined CIFs identical (md5), 9ig7 and 6iu9 differ, final R-work/R-free equal to 4 digits but 6iu9 R-work 0.2911 -> 0.2910; of the 5 timing cases 4 identical, 7d98 (cif start) R-free 0.3096 -> 0.3095; 5f6m MD starts 01-04 median R-free 0.1692 -> 0.1692; 6o2h on the CPU engine identical (md5). The score-only parity table is not touched (one Refit, no start). refit.scale (TIMING sum): 5f6m 1.52 -> 1.10 s. Wall: 5reo 1.68 -> 1.53, 5f6m 2.43 -> 2.24, 9yl4 7.19 -> 7.02, 7d98 3.70 -> 3.65, 5f6m MD start 4.57 -> 4.22 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit ff285fb525ecf4b480698d4aafe212a34301a8fe)
This commit is contained in:
1 parent
1f1aa18b67
commit
1f8b5b1986
5 files changed
+53
-25
No files matched your search
@@ -427,12 +427,16 @@ ModelScaleReport FitModelScale(gemmi::Scaling<float> &scaling, ModelScaleBox box
|
||||
// 10 A^2, or in eight values where the box is wider than the default, so a raised ceiling costs
|
||||
// no more grid points.
|
||||
const double b_step = std::max(10.0, (box.b_hi - box.b_lo) / 7.0);
|
||||
std::vector<PointFit> coarse;
|
||||
for (double ks = box.k_lo; ks <= box.k_hi + 1e-9; ks += 0.05)
|
||||
for (double bs = box.b_lo; bs <= box.b_hi + 1e-9; bs += b_step)
|
||||
coarse.push_back(PointFit{ks, bs});
|
||||
try_points(coarse);
|
||||
const double k0 = best_k_sol, b0 = best_b_sol;
|
||||
double k0 = box.k_start, b0 = box.b_start;
|
||||
if (k0 < 0) {
|
||||
std::vector<PointFit> coarse;
|
||||
for (double ks = box.k_lo; ks <= box.k_hi + 1e-9; ks += 0.05)
|
||||
for (double bs = box.b_lo; bs <= box.b_hi + 1e-9; bs += b_step)
|
||||
coarse.push_back(PointFit{ks, bs});
|
||||
try_points(coarse);
|
||||
k0 = best_k_sol;
|
||||
b0 = best_b_sol;
|
||||
}
|
||||
const double k_hi2 = std::min(box.k_hi, k0 + 0.05);
|
||||
const double b_hi2 = std::min(box.b_hi, b0 + b_step);
|
||||
std::vector<PointFit> fine;
|
||||
@@ -511,7 +515,8 @@ ModelScaleGPUPool::~ModelScaleGPUPool() {
|
||||
set_gpu(current);
|
||||
}
|
||||
|
||||
ModelScaleReport ModelScaleGPUPool::Fit(gemmi::Scaling<float> &scaling, double b_hi, size_t nthreads, bool robust) {
|
||||
ModelScaleReport ModelScaleGPUPool::Fit(gemmi::Scaling<float> &scaling, double b_hi, size_t nthreads, bool robust,
|
||||
double k_start, double b_start) {
|
||||
const size_t n = scaling.points.size();
|
||||
std::vector<std::array<int, 3>> hkl(n);
|
||||
std::vector<double> stol2(n);
|
||||
@@ -554,11 +559,11 @@ ModelScaleReport ModelScaleGPUPool::Fit(gemmi::Scaling<float> &scaling, double b
|
||||
if (cudaMemcpyAsync(e->fcalc, fc.data(), n * sizeof(float2), cudaMemcpyHostToDevice, e->stream) != cudaSuccess
|
||||
|| cudaMemcpyAsync(e->fmask, fm.data(), n * sizeof(float2), cudaMemcpyHostToDevice, e->stream) != cudaSuccess)
|
||||
throw JFJochException(JFJochExceptionCategory::GPUCUDAError, "ModelScaleGPUPool: the upload failed");
|
||||
fit = e->scale.FitSolvent(e->fcalc, e->fmask, b_hi, robust);
|
||||
fit = e->scale.FitSolvent(e->fcalc, e->fmask, b_hi, robust, k_start, b_start);
|
||||
} catch (const ModelScaleGPUTooFewReflections &) {
|
||||
set_gpu(current);
|
||||
release();
|
||||
return FitModelScale(scaling, {.b_hi = b_hi, .robust = robust}, nthreads);
|
||||
return FitModelScale(scaling, {.b_hi = b_hi, .robust = robust, .k_start = k_start, .b_start = b_start}, nthreads);
|
||||
} catch (...) {
|
||||
set_gpu(current);
|
||||
release();
|
||||
|
||||
Reference in new issue
Block a user