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

Make some moi_xxx functions private #2548

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
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
22 changes: 9 additions & 13 deletions src/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,9 @@ end
unsafe_backend(model::MOIB.LazyBridgeOptimizer) = unsafe_backend(model.model)
unsafe_backend(model::MOI.ModelLike) = model

"""
moi_mode(model::MOI.ModelLike)
_moi_mode(model::MOI.ModelLike) = DIRECT

Return the `ModelMode` of `model`.
"""
moi_mode(model::MOI.ModelLike) = DIRECT
function moi_mode(model::MOIU.CachingOptimizer)
function _moi_mode(model::MOIU.CachingOptimizer)
if model.mode == MOIU.AUTOMATIC
return AUTOMATIC
else
Expand All @@ -483,17 +479,17 @@ Return the [`ModelMode`](@ref) ([`DIRECT`](@ref), [`AUTOMATIC`](@ref), or
"""
function mode(model::Model)
# The type of `backend(model)` is not type-stable, so we use a function
# barrier (`moi_mode`) to improve performance.
return moi_mode(backend(model))
# barrier (`_moi_mode`) to improve performance.
return _moi_mode(backend(model))
end

"""
moi_bridge_constraints(model::MOI.ModelLike)
_moi_bridge_constraints(model::MOI.ModelLike)

Return `true` if `model` will bridge constraints.
"""
moi_bridge_constraints(model::MOI.ModelLike) = false
function moi_bridge_constraints(model::MOIU.CachingOptimizer)
_moi_bridge_constraints(model::MOI.ModelLike) = false
function _moi_bridge_constraints(model::MOIU.CachingOptimizer)
return model.optimizer isa MOI.Bridges.LazyBridgeOptimizer
end

Expand Down Expand Up @@ -540,8 +536,8 @@ available.
"""
function bridge_constraints(model::Model)
# The type of `backend(model)` is not type-stable, so we use a function
# barrier (`moi_bridge_constraints`) to improve performance.
return moi_bridge_constraints(backend(model))
# barrier (`_moi_bridge_constraints`) to improve performance.
return _moi_bridge_constraints(backend(model))
end

function _moi_add_bridge(
Expand Down
8 changes: 4 additions & 4 deletions src/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,15 @@ function check_belongs_to_model(con::VectorConstraint, model)
end
end

function moi_add_constraint(
function _moi_add_constraint(
model::MOI.ModelLike,
f::MOI.AbstractFunction,
s::MOI.AbstractSet,
)
if !MOI.supports_constraint(model, typeof(f), typeof(s))
if moi_mode(model) == DIRECT
if _moi_mode(model) == DIRECT
bridge_message = "."
elseif moi_bridge_constraints(model)
elseif _moi_bridge_constraints(model)
error(
sprint(
io -> MOI.Bridges.debug(
Expand Down Expand Up @@ -556,7 +556,7 @@ function add_constraint(
# function.
check_belongs_to_model(con, model)
func, set = moi_function(con), moi_set(con)
cindex = moi_add_constraint(
cindex = _moi_add_constraint(
backend(model),
func,
set,
Expand Down
2 changes: 1 addition & 1 deletion src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function _precompile_()
)
for (F, S) in constraints
Base.precompile(
moi_add_constraint,
JuMP._moi_add_constraint,
(
MOIU.CachingOptimizer{
MOI.AbstractOptimizer,
Expand Down