From 05544a1fc6c7b5a32afd085ea429629e458d508f Mon Sep 17 00:00:00 2001 From: Ivo Hedtke Date: Fri, 8 Nov 2024 17:29:40 +0100 Subject: [PATCH 1/5] Add Var::getVar --- include/scippp/var.hpp | 21 ++++++++++++++++++++- source/var.cpp | 11 +++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/scippp/var.hpp b/include/scippp/var.hpp index 7a5675a5..9d783ac9 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]] const SCIP_Var* getVar() const; + /** * Get the assigned value in the solution. * @since 1.0.0 diff --git a/source/var.cpp b/source/var.cpp index 21298846..95eb40c6 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; +} + +const SCIP_Var* Var::getVar() const +{ + return var; +} + double Var::getSolVal(const Solution& sol) const { return SCIPgetSolVal(sol.scip, sol.sol, var); From 244fca977089ce80e0dbf240340af2311e279b0c Mon Sep 17 00:00:00 2001 From: Ivo Hedtke Date: Fri, 8 Nov 2024 17:33:15 +0100 Subject: [PATCH 2/5] Add test for getVar --- changelog.md | 4 ++++ test/test_var.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index 6a1c2b9c..7e1d1cae 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/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"); From f70366ca28d5d8ee94651d67b97d555de594f083 Mon Sep 17 00:00:00 2001 From: Ivo Hedtke Date: Mon, 11 Nov 2024 11:29:49 +0100 Subject: [PATCH 3/5] Fix const version of getVar --- include/scippp/var.hpp | 2 +- source/model.cpp | 2 +- source/var.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/scippp/var.hpp b/include/scippp/var.hpp index 9d783ac9..3f657926 100644 --- a/include/scippp/var.hpp +++ b/include/scippp/var.hpp @@ -34,7 +34,7 @@ struct Var { * @since 1.3.0 * @return underlying %SCIP variable. */ - [[nodiscard]] const SCIP_Var* getVar() const; + [[nodiscard]] SCIP_Var* const getVar() const; /** * Get the assigned value in the solution. 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 95eb40c6..c41ba0ab 100644 --- a/source/var.cpp +++ b/source/var.cpp @@ -12,7 +12,7 @@ SCIP_Var* Var::getVar() return var; } -const SCIP_Var* Var::getVar() const +SCIP_Var* const Var::getVar() const { return var; } From 444d4e7fd4de857d2e91981a8a9630592d25bad3 Mon Sep 17 00:00:00 2001 From: Ivo Hedtke Date: Thu, 14 Nov 2024 15:46:05 +0100 Subject: [PATCH 4/5] Fix changelog style --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 7e1d1cae..38ac2aca 100644 --- a/changelog.md +++ b/changelog.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Added -- [PR28](https://github.com/scipopt/SCIPpp/pull/28) Add `Var::getVar()`. +- [PR28](https://github.com/scipopt/SCIPpp/pull/28) Add `Var::getVar`. ## [1.2.0] - 2024-05-21 From 1ead5409db4c3986dadb0f9fe820071b54c0f237 Mon Sep 17 00:00:00 2001 From: Ivo Hedtke Date: Thu, 14 Nov 2024 15:56:19 +0100 Subject: [PATCH 5/5] Fix doxygen version in pages workflow --- .github/workflows/pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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