acceptodds
Published as a conference paper at NeurIPS 2026

Shellsort as Multi-Scale Relaxation: Learning Spectrum-Matched Gap Schedules

Qingyun Li, Ruoyun Li, Yunqi Li, Yunjin Li

Abstract

A Shellsort gap sequence is a multi-scale relaxation schedule. Each pass at gap eliminates inversions at length scale , and the sequence cools the array from coarse to fine, analogous to a multigrid V-cycle or simulated-annealing schedule. This view suggests that the right gap sequence should depend on the input's *disorder spectrum*: the inversion rate measured across logarithmic strides. Classical sequences such as Ciura, Sedgewick, and Tokuda are instead fixed schedules, applying the same coarse-to-fine relaxation to every input. We test this spectrum-matching view by formulating gap selection as a Markov decision process whose state is the current disorder spectrum and whose action selects the next gap. A small PPO-trained policy improves comparison count by **15-16%** over Sedgewick across array sizes to on a seven-family input mixture, with training under 10 minutes on a consumer CPU. But the main value of the learned policy is not only that it improves Shellsort: it provides a probe into what effective gap schedules are doing. The learned schedules organize into three distinct relaxation regimes: gradual Brownian-like cooling for flat-spectrum inputs, faster Lévy-flight-like cooling for coarse-scale structure, and direct fine-scale relaxation for inputs whose disorder is already local. Spectrum statistics predict schedule statistics, training only on flat-spectrum inputs recovers a dense Ciura-like regime, and an ablation that replaces the adaptive policy with one global learned sequence reduces the gain from 15.6% to 0.9%. Input adaptivity, not the discovery of another static sequence, accounts for the gain. The marginal spectrum has blind spots: pipe-organ inputs share the random spectrum but their bipartite structure becomes visible only after the first pass, so sequential adaptation provides an additional margin. For known target distributions the policy can be used offline as a schedule compiler: run it on representative inputs, extract a per-distribution schedule, and hardcode that fixed sequence as a drop-in replacement for the existing static gaps with no neural runtime overhead. Together, these results recast Shellsort gap design as spectrum-matched scheduling.

Keywords:
Atlanta, Main Track

Reviews

Among:
Shape:
123456this paper, Bottom 4%
Figure 1. Mean review rating of the reviewed papers at NeurIPS 2026. This paper averages 3.67 over 3 reviews, above 4% of the others.
Reviewer_hpsuOpenReview ↗
Rating
4
Clarity
3
Confidence
3
Originality
3
Quality
3
Significance
3
Read review
Summary

This paper proposes a learnable gap-sequence for Shellsort by using PPO adaptively. This paper shows that the popular gap sequences proposed by by Ciura (empirically), Sedgewick (theoretically), and Tokuda (based on a geometric forumla) can be improved upon, in terms of comparison counts. Their method improves upon comparison count to Sedgewick by 15-16% across N=128-16,384 arrays, using a seven family input mixture.

Strengths and weaknesses

Strengths

  • I appreciate the authors' transparency related to the weaknesses and limitations of their method, and their key claim (on the effectiveness of adaptive gap sequencing) is clearly supported.

  • The authors adopt strong statistical hygiene for their experimental design, having 30 seeds, per-family Mann–Whitney p-values, and held-out evaluation.

  • On flat-spectrum inputs, the method recovers a Ciura-like schedule ([80, 28, 12, 4, 1]). This is both an interesting finding and a convincing sign the method is behaving correctly.

  • A real system that repeatedly sorts similar/repetitive inputs might have a stable input distribution, which is one regime the where the learned offline gap schedules can really shine.

Weaknesses

  • The practical aspect of this algorithm is overstated. The motivating deployments are embedded systems, where wall-clock time and implementation simplicity render a neural network policy impractical. The honest reporting is appreciated, but the introduction and abstract do not convey this clear drawback/limitation (e.g. the overhead induced by computing the fingerprint and network forward pass).

  • The sequential adaptivity and cheap deployment aspects are in contention. The method's advantage over one-shot classifiers comes from this adaptivity. However, the proposed deployment (to use an offline schedule) discards this sequential adaptation advantage.

  • The per-family generation parameters (e.g., noise level for nearly-sorted, block size for interleaved, tooth period for sawtooth, duplicate fraction for many-duplicates) are not specified. These materially affect each family's disorder spectrum and thus the reported gain.

Questions
  • The fixed-sequence comparison (without using a lookup) is not compared head-to-head against the one-shot classifiers in Table 9. The authors should include this, since we likely cannot rely on an oracle for real systems. Can the authors add this?

  • Can the authors comment on the common types of distributions seen by the motivating applications (embedded systems), and if there is good reason to believe their mixture of datasets captures these distributions? For example, it would be interesting to capture the distribution of a real system and apply this method to it, rather than using a synthetic dataset. I expect the learned policy to provide an advantage here.

Limitations

Yes

Paper formatting concerns

N/A

Final justification

I would like to thank the authors for the discussion; however, the rebuttal did not significantly impact my original review. I find it interesting that the method can recover a schedule similar to Ciura's empirically optimized sequence (which is claimed to be the best-known sequence). At the same time, the authors are forthcoming about their limitations, and the experimental design is strong. However, I have doubts as to whether this algorithm is practical in applied settings (given, e.g., the wall-clock overhead), and it seems to only provide a minor benefit in the precomputed/offline setting. I also agree with the "limited novelty" point from reviewer FkKJ. For this reason, I would be hesitant to increase my score beyond my original review.

Reviewer_FkKJOpenReview ↗
Rating
3
Clarity
2
Confidence
1
Originality
2
Quality
3
Significance
3
Read review
Summary

The paper studies Shellsort gap-sequence selection. The authors propose viewing a gap sequence as a multi-scale relaxation or cooling schedule, where each gap targets disorder at a different length scale. They define an input “disorder spectrum” based on inversion rates at logarithmic strides, formulate adaptive gap selection as an MDP, and train a small PPO policy to choose gaps sequentially. On a mixture of seven synthetic input families, the learned policy reduces comparison counts by roughly 15–16% relative to Sedgewick across different array sizes.

Strengths and weaknesses

Strengths

  1. The proposed method is based on a valid motivation: previous method are fixed schedules, this paper propose
  2. The paper is transparent about several limitations, including wall-clock overhead and poor generalization to structurally novel distributions.

Weakness

  1. The novelty is limited. The core method is essentially a practical application of a standard PPO policy to adaptive Shellsort gap selection, using hand-designed input features and a straightforward reward based on comparison count.
  2. The main practical claim is weakened by wall-clock overhead. Although comparison count is a standard theoretical metric, the learned policy is reported to be 65× slower than Sedgewick at N=256 and still 3× slower at N=16,384 when fingerprint computation and MLP inference are included. This is especially important because the motivation emphasizes embedded and practical sorting settings. A comparison-count improvement does not by itself establish a practical improvement for real sorting workloads.
Questions

Does the proposed method provides actual end-to-end wall-clock speedups on realistic workloads, rather than only reducing comparison counts?

Limitations

yes

Paper formatting concerns

One appendix page containing a large table appears to be rotated by 90 degrees.

Reviewer_BtjLOpenReview ↗
Rating
4
Clarity
4
Confidence
3
Originality
3
Quality
3
Significance
2
Read review
Summary

The paper views gap selection in Shellsort as a multi-scale relaxation problem. The authors formulate gap selection as an MDP whose state is a per-stride inversion fingerprint, train a small PPO MLP on a seven-family dataset, and report a reduced number of comparisons over existing methods across different array sizes. The RL model adaptively changes its gap schedule according to the disorder spectrum of the given array to achieve fewer comparisons during sorting.

Strengths and weaknesses

Strengths

  • The multi-scale relaxation framing is well-motivated and the MDP design is reasonable. In particular, the inversion fingerprint as a disorder spectrum is a natural state representation, which also demonstrates clear empirical benefits.
  • The ablation experiments are thorough. The per-family breakdown is illustrative. The pipe-organ counter-example effectively demonstrates why sequential RL outperforms one-shot classifiers. The experiments restricting training to certain families and reproducing similar patterns are insightful.
  • The paper is well-written and clearly structured. I enjoyed reading the paper.

Weaknesses

The core weakness is the scalability of the algorithm.

  • Generalization concern. The authors acknowledge that the policy fails on distributions not seen during training, and only seven families are included during training. The proposed fix of adding more families is essentially enumeration rather than genuine generalization, and the paper does not characterize how many families would be needed to cover realistic input diversity. There remains a gap between the controlled evaluation setting and real-world application.
  • The paper trains and evaluates independent policies at each array size. There is no discussion of whether a single policy could generalize across N values. It also limits the algos scalability for real usage.
Questions
  1. As N grows, the action space expands. Is there any analysis of how policy performance or training stability changes as the action space size increases? At very large N, does the larger action space require more training steps to explore adequately?
  2. The paper uses a fixed 500 update steps across all N values. Is there a training curve showing convergence behavior? It is not obvious that 500 steps is sufficient or necessary at all N.
  3. Have you tested the scalability with respect to the number of families? How many families can be added while the algorithm still outperforms the baseline?
Limitations

yes

Paper formatting concerns

no

Final justification

Thank you for the detailed response and the additional experiments. The new results provide further evidence on the convergence behavior, action-space scalability, and the impact of increasing the number of input families. I maintain my original rating.

Comments on the paper

1 comment
Meta-review

The reviewers agree that the paper presents a well-motivated application of reinforcement learning to adaptive Shellsort gap selection, with a clear formulation, thorough experimental evaluation, and honest discussion of its limitations. They particularly appreciate the comprehensive ablations, statistical rigor, and evidence supporting the benefits of sequential adaptive policies. The primary concerns relate to scalability, generalization beyond the training distributions, practical deployment overhead, and the limited methodological novelty. While these issues should be discussed more explicitly in the final version, they do not outweigh the paper's overall contribution. Therefore, I recommend weak acceptance.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.