Skip to content

Commit

Permalink
Remove ConstraintName for VariableIndex constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Mar 20, 2024
1 parent 0d0f0dd commit c512e5b
Showing 1 changed file with 1 addition and 53 deletions.
54 changes: 1 addition & 53 deletions src/MOI/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,7 @@ mutable struct VariableInfo
type::VariableType
start::Union{Float64,Nothing}
name::String
# Storage for constraint names associated with variables because Xpress can
# only store names for variables and proper constraints. We can perform an
# optimization and only store three strings for the constraint names
# because, at most, there can be three VariableIndex constraints, e.g.,
# LessThan, GreaterThan, and Integer.
lessthan_name::String
greaterthan_interval_or_equalto_name::String
type_constraint_name::String

# Storage for the lower bound if the variable is the `t` variable in a
# second order cone.
lower_bound_if_soc::Float64
Expand All @@ -73,9 +66,6 @@ mutable struct VariableInfo
CONTINUOUS,
nothing,
"",
"",
"",
"",
NaN,
0,
false,
Expand Down Expand Up @@ -1560,7 +1550,6 @@ function MOI.delete(
else
info.bound = NONE
end
info.lessthan_name = ""
model.name_to_constraint_index = nothing
if info.type == BINARY
@checked Lib.XPRSchgcoltype(
Expand Down Expand Up @@ -1792,7 +1781,6 @@ function MOI.delete(
else
info.bound = NONE
end
info.greaterthan_interval_or_equalto_name = ""
model.name_to_constraint_index = nothing
if info.type == BINARY
@checked Lib.XPRSchgcoltype(
Expand All @@ -1816,7 +1804,6 @@ function MOI.delete(
_set_variable_upper_bound(model, info, Inf)
info.previous_upper_bound = Inf
info.bound = NONE
info.greaterthan_interval_or_equalto_name = ""
model.name_to_constraint_index = nothing
if info.type == BINARY
@checked Lib.XPRSchgcoltype(
Expand All @@ -1840,7 +1827,6 @@ function MOI.delete(
_set_variable_upper_bound(model, info, Inf)
info.previous_upper_bound = Inf
info.bound = NONE
info.greaterthan_interval_or_equalto_name = ""
model.name_to_constraint_index = nothing
if info.type == BINARY
@checked Lib.XPRSchgcoltype(
Expand Down Expand Up @@ -1998,7 +1984,6 @@ function MOI.delete(
_set_variable_upper_bound(model, info, info.previous_upper_bound)
end
info.type = CONTINUOUS
info.type_constraint_name = ""
model.name_to_constraint_index = nothing
return
end
Expand Down Expand Up @@ -2041,7 +2026,6 @@ function MOI.delete(
Ref(UInt8('C')),
)
info.type = CONTINUOUS
info.type_constraint_name = ""
model.name_to_constraint_index = nothing
return
end
Expand Down Expand Up @@ -2093,7 +2077,6 @@ function MOI.delete(
_set_variable_upper_bound(model, info, Inf)
info.semi_lower_bound = NaN
info.type = CONTINUOUS
info.type_constraint_name = ""
model.name_to_constraint_index = nothing
return
end
Expand Down Expand Up @@ -2148,7 +2131,6 @@ function MOI.delete(
_set_variable_upper_bound(model, info, Inf)
info.semi_lower_bound = NaN
info.type = CONTINUOUS
info.type_constraint_name = ""
model.name_to_constraint_index = nothing
return
end
Expand Down Expand Up @@ -2496,7 +2478,6 @@ function _rebuild_name_to_constraint_index(model::Optimizer)
model.sos_constraint_info,
MOI.VectorOfVariables,
)
_rebuild_name_to_constraint_index_variables(model)
return
end

Expand Down Expand Up @@ -2554,39 +2535,6 @@ function _rebuild_name_to_constraint_index_util(model::Optimizer, dict, F)
return
end

function _rebuild_name_to_constraint_index_variables(model::Optimizer)
for (key, info) in model.variable_info
for S in (
MOI.LessThan{Float64},
MOI.GreaterThan{Float64},
MOI.EqualTo{Float64},
MOI.Interval{Float64},
MOI.ZeroOne,
MOI.Integer,
MOI.Semicontinuous{Float64},
MOI.Semiinteger{Float64},
)
constraint_name = ""
if info.bound in _bound_enums(S)
constraint_name =
S == MOI.LessThan{Float64} ? info.lessthan_name :
info.greaterthan_interval_or_equalto_name
elseif info.type in _type_enums(S)
constraint_name = info.type_constraint_name
end
if constraint_name == ""
continue
elseif haskey(model.name_to_constraint_index, constraint_name)
model.name_to_constraint_index[constraint_name] = nothing
else
model.name_to_constraint_index[constraint_name] =
MOI.ConstraintIndex{MOI.VariableIndex,S}(key.value)
end
end
end
return
end

###
### VectorAffineFunction-in-INDICATOR_SET
###
Expand Down

0 comments on commit c512e5b

Please sign in to comment.