cpbenchy run instances/ -s ortools -t 60 -p cpbenchy.observers:PBOutput- Version
- cpbenchy 0.1.0.dev0
- Last updated
- 6 Oct 2026 · 1 commit
- Authors
- ThomSerg
- Formats
- opb
- Homepage
- www.cril.univ-artois.fr/PB26/
- Tags
- pseudo-booleancompetitionoutput
What it does
Writes what a solver in the Pseudo-Boolean competition prints, for each run on an OPB instance. The solution is a line with every variable as a literal:
o -7
o -9
s OPTIMUM FOUND
v x1 x2 -x3 x4Each competition specifies what a solver prints:
olines with each better objective value, while it solves- an
sline with its answer:OPTIMUM FOUND,SATISFIABLE,UNSATISFIABLEorUNKNOWN vlines with the solution
The output goes to each run’s logs/<run_id>.pb.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.
Variables that occur in no constraint still get a value, from the number of variables in the
instance’s header (* #variable= ...).
Use it
import cpbenchy
from cpbenchy import observers
cpbenchy.run("pb/", solvers=["exact", "ortools"], time_limit=60, plugins=[observers.PBOutput()])cpbenchy run pb/ -s exact -s ortools -t 60 -p cpbenchy.observers:PBOutputThe PB rules enable it, with the competition’s limits.
What it records
logs/<run_id>.pb.out |
the competition output |
Implementation
The PBOutput in src/cpbenchy/observers.py, lines 95–102 of 222, as of this version of the docs.
class PBOutput(CompetitionOutput):
"""Pseudo-Boolean competition output: every variable as `x1` or `-x1`."""
name = "pb"
formats = ("opb",)
def solution(self, ctx):
return [" ".join(fmt.literals(*numbered(ctx), prefix="x"))]