Skip to content

Commit

Permalink
Add name to MPVariable binding for inspect and printing (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbolender authored Dec 3, 2024
1 parent 35b56fc commit 1299899
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/or-tools/math_opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void init_math_opt(Rice::Module& m) {

Rice::define_class_under<Variable>(mathopt, "Variable")
.define_method("id", &Variable::id)
.define_method("name", &Variable::name)
.define_method(
"_eql?",
[](Variable& self, Variable &other) {
Expand Down
7 changes: 7 additions & 0 deletions test/math_opt_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,11 @@ def test_non_integer_solver
end
assert_equal "Glop does not support integer variables", error.message
end

def test_variable_inspect
model = ORTools::MathOpt::Model.new("getting_started_lp")
var = model.add_integer_variable(-1.0, 1.5, "x")

assert_equal "x", var.inspect
end
end

0 comments on commit 1299899

Please sign in to comment.