Project for the Combinatorial Decision Making & Optimization course of the MAster's Degree in Artificial Intelligence of UniBo
WARNING: The Dockerfile was tested on both x86 and arm architectures (for arm you need to add the flag when building the image: --platform linux/amd64), but the SMT solver CVC5 is not set up to work on arm architecture.
This README explains how to build and run the project image using only Docker CLI. It documents the available flags that the container entrypoint accepts, shows concrete examples, and lists the available versions and which version token to pass when you want to run a specific experiment.
All commands assume you run them from the project root where the Dockerfile and the source/ directory live.
Build the image once (from project root):
docker build -t sts-container .You should mount your working source/ and res/ directories into the container so the container uses your code and writes outputs back to the host:
# Unix / macOS (bash / zsh)
-v "$(pwd)/source:/CDMO/source" -v "$(pwd)/res:/CDMO/res"On PowerShell use ${PWD} instead of $(pwd).
The container entrypoint accepts two styles of invocation:
-
No arguments (batch mode) If you run the container without passing any arguments, the entrypoint will sequentially run every approach and runs the same scripts that genereted the json files:
CP,SMT,MIP— invokingpython /CDMO/source/<APPROACH>/main.pyfor each approach with default parameters.docker run --rm \ -v "$(pwd)/source:/CDMO/source" \ -v "$(pwd)/res:/CDMO/res" \ sts-container
-
Only the approach The entrypoint will run a single approach only, that generate the json files in
/CDMO/res/<APPROACH>/n.json.docker run --rm -v "$(pwd)/source:/CDMO/source" -v "$(pwd)/res:/CDMO/res" \ sts-container MIP
-
Single-approach mode (positional or flag style) If you pass arguments, the entrypoint will run a single approach and a single verion among the possible (see underneath) only.
-
Positional form:
docker run --rm -v "$(pwd)/source:/CDMO/source" -v "$(pwd)/res:/CDMO/res" \ sts-container MIP 8 v1
This runs
python /CDMO/source/MIP/main.py --instance 8 --version v1. -
Flag form:
docker run --rm -v "$(pwd)/source:/CDMO/source" -v "$(pwd)/res:/CDMO/res" \ sts-container -- --approach MIP --n 8 --version v1
This runs the same
main.pyand forwards--n 8 --version v1.
-
--approach <APPROACH>— one ofCP,SMT,MIP(case-insensitive).--nor--instance <int>— instance size (even integer).--version <str>— version token (e.g.v1).-h,--help— show help (entrypoint prints usage).
The following list serves as index to know which version runs a particular model (all the cited model are described in the report).
| version | meaning / which implementation is used |
|---|---|
v1 |
Will run the naive_model not balanced, with 'gecode' solver |
v2 |
Will run the better_model not balanced, with 'gecode' solver |
v3 |
Will run the better_model not balanced, with 'chuffed' solver |
v4 |
Will run the better_model_chan not balanced, with 'chuffed' solver |
v5 |
Will run the circle_met_model not balanced, with 'chuffed' solver |
v6 |
Will run the circle_met_model_chan, not balanced, with 'chuffed' solver |
v7 |
Will run the circle_met_model_chan, balanced with HAP_v1, with 'chuffed' solver |
v8 |
Will run the circle_met_model_chan, balanced with HAP_v2, with 'chuffed' solver |
This is the list of the versions which are available for SMT.
| version | meaning / which implementation is used |
|---|---|
v1 |
Will run the model with the Z3 solver on the pysmt encoding in decision version |
v2 |
Will run the model with the Z3 solver on the pysmt encoding in optimization version |
v3 |
Will run the model with the CVC5 solver on the pysmt encoding in decision version |
v4 |
Will run the model with the CVC5 solver on the pysmt encoding in optimization version |
v5 |
Will run the model with the OptiMathSAT solver on the pysmt encoding in decision version |
v6 |
Will run the model with the OptiMathSAT solver on the pysmt encoding in optimization version |
v7 |
Will run the model with the Z3 solver on the Z3py encoding in decision version |
v8 |
Will run the model with the Z3 solver on the Z3py encoding in optimization version |
v9 |
Will run the model with the CVC5 solver on the Z3py encoding in decision version |
v10 |
Will run the model with the CVC5 solver on the Z3py encoding in optimization version |
v11 |
Will run the model with the OptiMathSAT solver on the Z3py encoding in decision version |
v12 |
Will run the model with the OptiMathSAT solver on the Z3py encoding in optimization version |
Single-version mode
- When just
--versionis passed, that version is run with all the even instances from 4 to 18; - When just
--nis passed, that instance is run with all the twelve versions; - When both
--versionand--nare passed, then the chosen instance on the chosen version is performed; - When none of the two is passed, all the feasible instances will be run, so the one which on the report timeout, will not run.
This is the list of the versions which are available for MIP.
| version | meaning / which implementation is used |
|---|---|
v1 |
the best CBC and GLPK base — feasible model |
v2 |
Useful to verify the behaviour of CBC i!=j and compare it to v1/v3. |
v3 |
the best CBC and GLPK i<j-balanced. |
v4 |
the best CBC and GLPK pre - feasible/balanced. |
v5 |
seed-sensitivity sweep — runs the same CBC base-feasible case over many seeds (0, 1234567, 26, 42, 262626, 424242, 878641, 5656565). Usefull to see how changing seed, changes the the performance of the same model. |
v6 |
GLPK robustness & cuts — multiple GLPK combos (seeds, cuts on/off, base vs i<j) usefull to check the performance of GLPK |
v7 |
Runs a CBC-balanced instance over some seeds using the |
-
Batch mode (no args): the MIP batch writes files into:
/CDMO/res/MIP/{nn}.json -
Single-version mode (when you pass
--versionand--instance) the script writes to:/CDMO/res/additional_tests/{n}.json
If you want a shell inside the image (mounting your source/res), decomment the dev code inside the dockerfile and comment the part about PRODUCTION script.
Build the new image and run the command:
docker run --rm -it \
-v "$(pwd)/source:/CDMO/source" \
-v "$(pwd)/res:/CDMO/res" \
sts-container /bin/bashThen you can run commands manually inside the container, e.g.:
python /CDMO/source/MIP/main.py --instance 8 --version v1