Skip to content

Commit 781cbfb

Browse files
authored
Merge pull request #40 from scipopt/ivhedtke-mutable-last-return
Make lastReturnCode mutable
2 parents 6ab0c12 + 33b2e42 commit 781cbfb

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

changelog.md

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

77
### Changed
88

9+
- [PR40](https://github.com/scipopt/SCIPpp/pull/40) `Model::addSolution()`, `Model::setObjsense()`, `Model::setParam()`,
10+
and `Model::solve()` are now const member functions.
911
- [PR38](https://github.com/scipopt/SCIPpp/pull/38) Update to SCIP 10.0.0.
1012

1113
## [1.3.0] - 2025-10-08

conanfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def requirements(self):
8080
def generate(self):
8181
tc = CMakeToolchain(self)
8282
tc.variables[self.name + "_version"] = self.version
83-
tc.variables["BUILD_TESTS"] = self.options.with_tests
84-
tc.variables["BUILD_UTILS"] = self.options.with_utils
83+
tc.cache_variables["BUILD_TESTS"] = self.options.with_tests
84+
tc.cache_variables["BUILD_UTILS"] = self.options.with_utils
8585
tc.generate()
8686

8787
def build(self):

include/scippp/model.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Model {
4747
//! Constraints.
4848
std::vector<SCIP_Cons*> m_cons {};
4949
//! Stores the return of the last %SCIP call when the default call wrapper is used.
50-
SCIP_Retcode m_lastReturnCode;
50+
mutable SCIP_Retcode m_lastReturnCode;
5151
//! Wrapper for every call to %SCIP's %C %API.
5252
std::function<void(SCIP_Retcode)> m_scipCallWrapper;
5353

@@ -204,14 +204,14 @@ class Model {
204204
* Solve the model.
205205
* @since 1.0.0
206206
*/
207-
void solve();
207+
void solve() const;
208208

209209
/**
210210
* Set objective goal.
211211
* @since 1.0.0
212212
* @param objsense Minimize or Maximize.
213213
*/
214-
void setObjsense(Sense objsense);
214+
void setObjsense(Sense objsense) const;
215215

216216
/**
217217
* Returns the solution status.
@@ -270,7 +270,7 @@ class Model {
270270
* @param value to set the parameter to.
271271
*/
272272
template <typename T, typename PT>
273-
void setParam(params::Param<PT> parameter, T value)
273+
void setParam(params::Param<PT> parameter, T value) const
274274
{
275275
auto ptValue { static_cast<PT>(value) };
276276
const auto* cName { parameter.scipName.data() };
@@ -346,6 +346,6 @@ class Model {
346346
bool completely = true,
347347
bool checkBounds = true,
348348
bool checkIntegrality = true,
349-
bool checkLpRows = true);
349+
bool checkLpRows = true) const;
350350
};
351351
}

source/model.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ bool Model::isZero(SCIP_Real value) const
105105
return SCIPisZero(m_scip, value);
106106
}
107107

108-
void Model::solve()
108+
void Model::solve() const
109109
{
110110
m_scipCallWrapper(SCIPsolve(m_scip));
111111
}
112112

113-
void Model::setObjsense(Sense objsense)
113+
void Model::setObjsense(Sense objsense) const
114114
{
115115
m_scipCallWrapper(SCIPsetObjsense(m_scip, static_cast<SCIP_Objsense>(objsense)));
116116
}
@@ -156,7 +156,7 @@ bool Model::addSolution(
156156
bool completely,
157157
bool checkBounds,
158158
bool checkIntegrality,
159-
bool checkLpRows)
159+
bool checkLpRows) const
160160
{
161161
SCIP_Sol* sol { nullptr };
162162
m_scipCallWrapper(SCIPcreateSol(m_scip, &sol, nullptr));

0 commit comments

Comments
 (0)