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: 1 addition & 4 deletions src/Utilities/cachingoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ mutable struct CachingOptimizer{O,M<:MOI.ModelLike} <: MOI.AbstractOptimizer
)
end

function CachingOptimizer(
cache::MOI.ModelLike,
optimizer::MOI.AbstractOptimizer,
)
function CachingOptimizer(cache::MOI.ModelLike, optimizer::MOI.ModelLike)
@assert MOI.is_empty(optimizer)
model = new{typeof(optimizer),typeof(cache)}(
optimizer,
Expand Down
6 changes: 3 additions & 3 deletions src/instantiate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ const _INSTANTIATE_NOT_CALLABLE_MESSAGE =
_instantiate_and_check(optimizer_constructor)

Create an instance of optimizer by calling `optimizer_constructor`.
Then check that the type returned is an empty [`AbstractOptimizer`](@ref).
Then check that the type returned is an empty [`ModelLike`](@ref).
"""
function _instantiate_and_check(optimizer_constructor)
if !applicable(optimizer_constructor)
error(_INSTANTIATE_NOT_CALLABLE_MESSAGE)
end
optimizer = optimizer_constructor()
if !isa(optimizer, AbstractOptimizer)
if !isa(optimizer, ModelLike)
error(
"The provided `optimizer_constructor` returned an object of type " *
"$(typeof(optimizer)). Expected a " *
"MathOptInterface.AbstractOptimizer.",
"MathOptInterface.ModelLike.",
)
end
if !is_empty(optimizer)
Expand Down
17 changes: 17 additions & 0 deletions test/FileFormats/FileFormats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ function test_copying()
end
end

function test_instantiate()
models = [
MOI.FileFormats.CBF.Model,
MOI.FileFormats.LP.Model,
MOI.FileFormats.MOF.Model,
MOI.FileFormats.MPS.Model,
MOI.FileFormats.SDPA.Model,
]
for src in models
model = MOI.instantiate(src)
@test model isa src
bridged = MOI.instantiate(src; with_bridge_type = Float64)
@test bridged isa MOI.Bridges.LazyBridgeOptimizer
end
return
end

function test_compressed_open()
for cs in [MOI.FileFormats.Bzip2(), MOI.FileFormats.Gzip()]
for open_type in ["a", "r+", "w+", "a+"]
Expand Down
2 changes: 1 addition & 1 deletion test/instantiate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function _test_instantiate(T)

err = ErrorException(
"The provided `optimizer_constructor` returned an object of type " *
"$Int. Expected a MathOptInterface.AbstractOptimizer.",
"$Int. Expected a MathOptInterface.ModelLike.",
)
h() = 1
@test_throws err MOI.instantiate(h)
Expand Down