Python package to parse and solve product configuration problems specified in COOM using ASP.
pip install .
The COOM language is a domain-specific language for modelling product configuration problems. While currently geared towards ASP, the COOM Suite is intended to serve as a general workbench for experimentation with industrial-scale product configuration problems. It includes a (customizable) ANTLR v4 parser to convert COOM specifications into facts, and currently contains two ASP encodings for solving: one for clingo and one for hybrid solver fclingo.
In addition, a range of examples and a benchmark collection with four scalable benchmark sets is provided.
We define the following three COOM language fragments:
- COOM Core corresponds to a simple Constraint Satisfaction Problem (CSP). It mainly consists of table and Boolean constraints over discrete attributes and all variables are defined.
- COOM[P] adds partonomies and cardinalities on top of COOM Core.
- COOM[X] adds numeric variables and calculations (arithmetic expressions and aggregate functions) on top of COOM[P].
The COOM Suite contains a range of (product) configuration examples encoded in
the COOM language. They can be found in the examples/coom
directory. We highlight here only the Bike collection, containing three
examples in increasing complexity that correspond to the three COOM language
fragments defined above: the Kids,
City, and
Travel Bike.
We also provide the corresponding (serialized and refined) facts to these
examples under examples/asp
.
The COOM suite includes four scalable benchmark sets. More information can be
found in the benchmarks
directory.
To convert a COOM instance into a set of (serialized) facts run
coomsuite convert examples/coom/kids-bike.coom
By default, the facts are printed to the console.
Optionally, an output directory can be provided using option --output dir
in
which case the facts will be saved to the given directory.
To solve a COOM model using ASP run
coomsuite solve examples/coom/kids-bike.coom
This will convert the given COOM file to a set of (serialized) facts and solve them with the clingo encoding.
Possible options include:
-
Using
--output coom
, the output facts will be converted into a (more readable) COOM format. -
For solving with solver fclingo, specify
--solver fclingo
. -
The usual clingo command-line arguments can be used, eg. to calculate all stable models and suppress printing models.
coomsuite solve examples/coom/kids-bike.coom 0 -q
- Note that the direct conversion of COOM into facts is a mere serialization of
the COOM model. We make use of a preprocessing encoding to translate the
"serialized" facts into a set of "refined" facts, capturing the essence of a
configuration problem. To show the "refined" facts, run with option
--show-facts
. This will print the facts to the console.
To get started have a look at the COOM grammar.
You can customize the conversion by modifying the ASP Visitor.
More information on the Python target of ANTLR v4 can be found here.
The encodings are stored in
src/coomsuite/encodings/
.
Loading of the encodings is handled with clingo's Application class. Modify this line to insert your own encoding. Note that you might also have to disable/modify the preprocessing encoding here.
From the corresponding folder run (possibly replacing the version number and grammar file name)
antlr4 -v 4.9.3 -Dlanguage=Python3 Grammar.g4 -visitor
To improve code quality, we use nox to run linters, type checkers, unit tests, documentation and more. We recommend installing nox using pipx to have it available globally.
# install
python -m pip install pipx
python -m pipx install nox
# run all sessions
nox
# list all sessions
nox -l
# run individual session
nox -s session_name
# run individual session (reuse install)
nox -Rs session_name
Note that the nox sessions create editable installs. In case there are
issues, try recreating environments by dropping the -R
option. If your
project is incompatible with editable installs, adjust the noxfile.py
to
disable them.
We also provide a pre-commit config to autoformat code upon commits. It can be set up using the following commands:
python -m pipx install pre-commit
pre-commit install