Skip to content

Commit 6f9ddd7

Browse files
authored
Merge pull request #28 from scipopt/hedtle-prep-hide-var
Add Var::getVar
2 parents 3a42529 + 1ead540 commit 6f9ddd7

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v3
1212
- uses: ssciwr/doxygen-install@v1
1313
with:
14-
version: "1.20.0"
14+
version: "1.12.0"
1515
- uses: ts-graphviz/setup-graphviz@v1
1616
- name: Prepare Doxygen Config
1717
run: echo "PROJECT_NUMBER = ${GITHUB_REF}" >> Doxyfile

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
- [PR27](https://github.com/scipopt/SCIPpp/pull/27) Update to SCIP 9.2.0.
1010

11+
## Added
12+
13+
- [PR28](https://github.com/scipopt/SCIPpp/pull/28) Add `Var::getVar`.
14+
1115
## [1.2.0] - 2024-05-21
1216

1317
### Changed

include/scippp/var.hpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,27 @@ struct Solution;
1515
* @since 1.0.0
1616
*/
1717
struct Var {
18-
//! Pointer to the underlying %SCIP variable.
18+
/**
19+
* Pointer to the underlying %SCIP variable.
20+
* @deprecated since 1.3.0: Use #getVar() instead
21+
*/
1922
SCIP_Var* var { nullptr };
23+
24+
/**
25+
* Pointer to the underlying %SCIP variable.
26+
* @since 1.3.0
27+
* @return underlying %SCIP variable.
28+
*/
29+
[[nodiscard]] SCIP_Var* getVar();
30+
31+
/**
32+
* Pointer to the underlying %SCIP variable.
33+
*
34+
* @since 1.3.0
35+
* @return underlying %SCIP variable.
36+
*/
37+
[[nodiscard]] SCIP_Var* const getVar() const;
38+
2039
/**
2140
* Get the assigned value in the solution.
2241
* @since 1.0.0

source/model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void Model::addConstr(const scippp::LinIneq& ineq, const std::string& name)
7979
ineq.m_lhs, /* left hand side of constraint */
8080
ineq.m_rhs.has_value() ? ineq.m_rhs.value() : infinity()));
8181
for (size_t index { 0 }; index < ineq.m_linExpr.m_vars.size(); index++) {
82-
m_scipCallWrapper(SCIPaddCoefLinear(m_scip, con, ineq.m_linExpr.m_vars.at(index).var, ineq.m_linExpr.m_coeffs.at(index)));
82+
m_scipCallWrapper(SCIPaddCoefLinear(m_scip, con, ineq.m_linExpr.m_vars.at(index).getVar(), ineq.m_linExpr.m_coeffs.at(index)));
8383
}
8484
m_scipCallWrapper(SCIPaddCons(m_scip, con));
8585
m_cons.push_back(con);

source/var.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#include "scippp/var.hpp"
22

33
#include "scippp/solution.hpp"
4+
45
#include <scip/scip_numerics.h>
56
#include <scip/scip_sol.h>
67

78
namespace scippp {
89

10+
SCIP_Var* Var::getVar()
11+
{
12+
return var;
13+
}
14+
15+
SCIP_Var* const Var::getVar() const
16+
{
17+
return var;
18+
}
19+
920
double Var::getSolVal(const Solution& sol) const
1021
{
1122
return SCIPgetSolVal(sol.scip, sol.sol, var);

test/test_var.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ BOOST_AUTO_TEST_CASE(IsVoid)
6666
{
6767
scippp::Var x;
6868
BOOST_TEST(x.var == nullptr);
69+
BOOST_TEST(x.getVar() == nullptr);
6970
BOOST_TEST(x.isVoid());
7071

7172
Model model("Simple");

0 commit comments

Comments
 (0)