From 29d91ef9cfd8b687d5f19df47cfeac33339f45f9 Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 2 Sep 2021 14:22:00 +1200 Subject: [PATCH] [docs] update docs to build on Julia 1.6 --- .github/workflows/documentation.yml | 4 +- docs/Project.toml | 2 +- docs/src/manual/constraints.md | 8 +-- docs/src/manual/modification.md | 14 ++--- docs/src/manual/variables.md | 2 +- docs/src/submodules/Bridges/implementation.md | 6 +-- docs/src/submodules/Bridges/overview.md | 30 +++++------ docs/src/submodules/FileFormats/overview.md | 18 +++---- docs/src/submodules/Utilities/overview.md | 54 +++++++++---------- docs/src/tutorials/example.md | 6 +-- .../src/tutorials/manipulating_expressions.md | 20 +++---- src/Bridges/Constraint/bridge.jl | 2 +- src/Bridges/Variable/bridge.jl | 6 +-- 13 files changed, 86 insertions(+), 86 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 4b10cc9802..4b5055ec21 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -12,8 +12,8 @@ jobs: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@latest with: - # Build documentation on Julia 1.0 - version: '1.0' + # Build documentation on Julia 1.6 + version: '1.6' - name: Install dependencies shell: julia --project=docs {0} run: | diff --git a/docs/Project.toml b/docs/Project.toml index df0dc3f474..084be214a2 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -5,6 +5,6 @@ JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" [compat] -Documenter = "0.25" +Documenter = "0.27" JSON = "0.21" JSONSchema = "0.3" diff --git a/docs/src/manual/constraints.md b/docs/src/manual/constraints.md index 386533be2b..c6fd2c8355 100644 --- a/docs/src/manual/constraints.md +++ b/docs/src/manual/constraints.md @@ -15,7 +15,7 @@ Use [`add_constraint`](@ref) to add a single constraint. ```jldoctest constraints; setup=:(model = MOI.Utilities.Model{Float64}(); x = MOI.add_variables(model, 2)) julia> c = MOI.add_constraint(model, MOI.VectorOfVariables(x), MOI.Nonnegatives(2)) -MathOptInterface.ConstraintIndex{MathOptInterface.VectorOfVariables,MathOptInterface.Nonnegatives}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.VectorOfVariables, MathOptInterface.Nonnegatives}(1) ``` [`add_constraint`](@ref) returns a [`ConstraintIndex`](@ref) type, which should @@ -36,9 +36,9 @@ julia> c = MOI.add_constraints( [x[1], x[2]], [MOI.GreaterThan(0.0), MOI.GreaterThan(1.0)] ) -2-element Array{MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex,MathOptInterface.GreaterThan{Float64}},1}: - MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex,MathOptInterface.GreaterThan{Float64}}(1) - MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex,MathOptInterface.GreaterThan{Float64}}(2) +2-element Vector{MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}}: + MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}(1) + MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}(2) ``` This time, a vector of [`ConstraintIndex`](@ref) are returned. diff --git a/docs/src/manual/modification.md b/docs/src/manual/modification.md index bc99f1fd37..5d383c0db5 100644 --- a/docs/src/manual/modification.md +++ b/docs/src/manual/modification.md @@ -32,7 +32,7 @@ julia> c = MOI.add_constraint( MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, x)], 0.0), MOI.EqualTo(1.0), ) -MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}(1) julia> MOI.set(model, MOI.ConstraintSet(), c, MOI.EqualTo(2.0)); @@ -66,7 +66,7 @@ julia> c = MOI.add_constraint( MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, x)], 0.0), MOI.LessThan(1.0), ) -MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.LessThan{Float64}}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.LessThan{Float64}}(1) julia> new_c = MOI.transform(model, c, MOI.GreaterThan(2.0)); @@ -92,7 +92,7 @@ julia> c = MOI.add_constraint( MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, x)], 0.0), MOI.EqualTo(1.0), ) -MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}(1) julia> new_f = MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(2.0, x)], 1.0); @@ -120,7 +120,7 @@ julia> c = MOI.add_constraint( MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, x)], 0.0), MOI.EqualTo(1.0), ) -MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}(1) julia> MOI.modify(model, c, MOI.ScalarConstantChange(1.0)); @@ -171,7 +171,7 @@ julia> c = MOI.add_constraint( ), MOI.Nonnegatives(2), ) -MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.Nonnegatives}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.Nonnegatives}(1) julia> MOI.modify(model, c, MOI.VectorConstantChange([3.0, 4.0])); @@ -198,7 +198,7 @@ julia> c = MOI.add_constraint( MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, x)], 0.0), MOI.EqualTo(1.0), ) -MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}(1) julia> MOI.modify(model, c, MOI.ScalarCoefficientChange(x, 2.0)); @@ -229,7 +229,7 @@ julia> c = MOI.add_constraint( ), MOI.Nonnegatives(2), ) -MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.Nonnegatives}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.Nonnegatives}(1) julia> MOI.modify(model, c, MOI.MultirowChange(x, [(1, 3.0), (2, 4.0)])); diff --git a/docs/src/manual/variables.md b/docs/src/manual/variables.md index 5bef477ab3..4b02ad3f6c 100644 --- a/docs/src/manual/variables.md +++ b/docs/src/manual/variables.md @@ -29,7 +29,7 @@ true Use [`add_variables`](@ref) to add a number of variables. ```jldoctest variables julia> y = MOI.add_variables(model, 2) -2-element Array{MathOptInterface.VariableIndex,1}: +2-element Vector{MathOptInterface.VariableIndex}: MathOptInterface.VariableIndex(2) MathOptInterface.VariableIndex(3) ``` diff --git a/docs/src/submodules/Bridges/implementation.md b/docs/src/submodules/Bridges/implementation.md index 5343dbb1cb..df7e87f8b5 100644 --- a/docs/src/submodules/Bridges/implementation.md +++ b/docs/src/submodules/Bridges/implementation.md @@ -34,10 +34,10 @@ Bridges.Objective.bridge_objective ``` When querying the [`NumberOfVariables`](@ref), [`NumberOfConstraints`](@ref) -[`ListOfVariableIndices`](@ref), and [`ListOfConstraintIndices`](@ref), the +[`ListOfVariableIndices`](@ref), and [`ListOfConstraintIndices`](@ref), the variables and constraints created by the bridges in the underlying model are hidden by the bridge optimizer. For this purpose, the bridge should provide -access to the variables and constraints it has created by implementing the +access to the variables and constraints it has created by implementing the following methods of [`get`](@ref): ```@docs get(::Bridges.Constraint.AbstractBridge, ::NumberOfVariables) @@ -49,7 +49,7 @@ get(::Bridges.AbstractBridge, ::ListOfConstraintIndices) # SetMap bridges Implementing a constraint bridge relying on linear transformation between two -sets is easier thanks to the [SetMap interface](constraint_set_map). +sets is easier thanks to the [SetMap interface](@ref constraint_set_map). The bridge simply needs to be a subtype of [`Bridges.Variable.SetMapBridge`] for a variable bridge and [`Bridges.Constraint.SetMapBridge`] for a constraint bridge and the linear transformation is represented with diff --git a/docs/src/submodules/Bridges/overview.md b/docs/src/submodules/Bridges/overview.md index 42af9fb438..e522e03eed 100644 --- a/docs/src/submodules/Bridges/overview.md +++ b/docs/src/submodules/Bridges/overview.md @@ -104,14 +104,14 @@ in a [`Bridges.full_bridge_optimizer`](@ref). ```jldoctest julia> inner_optimizer = MOI.Utilities.Model{Float64}() -MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.Model{Float64} julia> optimizer = MOI.Bridges.full_bridge_optimizer(inner_optimizer, Float64) -MOIB.LazyBridgeOptimizer{MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIB.LazyBridgeOptimizer{MOIU.Model{Float64}} with 0 variable bridges with 0 constraint bridges with 0 objective bridges -with inner model MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +with inner model MOIU.Model{Float64} ``` That's all you have to do! Use `optimizer` as normal, and bridging will happen @@ -136,25 +136,25 @@ However, this will force the constraint to be bridged, even if the ```jldoctest julia> inner_optimizer = MOI.Utilities.Model{Float64}() -MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.Model{Float64} julia> optimizer = MOI.Bridges.Constraint.SplitInterval{Float64}(inner_optimizer) -MOIB.Constraint.SingleBridgeOptimizer{MOIB.Constraint.SplitIntervalBridge{Float64,F,S,LS,US} where US<:MOI.AbstractSet where LS<:MOI.AbstractSet where S<:MOI.AbstractSet where F<:MOI.AbstractFunction,MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIB.Constraint.SingleBridgeOptimizer{MOIB.Constraint.SplitIntervalBridge{Float64, F, S, LS, US} where {F<:MOI.AbstractFunction, S<:MOI.AbstractSet, LS<:MOI.AbstractSet, US<:MOI.AbstractSet}, MOIU.Model{Float64}} with 0 constraint bridges -with inner model MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +with inner model MOIU.Model{Float64} julia> x = MOI.add_variable(optimizer) MOI.VariableIndex(1) julia> MOI.add_constraint(optimizer, x, MOI.Interval(0.0, 1.0)) -MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex,MathOptInterface.Interval{Float64}}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.Interval{Float64}}(1) julia> MOI.get(optimizer, MOI.ListOfConstraintTypesPresent()) -1-element Array{Tuple{Type,Type},1}: +1-element Vector{Tuple{Type, Type}}: (MathOptInterface.VariableIndex, MathOptInterface.Interval{Float64}) julia> MOI.get(inner_optimizer, MOI.ListOfConstraintTypesPresent()) -2-element Array{Tuple{Type,Type},1}: +2-element Vector{Tuple{Type, Type}}: (MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}) (MathOptInterface.VariableIndex, MathOptInterface.LessThan{Float64}) ``` @@ -168,14 +168,14 @@ manually construct a [`Bridges.LazyBridgeOptimizer`](@ref). First, wrap an inner optimizer: ```jldoctest lazy_bridge_optimizer julia> inner_optimizer = MOI.Utilities.Model{Float64}() -MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.Model{Float64} julia> optimizer = MOI.Bridges.LazyBridgeOptimizer(inner_optimizer) -MOIB.LazyBridgeOptimizer{MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIB.LazyBridgeOptimizer{MOIU.Model{Float64}} with 0 variable bridges with 0 constraint bridges with 0 objective bridges -with inner model MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +with inner model MOIU.Model{Float64} ``` Then use [`Bridges.add_bridge`](@ref) to add individual bridges: @@ -191,13 +191,13 @@ julia> x = MOI.add_variable(optimizer) MOI.VariableIndex(1) julia> MOI.add_constraint(optimizer, x, MOI.Interval(0.0, 1.0)) -MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex,MathOptInterface.Interval{Float64}}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.Interval{Float64}}(1) julia> MOI.get(optimizer, MOI.ListOfConstraintTypesPresent()) -1-element Array{Tuple{Type,Type},1}: +1-element Vector{Tuple{Type, Type}}: (MathOptInterface.VariableIndex, MathOptInterface.Interval{Float64}) julia> MOI.get(inner_optimizer, MOI.ListOfConstraintTypesPresent()) -1-element Array{Tuple{Type,Type},1}: +1-element Vector{Tuple{Type, Type}}: (MathOptInterface.VariableIndex, MathOptInterface.Interval{Float64}) ``` diff --git a/docs/src/submodules/FileFormats/overview.md b/docs/src/submodules/FileFormats/overview.md index 51dc1eb04e..2fd86d6d4d 100644 --- a/docs/src/submodules/FileFormats/overview.md +++ b/docs/src/submodules/FileFormats/overview.md @@ -65,7 +65,7 @@ To write a model `src` to a [MathOptFormat file](https://jump.dev/MathOptFormat/ use: ```jldoctest fileformats julia> src = MOI.Utilities.Model{Float64}() -MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.Model{Float64} julia> MOI.add_variable(src) MathOptInterface.VariableIndex(1) @@ -108,7 +108,7 @@ A MathOptFormat Model julia> MOI.read_from_file(dest, "file.mof.json") julia> MOI.get(dest, MOI.ListOfVariableIndices()) -1-element Array{MathOptInterface.VariableIndex,1}: +1-element Vector{MathOptInterface.VariableIndex}: MathOptInterface.VariableIndex(1) julia> rm("file.mof.json") # Clean up after ourselves. @@ -122,13 +122,13 @@ guess the format from the file extension. For example: ```jldoctest fileformats julia> src = MOI.Utilities.Model{Float64}() -MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.Model{Float64} julia> dest = MOI.FileFormats.Model(filename = "file.cbf.gz") A Conic Benchmark Format (CBF) model julia> MOI.copy_to(dest, src) -MathOptInterface.Utilities.IndexMap with 0 entries +MathOptInterface.Utilities.IndexMap() julia> MOI.write_to_file(dest, "file.cbf.gz") @@ -136,13 +136,13 @@ julia> src_2 = MOI.FileFormats.Model(filename = "file.cbf.gz") A Conic Benchmark Format (CBF) model julia> src = MOI.Utilities.Model{Float64}() -MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.Model{Float64} julia> dest = MOI.FileFormats.Model(filename = "file.cbf.gz") A Conic Benchmark Format (CBF) model julia> MOI.copy_to(dest, src) -MathOptInterface.Utilities.IndexMap with 0 entries +MathOptInterface.Utilities.IndexMap() julia> MOI.write_to_file(dest, "file.cbf.gz") @@ -180,13 +180,13 @@ In addition to [`write_to_file`](@ref) and [`read_from_file`](@ref), you can read and write directly from `IO` streams using `Base.write` and `Base.read!`: ```jldoctest julia> src = MOI.Utilities.Model{Float64}() -MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.Model{Float64} julia> dest = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_MPS) A Mathematical Programming System (MPS) model julia> MOI.copy_to(dest, src) -MathOptInterface.Utilities.IndexMap with 0 entries +MathOptInterface.Utilities.IndexMap() julia> io = IOBuffer(); @@ -255,7 +255,7 @@ Use `JSONSchema.validate` to obtain more insight into why the validation failed: julia> JSONSchema.validate(bad_model, schema) Validation failed: path: [variables][1] -instance: Dict{String,Any}("NaMe"=>"x") +instance: Dict{String, Any}("NaMe" => "x") schema key: required schema value: Any["name"] ``` diff --git a/docs/src/submodules/Utilities/overview.md b/docs/src/submodules/Utilities/overview.md index 238ad23ab6..a6f19b64c9 100644 --- a/docs/src/submodules/Utilities/overview.md +++ b/docs/src/submodules/Utilities/overview.md @@ -21,7 +21,7 @@ given the extensibility of MOI, this might not cover all use cases. Create a model as follows: ```jldoctest julia> model = MOI.Utilities.Model{Float64}() -MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.Model{Float64} ``` ## Utilities.UniversalFallback @@ -36,8 +36,8 @@ like [`VariablePrimalStart`](@ref), so JuMP uses a combination of Universal fallback and [`Utilities.Model`](@ref) as a generic problem cache: ```jldoctest julia> model = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) -MOIU.UniversalFallback{MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} -fallback for MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +MOIU.UniversalFallback{MOIU.Model{Float64}} +fallback for MOIU.Model{Float64} ``` !!! warning @@ -83,10 +83,10 @@ julia> MOI.Utilities.@model( (MOI.VectorAffineFunction,), # Typed vector functions true, # <:MOI.AbstractOptimizer? ) -MathOptInterface.Utilities.GenericOptimizer{T,MathOptInterface.Utilities.ObjectiveContainer{T},MathOptInterface.Utilities.VariablesContainer{T},MyNewModelFunctionConstraints{T}} where T +MathOptInterface.Utilities.GenericOptimizer{T, MathOptInterface.Utilities.ObjectiveContainer{T}, MathOptInterface.Utilities.VariablesContainer{T}, MyNewModelFunctionConstraints{T}} where T julia> model = MyNewModel{Float64}() -MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MyNewModelFunctionConstraints{Float64}} +MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MyNewModelFunctionConstraints{Float64}} ``` !!! warning @@ -112,7 +112,7 @@ julia> MOI.Utilities.@model( (MOI.VectorAffineFunction,), # Typed vector functions true, # is_optimizer ) -MathOptInterface.Utilities.GenericOptimizer{T,MathOptInterface.Utilities.ObjectiveContainer{T},MathOptInterface.Utilities.VariablesContainer{T},MathOptInterface.Utilities.VectorOfConstraints{MathOptInterface.VectorAffineFunction{T},MathOptInterface.Complements}} where T +MathOptInterface.Utilities.GenericOptimizer{T, MathOptInterface.Utilities.ObjectiveContainer{T}, MathOptInterface.Utilities.VariablesContainer{T}, MathOptInterface.Utilities.VectorOfConstraints{MathOptInterface.VectorAffineFunction{T}, MathOptInterface.Complements}} where T ``` However, `PathOptimizer` does not support some `VariableIndex`-in-Set constraints, so we must explicitly define: @@ -152,11 +152,11 @@ julia> model = MOI.Utilities.CachingOptimizer( MOI.Utilities.Model{Float64}(), PathOptimizer{Float64}(), ) -MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}},MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}}, MOIU.Model{Float64}} in state EMPTY_OPTIMIZER in mode AUTOMATIC -with model cache MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} -with optimizer MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}} +with model cache MOIU.Model{Float64} +with optimizer MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}} ``` A [`Utilities.CachingOptimizer`](@ref) may be in one of three possible states: @@ -176,11 +176,11 @@ Use [`Utilities.attach_optimizer`](@ref) to go from `EMPTY_OPTIMIZER` to julia> MOI.Utilities.attach_optimizer(model) julia> model -MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}},MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}}, MOIU.Model{Float64}} in state ATTACHED_OPTIMIZER in mode AUTOMATIC -with model cache MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} -with optimizer MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}} +with model cache MOIU.Model{Float64} +with optimizer MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}} ``` !!! info @@ -192,11 +192,11 @@ Use [`Utilities.reset_optimizer`](@ref) to go from `ATTACHED_OPTIMIZER` to julia> MOI.Utilities.reset_optimizer(model) julia> model -MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}},MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}}, MOIU.Model{Float64}} in state EMPTY_OPTIMIZER in mode AUTOMATIC -with model cache MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} -with optimizer MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}} +with model cache MOIU.Model{Float64} +with optimizer MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}} ``` !!! info @@ -209,10 +209,10 @@ Use [`Utilities.drop_optimizer`](@ref) to go from any state to `NO_OPTIMIZER`: julia> MOI.Utilities.drop_optimizer(model) julia> model -MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}},MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}}, MOIU.Model{Float64}} in state NO_OPTIMIZER in mode AUTOMATIC -with model cache MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +with model cache MOIU.Model{Float64} with optimizer nothing ``` @@ -222,11 +222,11 @@ Pass an empty optimizer to [`Utilities.reset_optimizer`](@ref) to go from julia> MOI.Utilities.reset_optimizer(model, PathOptimizer{Float64}()) julia> model -MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}},MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIU.CachingOptimizer{MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}}, MOIU.Model{Float64}} in state EMPTY_OPTIMIZER in mode AUTOMATIC -with model cache MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} -with optimizer MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}} +with model cache MOIU.Model{Float64} +with optimizer MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}} ``` Deciding when to attach and reset the optimizer is tedious, and you will often @@ -256,20 +256,20 @@ julia> model = MOI.Utilities.CachingOptimizer( MOI.Utilities.Model{Float64}(), MOI.Utilities.MANUAL, ) -MOIU.CachingOptimizer{MOI.AbstractOptimizer,MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIU.CachingOptimizer{MOI.AbstractOptimizer, MOIU.Model{Float64}} in state NO_OPTIMIZER in mode MANUAL -with model cache MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} +with model cache MOIU.Model{Float64} with optimizer nothing julia> MOI.Utilities.reset_optimizer(model, PathOptimizer{Float64}()) julia> model -MOIU.CachingOptimizer{MOI.AbstractOptimizer,MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}}} +MOIU.CachingOptimizer{MOI.AbstractOptimizer, MOIU.Model{Float64}} in state EMPTY_OPTIMIZER in mode MANUAL -with model cache MOIU.GenericModel{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.ModelFunctionConstraints{Float64}} -with optimizer MOIU.GenericOptimizer{Float64,MOIU.ObjectiveContainer{Float64},MOIU.VariablesContainer{Float64},MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64},MOI.Complements}} +with model cache MOIU.Model{Float64} +with optimizer MOIU.GenericOptimizer{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, MOIU.VectorOfConstraints{MOI.VectorAffineFunction{Float64}, MOI.Complements}} ``` ## Printing @@ -284,7 +284,7 @@ MathOptInterface.VariableIndex(1) julia> MOI.set(model, MOI.VariableName(), x, "x_var") julia> MOI.add_constraint(model, x, MOI.ZeroOne()) -MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex,MathOptInterface.ZeroOne}(1) +MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.ZeroOne}(1) julia> MOI.set(model, MOI.ObjectiveFunction{typeof(x)}(), x) @@ -300,7 +300,7 @@ VariableIndex-in-ZeroOne x_var ∈ {0, 1} ``` -Use [`Utilities.latex_formulation`](@Ref) to display the model in LaTeX form: +Use [`Utilities.latex_formulation`](@ref) to display the model in LaTeX form: ```jldoctest utilities_print julia> MOI.Utilities.latex_formulation(model) $$ \begin{aligned} diff --git a/docs/src/tutorials/example.md b/docs/src/tutorials/example.md index 19880c38d9..29b420c929 100644 --- a/docs/src/tutorials/example.md +++ b/docs/src/tutorials/example.md @@ -35,13 +35,13 @@ optimizer = GLPK.Optimizer() We first define the constants of the problem: ```jldoctest knapsack; setup = :(optimizer = MOI.Utilities.MockOptimizer(MOI.Utilities.Model{Float64}()); MOI.Utilities.set_mock_optimize!(optimizer, mock -> MOI.Utilities.mock_optimize!(mock, ones(3)))) julia> c = [1.0, 2.0, 3.0] -3-element Array{Float64,1}: +3-element Vector{Float64}: 1.0 2.0 3.0 julia> w = [0.3, 0.5, 1.0] -3-element Array{Float64,1}: +3-element Vector{Float64}: 0.3 0.5 1.0 @@ -135,7 +135,7 @@ julia> MOI.get(optimizer, MOI.ObjectiveValue()) And what is the value of the variables `x`? ```jldoctest knapsack julia> MOI.get(optimizer, MOI.VariablePrimal(), x) -3-element Array{Float64,1}: +3-element Vector{Float64}: 1.0 1.0 1.0 diff --git a/docs/src/tutorials/manipulating_expressions.md b/docs/src/tutorials/manipulating_expressions.md index d1c269af79..02aba58a76 100644 --- a/docs/src/tutorials/manipulating_expressions.md +++ b/docs/src/tutorials/manipulating_expressions.md @@ -33,14 +33,14 @@ can be built using the standard constructor: ```jldoctest expr julia> f = MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1, x)], 2) # x + 2 -MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[ScalarAffineTerm{Int64}(1, VariableIndex(1))], 2) +MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[MathOptInterface.ScalarAffineTerm{Int64}(1, MathOptInterface.VariableIndex(1))], 2) ``` However, you can also use operators to build the same scalar function: ```jldoctest expr julia> f = x + 2 -MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[ScalarAffineTerm{Int64}(1, VariableIndex(1))], 2) +MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[MathOptInterface.ScalarAffineTerm{Int64}(1, MathOptInterface.VariableIndex(1))], 2) ``` ### Creating scalar quadratic functions @@ -51,13 +51,13 @@ obtain a quadratic function as a product of affine functions: ```jldoctest expr julia> 1 * x * x -MathOptInterface.ScalarQuadraticFunction{Int64}(MathOptInterface.ScalarQuadraticTerm{Int64}[ScalarQuadraticTerm{Int64}(2, VariableIndex(1), VariableIndex(1))], MathOptInterface.ScalarAffineTerm{Int64}[], 0) +MathOptInterface.ScalarQuadraticFunction{Int64}(MathOptInterface.ScalarQuadraticTerm{Int64}[MathOptInterface.ScalarQuadraticTerm{Int64}(2, MathOptInterface.VariableIndex(1), MathOptInterface.VariableIndex(1))], MathOptInterface.ScalarAffineTerm{Int64}[], 0) julia> f * f # (x + 2)² -MathOptInterface.ScalarQuadraticFunction{Int64}(MathOptInterface.ScalarQuadraticTerm{Int64}[ScalarQuadraticTerm{Int64}(2, VariableIndex(1), VariableIndex(1))], MathOptInterface.ScalarAffineTerm{Int64}[ScalarAffineTerm{Int64}(2, VariableIndex(1)), ScalarAffineTerm{Int64}(2, VariableIndex(1))], 4) +MathOptInterface.ScalarQuadraticFunction{Int64}(MathOptInterface.ScalarQuadraticTerm{Int64}[MathOptInterface.ScalarQuadraticTerm{Int64}(2, MathOptInterface.VariableIndex(1), MathOptInterface.VariableIndex(1))], MathOptInterface.ScalarAffineTerm{Int64}[MathOptInterface.ScalarAffineTerm{Int64}(2, MathOptInterface.VariableIndex(1)), MathOptInterface.ScalarAffineTerm{Int64}(2, MathOptInterface.VariableIndex(1))], 4) julia> f^2 # (x + 2)² too -MathOptInterface.ScalarQuadraticFunction{Int64}(MathOptInterface.ScalarQuadraticTerm{Int64}[ScalarQuadraticTerm{Int64}(2, VariableIndex(1), VariableIndex(1))], MathOptInterface.ScalarAffineTerm{Int64}[ScalarAffineTerm{Int64}(2, VariableIndex(1)), ScalarAffineTerm{Int64}(2, VariableIndex(1))], 4) +MathOptInterface.ScalarQuadraticFunction{Int64}(MathOptInterface.ScalarQuadraticTerm{Int64}[MathOptInterface.ScalarQuadraticTerm{Int64}(2, MathOptInterface.VariableIndex(1), MathOptInterface.VariableIndex(1))], MathOptInterface.ScalarAffineTerm{Int64}[MathOptInterface.ScalarAffineTerm{Int64}(2, MathOptInterface.VariableIndex(1)), MathOptInterface.ScalarAffineTerm{Int64}(2, MathOptInterface.VariableIndex(1))], 4) ``` ### Creating vector functions @@ -74,7 +74,7 @@ dimension corresponding to a dimension of the vector. ```jldoctest expr julia> g = MOI.Utilities.vectorize([f, 2 * f]) -MathOptInterface.VectorAffineFunction{Int64}(MathOptInterface.VectorAffineTerm{Int64}[VectorAffineTerm{Int64}(1, ScalarAffineTerm{Int64}(1, VariableIndex(1))), VectorAffineTerm{Int64}(2, ScalarAffineTerm{Int64}(2, VariableIndex(1)))], [2, 4]) +MathOptInterface.VectorAffineFunction{Int64}(MathOptInterface.VectorAffineTerm{Int64}[MathOptInterface.VectorAffineTerm{Int64}(1, MathOptInterface.ScalarAffineTerm{Int64}(1, MathOptInterface.VariableIndex(1))), MathOptInterface.VectorAffineTerm{Int64}(2, MathOptInterface.ScalarAffineTerm{Int64}(2, MathOptInterface.VariableIndex(1)))], [2, 4]) ``` !!! warning @@ -109,7 +109,7 @@ function: ```jldoctest expr julia> MOI.Utilities.canonical(f + f) # Returns 2x + 4 -MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[ScalarAffineTerm{Int64}(2, VariableIndex(1))], 4) +MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[MathOptInterface.ScalarAffineTerm{Int64}(2, MathOptInterface.VariableIndex(1))], 4) ``` ## Exploring functions @@ -124,9 +124,9 @@ vector function: ```jldoctest expr julia> MOI.Utilities.scalarize(g) # Returns a vector [f, 2 * f]. -2-element Array{MathOptInterface.ScalarAffineFunction{Int64},1}: - MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[ScalarAffineTerm{Int64}(1, VariableIndex(1))], 2) - MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[ScalarAffineTerm{Int64}(2, VariableIndex(1))], 4) +2-element Vector{MathOptInterface.ScalarAffineFunction{Int64}}: + MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[MathOptInterface.ScalarAffineTerm{Int64}(1, MathOptInterface.VariableIndex(1))], 2) + MathOptInterface.ScalarAffineFunction{Int64}(MathOptInterface.ScalarAffineTerm{Int64}[MathOptInterface.ScalarAffineTerm{Int64}(2, MathOptInterface.VariableIndex(1))], 4) ``` !!! note diff --git a/src/Bridges/Constraint/bridge.jl b/src/Bridges/Constraint/bridge.jl index 1a1f155ac4..7e6863f31b 100644 --- a/src/Bridges/Constraint/bridge.jl +++ b/src/Bridges/Constraint/bridge.jl @@ -126,7 +126,7 @@ MOI.Bridges.Constraint.concrete_bridge_type( # output -MathOptInterface.Bridges.Constraint.SplitIntervalBridge{Float64,MathOptInterface.VariableIndex,MathOptInterface.Interval{Float64},MathOptInterface.GreaterThan{Float64},MathOptInterface.LessThan{Float64}} +MathOptInterface.Bridges.Constraint.SplitIntervalBridge{Float64, MathOptInterface.VariableIndex, MathOptInterface.Interval{Float64}, MathOptInterface.GreaterThan{Float64}, MathOptInterface.LessThan{Float64}} ``` """ function concrete_bridge_type( diff --git a/src/Bridges/Variable/bridge.jl b/src/Bridges/Variable/bridge.jl index fe96480bf1..6474bfc7a1 100644 --- a/src/Bridges/Variable/bridge.jl +++ b/src/Bridges/Variable/bridge.jl @@ -150,7 +150,7 @@ MOI.Bridges.added_constrained_variable_types( # output -1-element Array{Tuple{Type},1}: +1-element Vector{Tuple{Type}}: (MathOptInterface.Nonnegatives,) ``` """ @@ -189,7 +189,7 @@ MOI.Bridges.added_constraint_types( # output -2-element Array{Tuple{Type,Type},1}: +2-element Vector{Tuple{Type, Type}}: (MathOptInterface.VariableIndex, MathOptInterface.EqualTo{Float64}) (MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}) ``` @@ -225,7 +225,7 @@ MOI.Bridges.Variable.concrete_bridge_type( # output -MathOptInterface.Bridges.Variable.VectorizeBridge{Float64,MathOptInterface.Nonnegatives} +MathOptInterface.Bridges.Variable.VectorizeBridge{Float64, MathOptInterface.Nonnegatives} ``` """ function concrete_bridge_type(bridge_type::Type, ::Type{<:MOI.AbstractSet})