Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance of adding SecondOrderCone constraints #561

Merged
merged 1 commit into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

import MathOptInterface

const MOI = MathOptInterface
const CleverDicts = MOI.Utilities.CleverDicts
import MathOptInterface as MOI
import MathOptInterface.Utilities: CleverDicts

@enum(
_BoundType,
Expand All @@ -18,6 +16,7 @@ const CleverDicts = MOI.Utilities.CleverDicts
_INTERVAL,
_EQUAL_TO
)

@enum(
_ObjectiveType,
_SINGLE_VARIABLE,
Expand Down Expand Up @@ -4292,13 +4291,13 @@ function MOI.add_constraint(

# First, check the lower bound on t.
t_info = _info(model, f.variables[1])
lb = _get_variable_lower_bound(model, t_info)
if isnan(t_info.lower_bound_if_soc) && lb < 0.0
# If `t_info.lower_bound_if_bounded` is active, this just makes
# `t_info.lower_bound_if_soc` equal to it. If `lower_bound_if_bounded`
# is set after, then it will call `_set_variable_lower_bound` and
# update `lower_bound_if_soc` accordingly.
t_info.lower_bound_if_soc = lb
# Check `.lower_bound_if_bounded` instead of `_get_variable_lower_bound` so
# that we don't incur a call to `GRBupdate`.
lb = t_info.lower_bound_if_bounded
if isnan(t_info.lower_bound_if_soc) && (isnan(lb) || lb < 0.0)
# If `isnan(lb)`, then we haven't set a bound. The default should be
# Gurobi's default. This is necessary for when we delete SOC constraints.
t_info.lower_bound_if_soc = isnan(lb) ? -GRB_INFINITY : lb
ret = GRBsetdblattrelement(model, "LB", Cint(t_info.column - 1), 0.0)
_check_ret(model, ret)
end
Expand Down
Loading