TRIQS /SOMis a numerical analytic continuation package first presented in [Comp. Phys. Comm. 239 (2019) 166–183]. Version 2.0 brings a number of new features, most notably a complete implementation of the Stochastic Optimization with Consistent Constraints protocol. Other additions include support for user-supplied covariance matrices of correlated input data, and a new family of integral kernels for fermionic Green's functions with enforced particle-hole symmetry. The code base has been updated to rely on the recent version 3.1 of the TRIQSlibrary, which also implies moving away from the discontinued Python 2.7 to Python 3. New version program summaryProgram Title:TRIQS /SOMCPC Library link to program files:https://doi.org/10.17632/fcjzyhrwpw.2Developer's repository link:https://github.com/krivenko/somLicensing provisions: GPLv3Programming language:C++/PythonJournal reference of previous version: Comp. Phys. Comm. 239 (2019) 166–183Does the new version supersede the previous version?: YesReasons for the new version: Implementation of the stochastic optimization with consistent constraints protocol as well as of other new features; Complete port to Python 3 and the TRIQSlibrary [1] version 3.1.Nature of problem: Quantum Monte Carlo methods (QMC) are powerful numerical techniques widely used to study quantum many-body effects and electronic structure of correlated materials. Obtaining physically relevant spectral functions from noisy QMC results in the imaginary time/Matsubara frequency domains requires solution of an ill-posed analytic continuation problem as a post-processing step.Solution method: We present an efficient C++/Python open-source implementation of the stochastic optimization method for analytic continuation, both in its original formulation (SOM) [2] and with the consistent constraints extensions (SOCC) [3,4].Summary of revisions:TRIQS /SOM has been ported from the long-deprecated TRIQS library branch 1.4.x to the recently released version 3.1 (requires a C++20 compiler). As a consequence, support for the retired Python 2.7 has been dropped in favor of Python 3.For consistency with the Maximum Entropy method and other approaches to numerical analytic continuation, we now search for a spectral function A(ϵ) minimizing the “goodness of fit” functionalχ2[A(ϵ)]=1N∑n=1N|Δ(n)σ(n)|2, as opposed to the previously usedD[A(ϵ)]=∑n=1N|Δ(n)σ(n)|.Δ(n) are discrepancies derived from the integral equation of the analytic continuation problem,Δ(n)=∫ϵminϵmaxK(n,ϵ)A(ϵ)dϵ−G(n), and σ(n) are user-provided estimated error bars on the input quantity G(n). Adoption of the χ2-functional has made it possible to support general N×N covariance matrices Σˆ of correlated input data as an alternative to the simple estimated error bars,χ2[A(ϵ)]=1NΔ†Σˆ−1Δ,Δ={Δ(n)}.The most prominent new feature of TRIQS /SOM 2.0 is a complete implementation of the Stochastic Optimization with Consistent Constraints protocol proposed by Goulko et al. in [4]. It includes three major aspects.•The Consistent Constraints update in the Markov chain [4, Sec. II.A] used to speed up accumulation of particular solutions. Unlike the elementary updates, it drastically changes heights of all rectangles in current configuration by minimizing a sum of the χ2-functional and a few quadratic regularization terms. These extra terms depend on a set of regularization parameters, whose values are determined in a self-consistent manner in the course of an iterative optimization procedure.•The Consistent Constraints (CC) protocol for constructing final solutions out of particular solutions [4, Sec. II.B]. In the original formulation of SOM, a final solution is constructed as a simple equal-weight sum of all “good” (delivering deep minima to χ2) particular solutions. The CC protocol aims at constructing a smoother final solution as a general superposition of J good particular solutions A(ϵ)=∑j=1JcjAj(ϵ), where expansion coefficients cj are subject to ∑j=1Jcj=1. A sophisticated and customizable iterative procedure is employed to minimize a certain quadratic function of cj, while self-consistently adjusting values of regularization parameters this function depends on. One may also use this algorithms to bias the final solution towards a certain “target” spectral function AT(ϵ).•A solution quality assessment technique [4, Sec. I-II] implemented in a new Python module som.spectral_stats. Functions from this module make it possible to perform statistical analysis of ensembles of accumulated particular solutions. Statistical averages over such ensembles may serve as estimates of true spectral functions, while dispersions and two-point correlations contain information about uncertainties of the estimated spectra.A new family of integral kernels K(n,ϵ) for particle-hole symmetric fermionic Green's functions has been introduced. The corresponding observable is called FermionGfSymm.The BosonAutoCorr kernels have been changed to more closely reproduce results of the BosonCorr kernels when applied to the same input data. Both kernel families are defined on the whole energy axis (ϵmin=−∞,ϵmax=+∞) and expect the same spectrum normalization constant now.Projection of an observable G(ϵ) onto a real frequency grid ϵi can now be performed using binning (enabled by default). In this mode, the projected observable is averaged over bins centered around points of the grid, Gi=1δ∫ϵi−δ/2ϵi+δ/2G(ϵ)dϵ, instead of being simply evaluated at those points, Gi=G(ϵi).The online documentation website has undergone a complete overhaul. Now, it includes a step-by-step tutorial for new users, a detailed user guide covering all major features of the package, an auto-generated Python API reference and a handful of usage examples. There is also a Python script porting guide for those switching from TRIQS /SOM 1.x.A detailed list of all changes in version 2.0 is available at http://krivenko.github.io/som/ChangeLog.html.