diff --git a/changelog.md b/changelog.md index 3c84d97e..e3b414f2 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- [PR40](https://github.com/scipopt/SCIPpp/pull/40) `Model::addSolution()`, `Model::setObjsense()`, `Model::setParam()`, + and `Model::solve()` are now const member functions. - [PR38](https://github.com/scipopt/SCIPpp/pull/38) Update to SCIP 10.0.0. ## [1.3.0] - 2025-10-08 diff --git a/include/scippp/model.hpp b/include/scippp/model.hpp index cac360ea..5df6272c 100644 --- a/include/scippp/model.hpp +++ b/include/scippp/model.hpp @@ -47,7 +47,7 @@ class Model { //! Constraints. std::vector m_cons {}; //! Stores the return of the last %SCIP call when the default call wrapper is used. - SCIP_Retcode m_lastReturnCode; + mutable SCIP_Retcode m_lastReturnCode; //! Wrapper for every call to %SCIP's %C %API. std::function m_scipCallWrapper; @@ -204,14 +204,14 @@ class Model { * Solve the model. * @since 1.0.0 */ - void solve(); + void solve() const; /** * Set objective goal. * @since 1.0.0 * @param objsense Minimize or Maximize. */ - void setObjsense(Sense objsense); + void setObjsense(Sense objsense) const; /** * Returns the solution status. @@ -270,7 +270,7 @@ class Model { * @param value to set the parameter to. */ template - void setParam(params::Param parameter, T value) + void setParam(params::Param parameter, T value) const { auto ptValue { static_cast(value) }; const auto* cName { parameter.scipName.data() }; @@ -346,6 +346,6 @@ class Model { bool completely = true, bool checkBounds = true, bool checkIntegrality = true, - bool checkLpRows = true); + bool checkLpRows = true) const; }; } diff --git a/source/model.cpp b/source/model.cpp index 84117cbd..23ba905f 100644 --- a/source/model.cpp +++ b/source/model.cpp @@ -105,12 +105,12 @@ bool Model::isZero(SCIP_Real value) const return SCIPisZero(m_scip, value); } -void Model::solve() +void Model::solve() const { m_scipCallWrapper(SCIPsolve(m_scip)); } -void Model::setObjsense(Sense objsense) +void Model::setObjsense(Sense objsense) const { m_scipCallWrapper(SCIPsetObjsense(m_scip, static_cast(objsense))); } @@ -156,7 +156,7 @@ bool Model::addSolution( bool completely, bool checkBounds, bool checkIntegrality, - bool checkLpRows) + bool checkLpRows) const { SCIP_Sol* sol { nullptr }; m_scipCallWrapper(SCIPcreateSol(m_scip, &sol, nullptr));