# Quick reference How to call cbls, as a command or a library, and what it prints. ## Terminal ```bash # Build the C++ CLI, ./build/cbls, from a clone git clone https://github.com/spoorendonk/cbls && cd cbls cmake -B build cmake --build build -j4 # Install for Python: import cbls, and the cbls command (needs a C++17 compiler and zlib) pip install git+https://github.com/spoorendonk/cbls # Solve a file: .cbls, .mps, .mps.gz or .nl (also python -m cbls; ./build/cbls: .cbls only) cbls examples/simple.cbls --time-limit 1 # Every option and default, and the exit status (the same for python -m cbls and ./build/cbls) cbls --help ``` A MINLPLib `.nl` file (`st_e38`, a pressure-vessel design, optimum 7197.727149) and a MIPLIB `.mps.gz` file (`neos5`, 63 columns), from a clone's root; the test suite runs both lines: ```bash cbls benchmarks/instances/minlplib/st_e38.nl --time-limit 2 --threads 1 --seed 42 --quiet cbls benchmarks/instances/miplib-fj/neos5.mps.gz --time-limit 2 --threads 1 --seed 42 --format jsonl --quiet ``` - **Output.** `--format human`: progress rows (`*` on a new best), then `Status:`, `Objective:`, `Time:` and `Solution:` lines. `--format jsonl`: one JSON object per line, `start`, `progress`, then `result` with `status`, `feasible`, `objective` (null when none), `termination`, `time`, `iterations` and `solution` (its names sorted as text: `d1`, `d10`, `d11`, ...). - **Exit status.** 0 when a feasible point was found; 1 when not, and on a bad argument or model file (the message on stderr). ## Python ```python import cbls # Build a model and solve it, any option as a keyword m = cbls.Model() x, y = m.Int(0, 10, "x"), m.Float(0, 10, "y") m.add_constraint(x + y >= 3) m.minimize(x * x + y) m.close() result = cbls.solve(m, time_limit=1, seed=42, threads=1) print(result.feasible, result.objective, result.value(x)) # Load a file, one loader per format (paths from a clone's root) model = cbls.load_model("examples/simple.cbls") converted = cbls.nl_to_model(cbls.read_nl("benchmarks/instances/minlplib/st_e38.nl")) # converted = cbls.mps_to_model(cbls.read_mps("benchmarks/instances/miplib-fj/neos5.mps.gz")) result = cbls.solve(converted.model, time_limit=2) print(result.feasible, converted.original_values()) # one value per file column ``` - **`.nl` files.** Solve one only if `converted.supported`; else `converted.skipped_reasons` names the operators cbls does not model. A maximisation keeps its sense in `result.objective`; `result.search.objective` is the engine's minimised value. - **`.mps` files.** Infinite bounds are derived from the rows where they can be, else clamped to 1e9, which can cut off solutions (`converted.n_clamped_columns` counts them). `OBJSENSE MAX` is refused: negate the costs. - **Whole programs** that solve a file and verify the point independently: [`examples/minlplib.py`](https://github.com/spoorendonk/cbls/blob/main/examples/minlplib.py), [`examples/mip.py`](https://github.com/spoorendonk/cbls/blob/main/examples/mip.py), and their C++ versions beside them. ## C++ Link the target `cbls::cbls`: the [C++ reference](cpp.md#using-it-from-cmake) has the CMake file. Reference: [C++](cpp.md), [Python](https://spoorendonk.dk/cbls/autoapi/cbls/index.html); all the docs as text: , .