Skip to content
cpbenchy 0.1.0.dev0 is in alpha: until version 1.0, commands, options, the Python API and the result format may still change. Pin the version you use.

solutions

Records how solutions improve over time, for every run, out of the box.

Updated View as Markdown
PluginBuilt incomes with cpbenchy

on by default; --no-solutions turns it off

Version
cpbenchy 0.1.0.dev0
Last updated
6 Oct 2026 · 1 commit
Authors
ThomSerg
Tags
built-inanytime

What it does

Records every run’s solutions over time: for optimization problems, each better objective value the solver finds, with when it found it. It is on by default, for every run, through CPMpy’s solution callback. Runs that are killed keep what they recorded.

Use it

Nothing to do. To turn it off (no solution callback, for solvers where it costs time):

What it records

extra["solutions"] [[seconds, objective], ...]

Implementation

The file src/cpbenchy/solutions.py, 23 lines, as of this version of the docs.

src/cpbenchy/solutions.pypython
"""Built-in plugin: record each run's solutions over time, as `extra["solutions"]`: [[seconds, objective], ...].

The worker reports solutions of optimization problems through CPMpy's `display` callback (see
`cpbenchy.worker.solvers`). Recorded from the events, so also for runs that get killed.
"""

from cpbenchy import hookimpl


@hookimpl
def cpbenchy_addoption(parser):
    parser.getgroup("run").addoption(
        "--no-solutions",
        dest="solutions",
        action="store_false",
        help="don't report intermediate solutions (no solution callback)",
    )


@hookimpl
def cpbenchy_run_event(run, event):
    if event.kind == "solution":
        run.extra.setdefault("solutions", []).append([round(event.t, 3), event.data["objective"]])
Navigation

Type to search…

↑↓ navigate↵ selectEsc close