diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml index e31cfc19b7..c4482c2299 100644 --- a/.github/workflows/format_check.yml +++ b/.github/workflows/format_check.yml @@ -20,8 +20,7 @@ jobs: using Pkg Pkg.add(PackageSpec(name="JuliaFormatter", version="1")) using JuliaFormatter - format("src", verbose=true) - format("test", verbose=true) + format(".", verbose=true) out = String(read(Cmd(`git diff`))) if isempty(out) exit(0) diff --git a/docs/make.jl b/docs/make.jl index 7310a0d61c..5dcf4cc161 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -21,10 +21,7 @@ const _PDF = findfirst(isequal("--pdf"), ARGS) !== nothing || _IS_GITHUB_ACTIONS # ============================================================================== const _PAGES = [ - "Introduction" => [ - "index.md", - "background/motivation.md", - ], + "Introduction" => ["index.md", "background/motivation.md"], "Tutorials" => [ "tutorials/example.md", "tutorials/implementing.md", @@ -94,12 +91,12 @@ const _PAGES = [ function fix_release_line( line::String, - url::String = "https://github.com/jump-dev/MathOptInterface.jl" + url::String = "https://github.com/jump-dev/MathOptInterface.jl", ) # (#XXXX) -> ([#XXXX](url/issue/XXXX)) while (m = match(r"\(\#([0-9]+)\)", line)) !== nothing - id = m.captures[1] - line = replace(line, m.match => "([#$id]($url/issues/$id))") + id = m.captures[1] + line = replace(line, m.match => "([#$id]($url/issues/$id))") end # ## vX.Y.Z -> [vX.Y.Z](url/releases/tag/vX.Y.Z) while (m = match(r"\#\# (v[0-9]+.[0-9]+.[0-9]+)", line)) !== nothing diff --git a/perf/bellman_ford.jl b/perf/bellman_ford.jl index c31f521aad..8ce6b0dff8 100644 --- a/perf/bellman_ford.jl +++ b/perf/bellman_ford.jl @@ -10,15 +10,58 @@ import MathOptInterface.Utilities as MOIU # Model similar to SDPA format, it gives a good example because it does not # support a lot hence need a lot of bridges -MOIU.@model(SDPAModel, - (), (MOI.EqualTo,), (MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), (), - (), (MOI.ScalarAffineFunction,), (MOI.VectorOfVariables,), ()) -MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.VariableIndex}, ::Type{MOI.GreaterThan{T}}) where {T} = false -MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.VariableIndex}, ::Type{MOI.LessThan{T}}) where {T} = false -MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.VariableIndex}, ::Type{MOI.EqualTo{T}}) where {T} = false -MOI.supports_constraint(::SDPAModel{T}, ::Type{MOI.VariableIndex}, ::Type{MOI.Interval{T}}) where {T} = false -MOI.supports_constraint(::SDPAModel, ::Type{MOI.VectorOfVariables}, ::Type{MOI.Reals}) = false -MOI.supports(::SDPAModel{T}, ::MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{T}}) where {T} = false +MOIU.@model( + SDPAModel, + (), + (MOI.EqualTo,), + (MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle), + (), + (), + (MOI.ScalarAffineFunction,), + (MOI.VectorOfVariables,), + () +) +function MOI.supports_constraint( + ::SDPAModel{T}, + ::Type{MOI.VariableIndex}, + ::Type{MOI.GreaterThan{T}}, +) 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}}, +) where {T} + return false +end MOI.supports(::SDPAModel, ::MOI.ObjectiveFunction{MOI.VariableIndex}) = false function interval_constraint() @@ -31,7 +74,7 @@ function interval_constraint() MOI.Bridges._reset_bridge_graph($bridged) MOI.Bridges.node($bridged, $F, $S) end) - display(@benchmark begin + return display(@benchmark begin MOI.Bridges._reset_bridge_graph($bridged) MOI.Bridges.bridge_index($bridged, $F, $S) end) @@ -48,7 +91,7 @@ function quadratic_objective() MOI.Bridges._reset_bridge_graph($bridged) MOI.Bridges.node($bridged, $F) end) - display(@benchmark begin + return display(@benchmark begin MOI.Bridges._reset_bridge_graph($bridged) MOI.Bridges.bridge_index($bridged, $F) end) diff --git a/perf/cachingoptimizer.jl b/perf/cachingoptimizer.jl index 090ff4d149..9af81ad889 100644 --- a/perf/cachingoptimizer.jl +++ b/perf/cachingoptimizer.jl @@ -12,15 +12,35 @@ using BenchmarkTools import MathOptInterface as MOI import MathOptInterface.Utilities as MOIU -@MOIU.model Model () (MOI.Interval,) () () () (MOI.ScalarAffineFunction,) () () +MOIU.@model Model () (MOI.Interval,) () () () (MOI.ScalarAffineFunction,) () () optimizer = MOIU.MockOptimizer(Model{Float64}()) caching_optimizer = MOIU.CachingOptimizer(Model{Float64}(), optimizer) MOIU.reset_optimizer(caching_optimizer) # detach optimizer v = MOI.add_variables(caching_optimizer, 2) cf = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.([0.0, 0.0], v), 0.0) c = MOI.add_constraint(caching_optimizer, cf, MOI.Interval(-Inf, 1.0)) -@btime MOI.set($caching_optimizer, $(MOI.ConstraintSet()), $c, $(MOI.Interval(0.0, 2.0))) +@btime MOI.set( + $caching_optimizer, + $(MOI.ConstraintSet()), + $c, + $(MOI.Interval(0.0, 2.0)), +) MOIU.attach_optimizer(caching_optimizer) -@btime MOI.set($caching_optimizer, $(MOI.ConstraintSet()), $c, $(MOI.Interval(0.0, 2.0))) -@btime MOI.set($(caching_optimizer.model_cache), $(MOI.ConstraintSet()), $c, $(MOI.Interval(0.0, 2.0))) -@btime MOI.set($(caching_optimizer.optimizer), $(MOI.ConstraintSet()), $(caching_optimizer.model_to_optimizer_map[c]), $(MOI.Interval(0.0, 2.0))) +@btime MOI.set( + $caching_optimizer, + $(MOI.ConstraintSet()), + $c, + $(MOI.Interval(0.0, 2.0)), +) +@btime MOI.set( + $(caching_optimizer.model_cache), + $(MOI.ConstraintSet()), + $c, + $(MOI.Interval(0.0, 2.0)), +) +@btime MOI.set( + $(caching_optimizer.optimizer), + $(MOI.ConstraintSet()), + $(caching_optimizer.model_to_optimizer_map[c]), + $(MOI.Interval(0.0, 2.0)), +) diff --git a/perf/time_to_first_solve/script.jl b/perf/time_to_first_solve/script.jl index e5cc52aa24..75654f498a 100644 --- a/perf/time_to_first_solve/script.jl +++ b/perf/time_to_first_solve/script.jl @@ -11,24 +11,24 @@ import MathOptInterface as MOI function example_diet(optimizer, bridge) category_data = [ 1800.0 2200.0 - 91.0 Inf - 0.0 65.0 - 0.0 1779.0 + 91.0 Inf + 0.0 65.0 + 0.0 1779.0 ] cost = [2.49, 2.89, 1.50, 1.89, 2.09, 1.99, 2.49, 0.89, 1.59] food_data = [ 410 24 26 730 420 32 10 1190 560 20 32 1800 - 380 4 19 270 + 380 4 19 270 320 12 10 930 320 15 12 820 320 31 12 1230 - 100 8 2.5 125 - 330 8 10 180 + 100 8 2.5 125 + 330 8 10 180 ] bridge_model = if bridge - MOI.instantiate(optimizer; with_bridge_type=Float64) + MOI.instantiate(optimizer; with_bridge_type = Float64) else MOI.instantiate(optimizer) end