Skip to content

Commit db70ec6

Browse files
committed
Add _converttofixed for Gurobi
1 parent 643c266 commit db70ec6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

include/pyoptinterface/gurobi_model.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
B(GRBemptyenv); \
6767
B(GRBloadenv); \
6868
B(GRBfreeenv); \
69-
B(GRBstartenv);
69+
B(GRBstartenv); \
70+
B(GRBconverttofixed);
7071

7172
namespace gurobi
7273
{
@@ -251,6 +252,9 @@ class GurobiModel
251252
double get_objective_coefficient(const VariableIndex &variable);
252253
void set_objective_coefficient(const VariableIndex &variable, double value);
253254

255+
// Gurobi-specific convertofixed
256+
void _converttofixed();
257+
254258
// Non-exported functions
255259
void check_error(int error);
256260

lib/gurobi_model.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,12 @@ void GurobiModel::set_objective_coefficient(const VariableIndex &variable, doubl
950950
set_variable_raw_attribute_double(variable, GRB_DBL_ATTR_OBJ, value);
951951
}
952952

953+
void GurobiModel::_converttofixed()
954+
{
955+
int error = gurobi::GRBconverttofixed(m_model.get());
956+
check_error(error);
957+
}
958+
953959
int GurobiModel::_constraint_index(const ConstraintIndex &constraint)
954960
{
955961
_update_for_constraint_index(constraint.type);

lib/gurobi_model_ext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ NB_MODULE(gurobi_model_ext, m)
203203
BIND_F(set_normalized_coefficient)
204204
BIND_F(get_objective_coefficient)
205205
BIND_F(set_objective_coefficient)
206+
207+
BIND_F(_converttofixed)
206208
// clang-format on
207209
;
208210
}

0 commit comments

Comments
 (0)