Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1449476
first draft
TomWagg Apr 10, 2026
1857871
remove useless constants
TomWagg Apr 10, 2026
a471c1c
final fixes for working stroopwafel implementation
TomWagg Apr 10, 2026
1e34379
Merge branch 'develop' into stroop
TomWagg May 12, 2026
aaf0683
actually apply the shuffle properly
TomWagg May 12, 2026
6efd6aa
clean up einsum
TomWagg May 12, 2026
d50f31c
clarify sana bounds
TomWagg May 12, 2026
f2a189f
explain cosine sampling
TomWagg May 12, 2026
a10609f
clean up tests
TomWagg May 12, 2026
ed914d3
add new docs page for stroopwafel sampling
TomWagg May 12, 2026
d68dd96
add it to the main page (the new docs page)
TomWagg May 12, 2026
13252b7
add kick params for sampling
TomWagg May 19, 2026
cd2ff0e
add kick sampling
TomWagg May 25, 2026
15bccb5
create COSMICStroopOutput
TomWagg Jun 2, 2026
92c12e8
account for output in tests
TomWagg Jun 2, 2026
2d12d5d
bh star working with new stuff
TomWagg Jun 2, 2026
f29e198
we already have a roche radius function
TomWagg Jun 2, 2026
79178a2
clearer error about legwork
TomWagg Jun 2, 2026
8b726a0
add temporary bhflag 4
TomWagg Jun 2, 2026
b76d613
Merge branch 'develop' into stroop
TomWagg Jun 2, 2026
4879225
fix table indices
TomWagg Jun 2, 2026
4cd1967
update changelog and version
TomWagg Jun 2, 2026
db49faa
add checkpointing for slurm splitting and memory saving with only sav…
TomWagg Jun 2, 2026
26dff39
better upper limit for kick prior
TomWagg Jun 2, 2026
6c72503
add stroopwafel to api docs and tutorials
TomWagg Jun 2, 2026
0358c81
basics stroopwafel tutorial working
TomWagg Jun 2, 2026
373ca50
working on tutorials
TomWagg Jun 15, 2026
0b15835
Merge branch 'develop' into stroop
TomWagg Jun 28, 2026
ce9c10a
consolidate into single Distributions class
TomWagg Jun 28, 2026
4feca69
move tests to main folder
TomWagg Jun 28, 2026
c5bbe8e
docs overhaul
TomWagg Jun 29, 2026
e2f31fa
no alphabetical
TomWagg Jun 29, 2026
a7eb218
make derived stuff more general
TomWagg Jun 29, 2026
b7457b9
rename to main
TomWagg Jun 29, 2026
30212c5
update basics tutorial
TomWagg Jun 29, 2026
ceaff95
delete constants, move to definitions
TomWagg Jun 29, 2026
74b8109
simplify rejection, towards deleting consts
TomWagg Jun 29, 2026
36fe089
delete constants, move into attributes
TomWagg Jun 29, 2026
75d241a
make checkpointing save state better
TomWagg Jun 29, 2026
38802be
minor fixes for mins
TomWagg Jun 29, 2026
582983a
remove output path, spell out EM stuff
TomWagg Jun 29, 2026
5d5f3d8
review docs
TomWagg Jun 29, 2026
db63a55
finish off docs
TomWagg Jun 29, 2026
cf1cdc2
check over representative sample
TomWagg Jun 29, 2026
90f9162
add SSEDict to everything
TomWagg Jun 29, 2026
920287d
update changelog and version stuff
TomWagg Jun 29, 2026
d311968
remove old examples dir
TomWagg Jun 29, 2026
340328b
fix double hyphen
TomWagg Jun 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# COSMIC Changelog
## Prepend only please!

## 4.2.0

This version, among other thins, introduces adaptive importance sampling to COSMIC.

- Additions/changes
- **Adaptive importance sampling via the STROOPWAFEL algorithm** ([Broekgaarden et al. 2019](https://arxiv.org/abs/1905.00910)) — a new vectorised module for efficiently sampling rare binary outcomes (e.g. merging double compact objects), where flat Monte Carlo would need millions of evolutions to collect a handful of systems. Lives in ``cosmic.sample.stroopwafel``:
- ``AdaptiveSampler`` runs the three-phase pipeline (exploration → adaptation → refinement) and returns importance-weighted results; pass ``mc_only=True`` for a plain Monte Carlo baseline.
- ``ParameterSpace`` / ``Parameter`` define the sampled dimensions. Each parameter takes a single composable ``dist`` (see below), and columns follow the order the parameters are supplied.
- A binary is defined by ``{mass_1, mass_2, porb, ecc, metallicity}``; each is either sampled or returned by a user ``derive_params`` callback, validated when the sampler is constructed.
- Composable distributions (``cosmic.sample.stroopwafel.distributions``): base distributions (``Uniform``, ``PowerLaw``, ``BrokenPowerLaw``, ``TruncatedNormal``) combined with coordinate transforms (``Identity``, ``Log10``, ``Ln``, ``Sin``, ``CosShift``). Built-ins include ``kroupa`` (a continuous broken power law, α=-1.3 below 0.5 Msun and -2.3 above), ``sana``, ``sana_ecc``, ``flat_in_log``, ``uniform``, ``uniform_in_sine``, ``uniform_in_cosine`` and ``disberg``. Define your own by passing a ``Distribution`` instance, calling ``register(...)``, or subclassing ``Distribution``.
- Physical rejection via ``default_reject`` (or a custom callback). It is ``SSEDict``-aware, so ZAMS radii are computed with the same stellar engine used for evolution.
- Built-in hit-definition presets ``any_dco`` and ``merging_dco`` (``cosmic.sample.stroopwafel.presets``), or supply any ``(bpp) -> (n_hits, hit_bin_nums)`` function.
- Results are returned as ``cosmic.output.COSMICStroopOutput``, holding the samples, importance weights, hit flags, and full COSMIC tables, with ``hit_rate``/``hit_rate_uncertainty`` properties, ``draw_representative_sample(...)`` (weighted bootstrap), and ``save``/``from_file``.
- Self-contained checkpointing: ``run_exploration()`` returns a ``STROOPWAFELCheckpoint`` (``.save(path)``), and ``AdaptiveSampler.from_checkpoint(path)`` rebuilds the sampler — parameter space, settings, callables (serialised with ``dill``), and RNG state — for ``run_refinement()`` with no re-specification. Any setting can be overridden as a keyword.
- ``bhflag = 4`` is added as another option, which applies fallback-modulation even when kicks are directly supplied

- Documentation:
- New "Adaptive importance sampling" tutorial series under ``docs/pages/tutorials/adaptive/``: getting started (``basics``), defining and customising distributions (``distributions``), interpreting outputs and weights (``outputs``), and saving/resuming runs (``checkpoint``).

## 4.1.0

- Additions/changes
Expand Down
7 changes: 7 additions & 0 deletions docs/modules/sample.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ Multidimensional sampler
:no-inheritance-diagram:
:no-heading:

Adaptive importance sampler
---------------------------

.. automodapi:: cosmic.sample.stroopwafel
:no-inheritance-diagram:
:no-heading:

CMC related functions
---------------------

Expand Down
44 changes: 32 additions & 12 deletions docs/pages/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,58 +52,77 @@ This page contains of tutorials that show you how to use ``COSMIC`` and become a

:ref:`cmc_sampling`


.. grid-item-card::

.. container:: tutorial-card

.. rubric:: Converged populations
.. rubric:: Re-running simulations
:class: tutorial-card-title

.. rst-class:: tutorial-card-link

:ref:`fixedpop`
:ref:`rerun_rerun`

.. rst-class:: tutorial-card-link

:ref:`rerun_restart`

.. grid-item-card::

.. container:: tutorial-card

.. rubric:: Re-running simulations
.. rubric:: Modifying timesteps
:class: tutorial-card-title

.. rst-class:: tutorial-card-link

:ref:`rerun_rerun`
:ref:`timesteps_resolution`

.. rst-class:: tutorial-card-link

:ref:`rerun_restart`
:ref:`timesteps_modifiers`


.. grid-item-card::

.. container:: tutorial-card

.. rubric:: Modifying timesteps
.. rubric:: Converged populations
:class: tutorial-card-title

.. rst-class:: tutorial-card-link

:ref:`timesteps_resolution`
:ref:`fixedpop`

.. grid-item-card::

.. container:: tutorial-card

.. rubric:: Analysing simulations
:class: tutorial-card-title

.. rst-class:: tutorial-card-link

:ref:`timesteps_modifiers`
:ref:`analysis_interface`

.. grid-item-card::

.. container:: tutorial-card

.. rubric:: Analysing simulations
.. rubric:: Adaptive importance sampling
:class: tutorial-card-title

.. rst-class:: tutorial-card-link

:ref:`adaptive_basics`

:ref:`analysis_interface`
.. rst-class:: tutorial-card-link

:ref:`adaptive_outputs`

.. rst-class:: tutorial-card-link

:ref:`adaptive_checkpoint`

.. grid-item-card::

Expand All @@ -122,8 +141,9 @@ This page contains of tutorials that show you how to use ``COSMIC`` and become a

tutorials/evolve
tutorials/sample
tutorials/convergence
tutorials/rerun
tutorials/timesteps
tutorials/convergence
tutorials/analysis
tutorials/adaptive
tutorials/misc
13 changes: 13 additions & 0 deletions docs/pages/tutorials/adaptive.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
############################
Adaptive importance sampling
############################

These tutorials will cover how to use the adaptive importance sampling method in ``COSMIC`` to efficiently sample from the parameter space and obtain results with fewer samples.

.. toctree::
:maxdepth: 2

adaptive/basics
adaptive/distributions
adaptive/outputs
adaptive/checkpoint
Loading
Loading