diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 5d6283b2..305a79ea 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v3 - uses: ssciwr/doxygen-install@v1 with: - version: "1.20.0" + version: "1.12.0" - uses: ts-graphviz/setup-graphviz@v1 - name: Prepare Doxygen Config run: echo "PROJECT_NUMBER = ${GITHUB_REF}" >> Doxyfile diff --git a/changelog.md b/changelog.md index 6a1c2b9c..38ac2aca 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [PR27](https://github.com/scipopt/SCIPpp/pull/27) Update to SCIP 9.2.0. +## Added + +- [PR28](https://github.com/scipopt/SCIPpp/pull/28) Add `Var::getVar`. + ## [1.2.0] - 2024-05-21 ### Changed diff --git a/include/scippp/var.hpp b/include/scippp/var.hpp index 7a5675a5..3f657926 100644 --- a/include/scippp/var.hpp +++ b/include/scippp/var.hpp @@ -15,8 +15,27 @@ struct Solution; * @since 1.0.0 */ struct Var { - //! Pointer to the underlying %SCIP variable. + /** + * Pointer to the underlying %SCIP variable. + * @deprecated since 1.3.0: Use #getVar() instead + */ SCIP_Var* var { nullptr }; + + /** + * Pointer to the underlying %SCIP variable. + * @since 1.3.0 + * @return underlying %SCIP variable. + */ + [[nodiscard]] SCIP_Var* getVar(); + + /** + * Pointer to the underlying %SCIP variable. + * + * @since 1.3.0 + * @return underlying %SCIP variable. + */ + [[nodiscard]] SCIP_Var* const getVar() const; + /** * Get the assigned value in the solution. * @since 1.0.0 diff --git a/source/model.cpp b/source/model.cpp index bd504ee3..4553f92f 100644 --- a/source/model.cpp +++ b/source/model.cpp @@ -79,7 +79,7 @@ void Model::addConstr(const scippp::LinIneq& ineq, const std::string& name) ineq.m_lhs, /* left hand side of constraint */ ineq.m_rhs.has_value() ? ineq.m_rhs.value() : infinity())); for (size_t index { 0 }; index < ineq.m_linExpr.m_vars.size(); index++) { - m_scipCallWrapper(SCIPaddCoefLinear(m_scip, con, ineq.m_linExpr.m_vars.at(index).var, ineq.m_linExpr.m_coeffs.at(index))); + m_scipCallWrapper(SCIPaddCoefLinear(m_scip, con, ineq.m_linExpr.m_vars.at(index).getVar(), ineq.m_linExpr.m_coeffs.at(index))); } m_scipCallWrapper(SCIPaddCons(m_scip, con)); m_cons.push_back(con); diff --git a/source/var.cpp b/source/var.cpp index 21298846..c41ba0ab 100644 --- a/source/var.cpp +++ b/source/var.cpp @@ -1,11 +1,22 @@ #include "scippp/var.hpp" #include "scippp/solution.hpp" + #include #include namespace scippp { +SCIP_Var* Var::getVar() +{ + return var; +} + +SCIP_Var* const Var::getVar() const +{ + return var; +} + double Var::getSolVal(const Solution& sol) const { return SCIPgetSolVal(sol.scip, sol.sol, var); diff --git a/test/test_var.cpp b/test/test_var.cpp index fb516f30..fa79d887 100644 --- a/test/test_var.cpp +++ b/test/test_var.cpp @@ -66,6 +66,7 @@ BOOST_AUTO_TEST_CASE(IsVoid) { scippp::Var x; BOOST_TEST(x.var == nullptr); + BOOST_TEST(x.getVar() == nullptr); BOOST_TEST(x.isVoid()); Model model("Simple");