Constrained Posterior Sampling: Time Series Generation with Hard Constraints

Sai Shankar Narasimhan, Shubhankar Agarwal, Litu Rout, Sanjay Shakkottai, Sandeep P. Chinchali

This paper introduces Constrained Posterior Sampling (CPS), a novel framework for generating synthetic time series that must obey strict, domain-specific rules—like physical laws or financial logic—without sacrificing the realism of the data.

The Challenge of Hard Constraints

Generative models like Diffusion Models (DMs) and GANs are excellent at creating realistic synthetic data. However, in engineering, finance, and safety-critical fields, data isn't just about "looking real"—it must follow hard constraints. For example:

  • Finance: In an OHLC (Open-High-Low-Close) stock chart, the "High" must be $\ge$ all other values for that day.
  • Energy: Electricity demand patterns must stay within the physical limits of the power grid.
  • Physics: Generated sensor data might need to conserve energy or mass.
Concept of Constrained Posterior Sampling

Existing solutions struggle with these strict requirements. "Guidance-based" methods (which nudge the model toward constraints) are notoriously hard to tune when dealing with hundreds of constraints. "Projection-based" methods often project noisy intermediate states, pushing the data off the manifold of realism and resulting in blurry or nonsensical samples. Finally, training a model for specific constraints lacks scalability, as a new model is needed for every new set of rules.

The CPS Approach

To address these limitations, the authors propose Constrained Posterior Sampling (CPS), a training-free algorithm that integrates constraints directly into the reverse diffusion (denoising) process.

CPS Diffusion Process
  1. Projecting the Posterior Mean: Unlike previous methods that project the noisy latent state ($z_t$), CPS projects the posterior mean estimate ($\hat{z}_0$). This is the model's "best guess" at what the final clean sample will look like at any given step. By projecting the predicted clean version and then re-adding the appropriate amount of noise for the next step, CPS keeps the sample within the natural distribution learned during training.
  2. Time-Varying Penalty ($\gamma(t)$): CPS uses an optimization step that balances staying close to the model's prediction while satisfying constraints. The enforcement of constraints starts weak (when the signal is mostly noise) and becomes exponentially stronger as the denoising process nears completion.
  3. Training-Free & Scalable: Because CPS happens entirely during the inference phase, it requires no additional training. It can handle upwards of 100 constraints simultaneously using off-the-shelf optimization solvers (like CVXPY).

Key Results

The researchers evaluated CPS across diverse domains, including S&P 500 stocks, Beijing air quality, and Metro Interstate traffic volume. CPS demonstrated a significant leap over state-of-the-art baselines:

  • Sample Quality: Improved the Discriminative Score (a measure of how hard it is for a classifier to tell synthetic data from real data) by roughly 70%.
  • Distributional Similarity: Achieved a 22% improvement in Dynamic Time Warping (DTW), meaning the generated samples more closely tracked the specific patterns of real-world test cases.
  • Constraint Adherence: While guidance-based models often miss hard constraints at scale, CPS achieved near-zero constraint violation magnitudes across all tests.

Limitations and Future Work

The primary trade-off for CPS is inference latency. Because it runs an optimization solver at each denoising step, it is roughly 2x slower than standard guidance-based sampling. The authors suggest capping the number of optimization steps in early stages to mitigate this. Additionally, while the method works well empirically on non-convex constraints, current theoretical guarantees only cover linear/convex sets. Future directions include applying CPS to robotics trajectory generation and style transfer for time series.

Summary updated

BibTeX
@inproceedings{narasimhan2025constrained,
  author = {Sai Shankar Narasimhan and Shubhankar Agarwal and Litu Rout and Sanjay Shakkottai and Sandeep P. Chinchali},
  title = {{Constrained Posterior Sampling: Time Series Generation with Hard Constraints}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=iBLAYaEKdL},
}
Figure