Skip to content

Commit 4b294ca

Browse files
committed
Add _reset to call GRBreset for Gurobi
1 parent ee0d11b commit 4b294ca

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

include/pyoptinterface/gurobi_model.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define APILIST \
1616
B(GRBnewmodel); \
1717
B(GRBfreemodel); \
18+
B(GRBreset); \
1819
B(GRBgetenv); \
1920
B(GRBwrite); \
2021
B(GRBaddvar); \
@@ -150,6 +151,8 @@ class GurobiModel : public OnesideLinearConstraintMixin<GurobiModel>,
150151
void init(const GurobiEnv &env);
151152
void close();
152153

154+
void _reset(int clearall);
155+
153156
double get_infinity() const;
154157

155158
void write(const std::string &filename);

lib/gurobi_model.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ void GurobiModel::close()
187187
m_model.reset();
188188
}
189189

190+
void GurobiModel::_reset(int clearall)
191+
{
192+
int error = gurobi::GRBreset(m_model.get(), clearall);
193+
check_error(error);
194+
}
195+
190196
double GurobiModel::get_infinity() const
191197
{
192198
return GRB_INFINITY;

lib/gurobi_model_ext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ NB_MODULE(gurobi_model_ext, m)
4242
BIND_F(close)
4343
BIND_F(write)
4444
// clang-format on
45+
.def("_reset", &GurobiModel::_reset, nb::arg("clearall") = 0)
4546

4647
.def("add_variable", &GurobiModel::add_variable,
4748
nb::arg("domain") = VariableDomain::Continuous, nb::arg("lb") = -GRB_INFINITY,

0 commit comments

Comments
 (0)