Skip to content

Commit

Permalink
Merge 5392160 into b5183be
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Oct 17, 2019
2 parents b5183be + 5392160 commit 9006840
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ function MOI.set(
)
info = _info(model, v)
info.name = name
if !isempty(name)
if !isempty(name) && isascii(name)
# Note: GLPK errors if we try to set non-ascii column names.
GLPK.set_col_name(model.inner, info.column, name)
end
model.name_to_variable = nothing
Expand Down Expand Up @@ -1096,7 +1097,8 @@ function MOI.set(
info = _info(model, c)
old_name = info.name
info.name = name
if name != ""
if !isempty(name) && isascii(name)
# Note: GLPK errors if we try to set non-ascii row names.
GLPK.set_row_name(model.inner, info.row, name)
end
model.name_to_constraint_index = nothing
Expand Down
14 changes: 14 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,17 @@ end
@test_throws MOI.InvalidIndex(ci) MOI.get(model, MOI.ConstraintFunction(), ci)
@test_throws MOI.InvalidIndex(ci) MOI.delete(model, ci)
end

@testset "Non-ascii names" begin
model = GLPK.Optimizer()
x = MOI.add_variable(model)
MOI.set(model, MOI.VariableName(), x, "ω")
@test MOI.get(model, MOI.VariableName(), x) == "ω"
c = MOI.add_constraint(
model,
MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, x)], 0.0),
MOI.GreaterThan(0.0)
)
MOI.set(model, MOI.ConstraintName(), c, "ω")
@test MOI.get(model, MOI.ConstraintName(), c) == "ω"
end

0 comments on commit 9006840

Please sign in to comment.