Skip to content
Merged
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
5 changes: 5 additions & 0 deletions perf/bellman_ford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,39 @@ function MOI.supports_constraint(
) where {T}
return false
end

function MOI.supports_constraint(
::SDPAModel{T},
::Type{MOI.VariableIndex},
::Type{MOI.LessThan{T}},
) where {T}
return false
end

function MOI.supports_constraint(
::SDPAModel{T},
::Type{MOI.VariableIndex},
::Type{MOI.EqualTo{T}},
) where {T}
return false
end

function MOI.supports_constraint(
::SDPAModel{T},
::Type{MOI.VariableIndex},
::Type{MOI.Interval{T}},
) where {T}
return false
end

function MOI.supports_constraint(
::SDPAModel,
::Type{MOI.VectorOfVariables},
::Type{MOI.Reals},
)
return false
end

function MOI.supports(
::SDPAModel{T},
::MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{T}},
Expand Down
1 change: 1 addition & 0 deletions src/Bridges/Constraint/single_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function MOI.Bridges.is_bridged(
return MOI.Bridges.is_bridged(b, MOI.VariableIndex, S) &&
haskey(Constraint.bridges(b), ci)
end

function MOI.Bridges.is_bridged(
b::SingleBridgeOptimizer,
ci::MOI.ConstraintIndex{MOI.VectorOfVariables,S},
Expand Down
1 change: 1 addition & 0 deletions src/Bridges/Variable/set_map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function MOI.delete(
MOI.delete(model, bridge.variable)
return
end

function MOI.delete(
model::MOI.ModelLike,
bridge::SetMapBridge{T,S1,S2},
Expand Down
1 change: 1 addition & 0 deletions src/FileFormats/MOF/write.jl
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ head_name(::Type{MOI.LogDetConeSquare}) = "LogDetConeSquare"
function head_name(::Type{MOI.PositiveSemidefiniteConeTriangle})
return "PositiveSemidefiniteConeTriangle"
end

function head_name(::Type{MOI.PositiveSemidefiniteConeSquare})
return "PositiveSemidefiniteConeSquare"
end
Expand Down
2 changes: 2 additions & 0 deletions src/FileFormats/SDPA/SDPA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function MOI.supports_constraint(
) where {T}
return false
end

function MOI.supports_constraint(
::Model,
::Type{MOI.VariableIndex},
Expand Down Expand Up @@ -300,6 +301,7 @@ function _dim_to_set(s::AbstractString)
return MOI.Nonnegatives(-block_dim)
end
end

function _parse_dimensions(dims::AbstractString)
isvalid(char) = isdigit(char) || char == '-'
is_delimiter(char) = isspace(char) || char == ','
Expand Down
4 changes: 4 additions & 0 deletions src/Test/test_basic_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ _set(::Type{MOI.Integer}) = MOI.Integer()
function _set(::Type{T}, ::Type{MOI.Semicontinuous}) where {T}
return MOI.Semicontinuous(zero(T), one(T))
end

function _set(::Type{T}, ::Type{MOI.Semiinteger}) where {T}
return MOI.Semiinteger(zero(T), one(T))
end
Expand All @@ -124,12 +125,15 @@ _set(::Type{MOI.NormNuclearCone}) = MOI.NormNuclearCone(2, 3)
function _set(::Type{MOI.PositiveSemidefiniteConeTriangle})
return MOI.PositiveSemidefiniteConeTriangle(3)
end

function _set(::Type{MOI.PositiveSemidefiniteConeSquare})
return MOI.PositiveSemidefiniteConeSquare(3)
end

function _set(::Type{MOI.HermitianPositiveSemidefiniteConeTriangle})
return MOI.HermitianPositiveSemidefiniteConeTriangle(3)
end

function _set(::Type{MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle}})
return MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle}(3)
end
Expand Down
1 change: 1 addition & 0 deletions src/Test/test_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function MOI.get(::BadModelAttributeModel, ::MOI.ListOfModelAttributesSet)
end

struct UnknownVariableAttribute <: MOI.AbstractVariableAttribute end

struct BadVariableAttributeModel{T} <: BadModel{T}
BadVariableAttributeModel(T = Float64) = new{T}()
end
Expand Down
8 changes: 8 additions & 0 deletions src/Utilities/cachingoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ function pass_nonvariable_constraints(
constraint_types,
)
end

function final_touch(m::CachingOptimizer, index_map)
return final_touch(m.model_cache, index_map)
end

function MOI.copy_to(m::CachingOptimizer, src::MOI.ModelLike)
if m.state == ATTACHED_OPTIMIZER
reset_optimizer(m)
Expand Down Expand Up @@ -394,6 +396,7 @@ function MOI.supports_add_constrained_variable(
MOI.supports_add_constrained_variable(m.optimizer, S)::Bool
)
end

function MOI.add_constrained_variable(
m::CachingOptimizer,
set::S,
Expand Down Expand Up @@ -1032,6 +1035,7 @@ function MOI.supports(
)
return MOI.supports(model.model_cache, attr, IndexType)
end

function MOI.set(
model::CachingOptimizer,
attr::Union{MOI.VariableName,MOI.ConstraintName},
Expand All @@ -1045,6 +1049,7 @@ end
function MOI.supports(m::CachingOptimizer, attr::MOI.Name)
return MOI.supports(m.model_cache, attr)
end

function MOI.set(model::CachingOptimizer, attr::MOI.Name, value)
MOI.set(model.model_cache, attr, value)
return
Expand Down Expand Up @@ -1205,12 +1210,14 @@ end
function map_indices_to_optimizer(m::CachingOptimizer, idx::MOI.Index)
return m.model_to_optimizer_map[idx]
end

function map_indices_to_optimizer(
m::CachingOptimizer,
indices::Vector{<:MOI.Index},
)
return getindex.(Ref(m.model_to_optimizer_map), indices)
end

function MOI.set(
m::CachingOptimizer,
attr::AttributeFromOptimizer{T},
Expand Down Expand Up @@ -1272,6 +1279,7 @@ function MOI.supports(
return caching_opt.optimizer !== nothing &&
MOI.supports(caching_opt.optimizer, sub)::Bool
end

function MOI.submit(
caching_opt::CachingOptimizer,
sub::MOI.AbstractSubmittable,
Expand Down
2 changes: 2 additions & 0 deletions src/Utilities/mockoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ function MOI.get(mock::MockOptimizer, attr::MOI.AbstractOptimizerAttribute)
return MOI.get(mock.inner_model, attr)
end
end

function MOI.get(mock::MockOptimizer, attr::MOI.AbstractModelAttribute)
if MOI.is_set_by_optimize(attr)
return mock.model_attributes[attr]
Expand Down Expand Up @@ -680,6 +681,7 @@ function MOI.get(
return _safe_get_result(mock.constraint_dual, attr, idx, "dual")
end
end

function MOI.get(
mock::MockOptimizer,
::MockConstraintAttribute,
Expand Down
2 changes: 2 additions & 0 deletions src/Utilities/struct_of_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ function _add_variable(model::StructOfConstraints)
model.num_variables += 1
return broadcastcall(_add_variable, model)
end

function _add_variables(model::StructOfConstraints, n)
model.num_variables += n
return broadcastcall(Base.Fix2(_add_variables, n), model)
end

function final_touch(::Nothing, index_map) end

function final_touch(model::StructOfConstraints, index_map)
broadcastcall(Base.Fix2(final_touch, index_map), model)
return
Expand Down
1 change: 1 addition & 0 deletions src/Utilities/vector_of_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function MOI.modify(
end

function _add_variable(::VectorOfConstraints) end

function _add_variables(::VectorOfConstraints, ::Int64) end

# Deletion of variables in vector of variables
Expand Down
5 changes: 5 additions & 0 deletions src/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ function throw_if_scalar_and_constant_not_zero(
end
return
end

function throw_if_scalar_and_constant_not_zero(
::VariableIndex,
::Type{S},
) where {S<:AbstractScalarSet}
return
end

function throw_if_scalar_and_constant_not_zero(
::AbstractVectorFunction,
::Type{S},
Expand Down Expand Up @@ -197,6 +199,7 @@ function throw_add_constraint_error_fallback(
kwargs...,
)
end

function throw_add_constraint_error_fallback(
model::ModelLike,
func::AbstractVectorFunction,
Expand All @@ -210,6 +213,7 @@ function throw_add_constraint_error_fallback(
kwargs...,
)
end

function throw_add_constraint_error_fallback(
model::ModelLike,
func::AbstractScalarFunction,
Expand All @@ -220,6 +224,7 @@ function throw_add_constraint_error_fallback(
"Cannot add a constraint of the form `ScalarFunction`-in-`VectorSet`",
)
end

function throw_add_constraint_error_fallback(
model::ModelLike,
func::AbstractVectorFunction,
Expand Down
1 change: 1 addition & 0 deletions src/instantiate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ _to_param(param::Pair{<:AbstractOptimizerAttribute}) = param
function _to_param(param::Pair{String})
return RawOptimizerAttribute(param.first) => param.second
end

function _to_param(param::Pair)
return error(
"Expected an optimizer attribute or a string, got `$(param.first)` which is a `$(typeof(param.first))`.",
Expand Down
2 changes: 2 additions & 0 deletions src/modifications.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ struct ModifyConstraintNotAllowed{
change::C
message::String
end

function ModifyConstraintNotAllowed(
ci::ConstraintIndex{F,S},
change::AbstractFunctionModification,
message = "",
) where {F<:AbstractFunction,S<:AbstractSet}
return ModifyConstraintNotAllowed{F,S,typeof(change)}(ci, change, message)
end

function throw_modify_not_allowed(ci::ConstraintIndex, args...)
return throw(ModifyConstraintNotAllowed(ci, args...))
end
Expand Down
3 changes: 3 additions & 0 deletions test/Bridges/bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ end
include("utilities.jl")

struct DummyModelAttribute <: MOI.AbstractModelAttribute end

struct DummyEvaluator <: MOI.AbstractNLPEvaluator end

struct DummyVariableAttribute <: MOI.AbstractVariableAttribute end

struct DummyConstraintAttribute <: MOI.AbstractConstraintAttribute end

function test_subsitution_of_variables_constant()
Expand Down
2 changes: 2 additions & 0 deletions test/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1970,8 +1970,10 @@ function test_wrong_coefficient()
end

struct OptimizerWithBridgeListOfNonstandardBridges <: MOI.AbstractOptimizer end

struct BridgeListOfNonstandardBridges{T} <:
MOI.Bridges.Constraint.AbstractBridge end

function MOI.get(
::OptimizerWithBridgeListOfNonstandardBridges,
::MOI.Bridges.ListOfNonstandardBridges{T},
Expand Down
1 change: 1 addition & 0 deletions test/FileFormats/MOF/MOF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function _validate(filename::String)
end

struct UnsupportedSet <: MOI.AbstractSet end

struct UnsupportedFunction <: MOI.AbstractFunction end

function _test_model_equality(
Expand Down
1 change: 1 addition & 0 deletions test/FileFormats/SDPA/SDPA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ end
function _spacer(char)
return [" ", "$char", " $char", "$char ", " $char "]
end

function test_dim_reader()
for before in _spacer('{')
for sep in _spacer(',')
Expand Down
3 changes: 3 additions & 0 deletions test/Utilities/cachingoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1001,12 +1001,15 @@ function MOI.Utilities.final_touch(model::FinalTouchDetector, index_map)
model.index_map = index_map
return
end

function MOI.copy_to(::MOI.Utilities.MockOptimizer, ::FinalTouchDetector)
return MOI.Utilities.IndexMap()
end

function MOI.get(::FinalTouchDetector, ::MOI.ListOfOptimizerAttributesSet)
return MOI.AbstractOptimizerAttribute[]
end

function MOI.get(::FinalTouchDetector, ::MOI.ListOfModelAttributesSet)
return MOI.AbstractModelAttribute[]
end
Expand Down
2 changes: 2 additions & 0 deletions test/Utilities/mutable_arithmetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ end
function test_promote_operation_allocation_Int()
return _test_promote_operation_allocation(Int)
end

function test_promote_operation_allocation_Float64()
return _test_promote_operation_allocation(Float64)
end

function test_promote_operation_allocation_Float32()
return _test_promote_operation_allocation(Float32)
end
Expand Down
2 changes: 2 additions & 0 deletions test/dummy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ function MOI.supports(
)
return true
end

function MOI.supports_constraint(
::AbstractDummyModel,
::Type{MOI.VariableIndex},
::Type{MOI.EqualTo{Float64}},
)
return true
end

function MOI.supports_constraint(
::AbstractDummyModel,
::Type{MOI.VectorOfVariables},
Expand Down
Loading