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.

XCSP3Output

Answers in the format of the XCSP3 competition, and optionally checked by its official checker.

Updated View as Markdown
ObserverBuilt incomes with cpbenchy
cpbenchy run instances/ -s ortools -t 60 -p cpbenchy.observers:XCSP3Output
Version
cpbenchy 0.1.0.dev0
Last updated
6 Oct 2026 · 1 commit
Authors
ThomSerg
Formats
xcsp3
Requires
pycsp3, to read XCSP3; java, for the official checker
Tags
xcsp3competitionoutput

What it does

Writes what a solver in the XCSP3 competition prints, for each run on an XCSP3 instance, with the solution as an XML <instantiation> of the instance’s variables:

o 12
o 9
s OPTIMUM FOUND
v <instantiation type="optimum" cost="9">
v   <list>x[0] x[1] x[2] y</list>
v   <values>2 1 0 3</values>
v </instantiation>

Each competition specifies what a solver prints:

  • o lines with each better objective value, while it solves
  • an s line with its answer: OPTIMUM FOUND, SATISFIABLE, UNSATISFIABLE or UNKNOWN
  • v lines with the solution

The output goes to each run’s logs/<run_id>.xcsp3.out, written inside the measured run, as a competition solver would print it, so it costs the run the time it would cost in the competition. A run that is killed keeps its o lines. Under cpbenchy solve, the output goes to stdout, where competitions read it.

Given the competition’s solution checker, it also checks every solution with it, after the run and outside its measured time.

Use it

The XCSP3 rules enable it, with the competition’s limits.

Options

Argument
checker path of the XCSP3 solution checker jar; needs java. Default: no check

What it records

logs/<run_id>.xcsp3.out the competition output
extra["xcsp3_check"] with a checker: "OK", or what the checker says is wrong

Implementation

The XCSP3Output in src/cpbenchy/observers.py, lines 74–92 of 222, as of this version of the docs.

src/cpbenchy/observers.pypython
class XCSP3Output(CompetitionOutput):
    """XCSP3 competition output. With `checker` (the path of the competition's checker jar, needs java),
    the parent also checks every solution after its run, outside the measured time, and records the
    verdict as `extra["xcsp3_check"]`: "OK", or what is wrong."""

    name = "xcsp3"
    formats = ("xcsp3",)

    def __init__(self, checker=None):
        self.checker = checker

    def solution(self, ctx):
        cost = ctx.objective if ctx.model.has_objective() else None
        return fmt.xcsp3_instantiation(fmt.instance_variables(ctx.model), cost).splitlines()

    def on_result(self, run, result):
        output = self.output(run)
        if self.checker and result.status in ("optimal", "feasible") and output.exists():
            result.extra["xcsp3_check"] = xcsp3_check(self.checker, run.spec.instance.path, output)
Navigation

Type to search…

↑↓ navigate↵ selectEsc close