SCIP++ is a C++ wrapper for SCIP's C interface. It automatically manages the memory, and provides a simple interface to create linear expressions and inequalities.
The documentation can be found at https://scipopt.github.io/SCIPpp/
Here is a simple example where we create a new model, add two variables, add a linear inequality as constraint, and ask SCIP to solve the maximization problem.
A model can be created
Variables can be added
When adding multiple variables simultaneously to the model, they all have a coefficient of zero in the objective function by default. This can be changed to one by scippp::COEFF_ONE
:
For the coefficient, any object providing an index operator can be used:
Linear inequalities can be added to the model. They can be built from linear expressions:
The namespace scippp::params
contains all parameters shown https://www.scipopt.org/doc/html/PARAMETERS.php in the header parameters.hpp
. They are strongly typed, so that no string can be set as the value for a parameter expecting an integer. Instead of using the predefined parameters, one can also use scippp::params::Param<T>
directly.
The optimization goal can be changed by:
A model can be asked for the status and the number of solutions. A variable can be asked for its value in a given solution as
getSolVal(sol)
.getSolValAsInt(sol)
.getSolValAsLongInt(sol)
, andisZero(sol)
.A model can be written to file via Model::writeOrigProblem
if a std::filesystem::directory_entry
is given as argument. If it is just a string representing a file extension, it is written to standard output.
The model exposes
SCIPepsilon
via epsilon()
,SCIPround
via round(double)
, andSCIPisZero
via isZero(double)
Use the Statistics<T>
objects from the header solving_statistics.hpp to access solving statistics in a type-safe way:
For features not yet supported by SCIP++, one can access the underlying raw SCIP object via
We use Conan as package manager. That is not required! As long as find_package(scip CONFIG REQUIRED)
(and find_package(Boost CONFIG REQUIRED)
for the tests) work(s), any kind of dependency management system can be used.
Build and install:
Build and run tests:
Build and install:
Build and run tests:
If your setting of OS, compiler, C++ or stdlib version is one where conan-center does not host pre-compiled binaries, add --build=missing
when you run conan install
. The dependencies will then be built from source (don't worry, they will be available only for projects using conan, they do not interfere with versions you might already have installed on the system). So, when you see an error message like
change the install-command to
When CMake presets are not support, use the toolchain file that conan generates.
Build and install:
Build and run tests:
Use gen_constexpr_parameters
to transform all SCIP parameters into constexpr scippp::params::Param<T>
objects which can be added to the parameters.hpp
header.
Use extract_solvingstats
to transform all SCIP methods that access solving statistics into static const scippp::statistics::Statistic<T>
objects which can be added to the solving_statistics.hpp
header.
This project is maintained by Ivo Hedtke ivo (dot) hedtke (at) dbschenker (dot) com
.
SCIP++ follows the Contributor Covenant Code of Conduct v2, see code_of_conduct.md.
This project does not use a CLA.
SCIP++ is licensed under the Apache-2 license, see [LICENSE](LICENSE).