Skip to content

Commit

Permalink
WIP: add FileFormats.Optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Feb 5, 2024
1 parent 50d83f1 commit 844c852
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/FileFormats/FileFormats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ include("MPS/MPS.jl")
include("NL/NL.jl")
include("SDPA/SDPA.jl")

include("Optimizer.jl")

"""
FileFormat
Expand Down
60 changes: 60 additions & 0 deletions src/FileFormats/Optimizer.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) 2017: Miles Lubin and contributors
# Copyright (c) 2017: Google Inc.
#
# 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.

struct Optimizer{M<:MOI.ModelLike} <: MOI.AbstractOptimizer
inner::M
end

function Optimizer(; kwargs...)
model = Model(; kwargs...)
return Optimizer{typeof(model)}(model)

Check warning on line 13 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L11-L13

Added lines #L11 - L13 were not covered by tests
end

MOI.is_empty(model::Optimizer) = MOI.is_empty(model.inner)

Check warning on line 16 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L16

Added line #L16 was not covered by tests

MOI.empty!(model::Optimizer) = MOI.empty!(model.inner)

Check warning on line 18 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L18

Added line #L18 was not covered by tests

MOI.add_variable(model::Optimizer) = MOI.add_variable(model.inner)

Check warning on line 20 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L20

Added line #L20 was not covered by tests

function MOI.supports(model::Optimizer, attr::MOI.AbstractModelAttribute)
return MOI.supports(model.inner, attr)

Check warning on line 23 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L22-L23

Added lines #L22 - L23 were not covered by tests
end

function MOI.get(model::Optimizer, attr::MOI.AbstractModelAttribute)
return MOI.get(model.inner, attr)

Check warning on line 27 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L26-L27

Added lines #L26 - L27 were not covered by tests
end

function MOI.set(model::Optimizer, attr::MOI.AbstractModelAttribute, value)
return MOI.set(model.inner, attr, value)

Check warning on line 31 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L30-L31

Added lines #L30 - L31 were not covered by tests
end

function MOI.get(model::Optimizer, attr::MOI.AbstractOptimizerAttribute)
return MOI.get(model.inner, attr)

Check warning on line 35 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L34-L35

Added lines #L34 - L35 were not covered by tests
end

function MOI.get(model::Optimizer, ::MOI.SolverName)
return "FileFormats.Optimizer"

Check warning on line 39 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L38-L39

Added lines #L38 - L39 were not covered by tests
end

function MOI.supports_constraint(

Check warning on line 42 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L42

Added line #L42 was not covered by tests
model::Optimizer,
::Type{F},
::Type{S},
) where {F<:MOI.AbstractFunction,S<:MOI.AbstractSet}
return MOI.supports_constraint(model.inner, F, S)

Check warning on line 47 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L47

Added line #L47 was not covered by tests
end

function MOI.add_constraint(

Check warning on line 50 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L50

Added line #L50 was not covered by tests
model::Optimizer,
f::MOI.AbstractFunction,
s::MOI.AbstractSet,
)
return MOI.add_constraint(model.inner, f, s)

Check warning on line 55 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L55

Added line #L55 was not covered by tests
end

function MOI.write_to_file(model::Optimizer, filename::String)
return MOI.write_to_file(model.inner, filename)

Check warning on line 59 in src/FileFormats/Optimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/Optimizer.jl#L58-L59

Added lines #L58 - L59 were not covered by tests
end

0 comments on commit 844c852

Please sign in to comment.