Skip to content

Commit dd7ec50

Browse files
committed
Update
1 parent 7b302bb commit dd7ec50

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

src/Interfaces/MOI/variables.jl

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,6 @@ function MOI.add_variable(m::Optimizer{T}) where{T}
3838
return x
3939
end
4040

41-
# TODO: dispatch to inner model
42-
function MOI.add_variables(m::Optimizer, N::Int)
43-
N >= 0 || error("Cannot add negative number of variables")
44-
45-
N == 0 && return MOI.VariableIndex[]
46-
47-
vars = Vector{MOI.VariableIndex}(undef, N)
48-
for j in 1:N
49-
x = MOI.add_variable(m)
50-
vars[j] = x
51-
end
52-
53-
return vars
54-
end
55-
56-
5741
# =============================================
5842
# 3. Delete variables
5943
# =============================================
@@ -111,13 +95,16 @@ function MOI.set(m::Optimizer, ::MOI.VariableName, v::MOI.VariableIndex, name::S
11195
# Check that variable does exist
11296
MOI.throw_if_not_valid(m, v)
11397

114-
s = get!(m.name2var, name, Set{MOI.VariableIndex}())
115-
11698
# Update inner model
11799
j = m.var_indices[v]
118100
old_name = get_attribute(m.inner, VariableName(), j)
101+
if name == old_name
102+
return # It's the same name!
103+
end
119104
set_attribute(m.inner, VariableName(), j, name)
120105

106+
s = get!(m.name2var, name, Set{MOI.VariableIndex}())
107+
121108
# Update names mapping
122109
push!(s, v)
123110
# Delete old name

test/Interfaces/MOI_wrapper.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ end
3434
exclude = Any[MOI.ConstraintBasisStatus, MOI.VariableBasisStatus],
3535
),
3636
exclude=[
37-
r"^test_model_Name_VariableName_ConstraintName$",
3837
r"^test_conic_NormInfinityCone_INFEASIBLE$",
3938
r"^test_conic_NormOneCone_INFEASIBLE$",
4039
],

0 commit comments

Comments
 (0)