Skip to content

Add import MathOptInterface as MOI to DocTestSetup #2746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
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
7 changes: 7 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ end
# link checking. Inn production we replace this by running the LaTeX build.
write(joinpath(@__DIR__, "src", "MathOptInterface.pdf"), "")

Documenter.DocMeta.setdocmeta!(
MathOptInterface,
:DocTestSetup,
:(import MathOptInterface as MOI);
recursive = true,
)

@time Documenter.makedocs(
sitename = "MathOptInterface",
authors = "The JuMP core developers and contributors",
Expand Down
4 changes: 0 additions & 4 deletions src/Benchmarks/Benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ Extra `kwargs` are based to `BenchmarkTools.run`.
## Example

```julia
julia> import MathOptInterface as MOI

julia> import GLPK

julia> my_suite = MOI.Benchmarks.suite(() -> GLPK.Optimizer());
Expand Down Expand Up @@ -100,8 +98,6 @@ Extra `kwargs` are based to `BenchmarkTools.run`.
## Example

```julia
julia> import MathOptInterface as MOI

julia> import GLPK

julia> my_suite = MOI.Benchmarks.suite(() -> GLPK.Optimizer());
Expand Down
6 changes: 3 additions & 3 deletions src/Bridges/Bridges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ coefficient type `T`, as well as the bridges in the list returned by the

## Example

```jldoctest; setup=:(import MathOptInterface as MOI)
```jldoctest
julia> model = MOI.Utilities.Model{Float64}();

julia> bridged_model = MOI.Bridges.full_bridge_optimizer(model, Float64);
Expand Down Expand Up @@ -273,7 +273,7 @@ and [`MOI.ConstraintPrimalStart`](@ref) to throw [`MOI.GetAttributeNotAllowed`](

## Example

```jldoctest; setup=:(import MathOptInterface as MOI), filter=r"[0-9.]+s"
```jldoctest; filter=r"[0-9.]+s"
julia> MOI.Bridges.runtests(
MOI.Bridges.Constraint.ZeroOneBridge,
model -> MOI.add_constrained_variable(model, MOI.ZeroOne()),
Expand Down Expand Up @@ -423,7 +423,7 @@ Run a series of tests that check the correctness of `Bridge`.

## Example

```jldoctest; setup=:(import MathOptInterface as MOI), filter=r"[0-9.]+s"
```jldoctest; filter=r"[0-9.]+s"
julia> MOI.Bridges.runtests(
MOI.Bridges.Constraint.ZeroOneBridge,
\"\"\"
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/Constraint/bridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The [`SplitIntervalBridge`](@ref) bridges a [`MOI.VariableIndex`](@ref)-in-[`MOI
constraint into a [`MOI.VariableIndex`](@ref)-in-[`MOI.GreaterThan`](@ref) and a
[`MOI.VariableIndex`](@ref)-in-[`MOI.LessThan`](@ref) constraint.

```jldoctest; setup=:(import MathOptInterface as MOI)
```jldoctest
julia> MOI.Bridges.Constraint.concrete_bridge_type(
MOI.Bridges.Constraint.SplitIntervalBridge{Float64},
MOI.VariableIndex,
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/Constraint/single_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and unsupported by `model`.

## Example

```jldoctest con_singlebridgeoptimizer; setup=:(import MathOptInterface as MOI)
```jldoctest con_singlebridgeoptimizer
julia> struct MyNewBridge{T} <: MOI.Bridges.Constraint.AbstractBridge end

julia> bridge = MOI.Bridges.Constraint.SingleBridgeOptimizer{MyNewBridge{Float64}}(
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/Objective/single_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and unsupported by `model`.

## Example

```jldoctest obj_singlebridgeoptimizer; setup=:(import MathOptInterface as MOI)
```jldoctest obj_singlebridgeoptimizer
julia> struct MyNewBridge{T} <: MOI.Bridges.Objective.AbstractBridge end

julia> bridge = MOI.Bridges.Objective.SingleBridgeOptimizer{MyNewBridge{Float64}}(
Expand Down
4 changes: 1 addition & 3 deletions src/Bridges/Variable/bridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ solver.

## Example

```jldoctest; setup=(import MathOptInterface as MOI)
```jldoctest
julia> MOI.Bridges.Variable.supports_constrained_variable(
MOI.Bridges.Variable.NonposToNonnegBridge{Float64},
MOI.Nonpositives,
Expand Down Expand Up @@ -78,8 +78,6 @@ variables in [`MOI.Nonnegatives`](@ref) by the
[`VectorizeBridge`](@ref):

```jldoctest
julia> import MathOptInterface as MOI

julia> MOI.Bridges.Variable.concrete_bridge_type(
MOI.Bridges.Variable.VectorizeBridge{Float64},
MOI.GreaterThan{Float64},
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/Variable/single_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ by the bridge `BT` and unsupported by `model`.

## Example

```jldoctest var_singlebridgeoptimizer; setup=:(import MathOptInterface as MOI)
```jldoctest var_singlebridgeoptimizer
julia> struct MyNewBridge{T} <: MOI.Bridges.Variable.AbstractBridge end

julia> bridge = MOI.Bridges.Variable.SingleBridgeOptimizer{MyNewBridge{Float64}}(
Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/bridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ type `BT` add.

## Example

```jldoctest; setup=(import MathOptInterface as MOI)
```jldoctest
julia> MOI.Bridges.added_constrained_variable_types(
MOI.Bridges.Variable.NonposToNonnegBridge{Float64},
)
Expand All @@ -229,7 +229,7 @@ add.

## Example

```jldoctest; setup=(import MathOptInterface as MOI)
```jldoctest
julia> MOI.Bridges.added_constraint_types(
MOI.Bridges.Constraint.ZeroOneBridge{Float64},
)
Expand All @@ -254,7 +254,7 @@ set.

## Example

```jldoctest; setup=(import MathOptInterface as MOI)
```jldoctest
julia> MOI.Bridges.set_objective_function_type(
MOI.Bridges.Objective.FunctionizeBridge{Float64},
)
Expand Down Expand Up @@ -311,7 +311,7 @@ constraint.
For this reason, the [`Bridges.Constraint.FunctionConversionBridge`](@ref) is
given a cost of `10`:

```jldoctest; setup=(import MathOptInterface as MOI)
```jldoctest
julia> F = MOI.ScalarQuadraticFunction{Float64};

julia> G = MOI.ScalarAffineFunction{Float64};
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ and [`full_bridge_optimizer`](@ref).

## Example

```jldoctest; setup=:(import MathOptInterface as MOI)
```jldoctest
julia> model = MOI.Bridges.LazyBridgeOptimizer(MOI.Utilities.Model{Float64}());

julia> MOI.Bridges.add_bridge(model, MOI.Bridges.Variable.FreeBridge{Float64})
Expand Down
2 changes: 0 additions & 2 deletions src/Nonlinear/ReverseAD/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ end.
## Examples

```jldoctest
julia> import MathOptInterface as MOI

julia> x = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
3-element Vector{Tuple{Int64, Int64, Int64}}:
(1, 2, 3)
Expand Down
8 changes: 0 additions & 8 deletions src/Nonlinear/SymbolicAD/SymbolicAD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ Return a simplified copy of the function `f`.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> x = MOI.VariableIndex(1)
MOI.VariableIndex(1)

Expand Down Expand Up @@ -52,8 +50,6 @@ new object if `f` can be represented in a simpler type.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> x = MOI.VariableIndex(1)
MOI.VariableIndex(1)

Expand Down Expand Up @@ -356,8 +352,6 @@ Return a sorted list of the `MOI.VariableIndex` present in the function `f`.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> x = MOI.VariableIndex.(1:3)
3-element Vector{MathOptInterface.VariableIndex}:
MOI.VariableIndex(1)
Expand Down Expand Up @@ -463,8 +457,6 @@ simplified expression of the derivative.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> x = MOI.VariableIndex(1)
MOI.VariableIndex(1)

Expand Down
2 changes: 0 additions & 2 deletions src/Nonlinear/evaluator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Return the 1-indexed value of the constraint index `c` in `evaluator`.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> model = MOI.Nonlinear.Model()
A Nonlinear.Model with:
0 objectives
Expand Down
10 changes: 0 additions & 10 deletions src/Nonlinear/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ To remove the objective, pass `nothing`.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> model = MOI.Nonlinear.Model()
A Nonlinear.Model with:
0 objectives
Expand Down Expand Up @@ -90,8 +88,6 @@ Parse `expr` into a [`Expression`](@ref) and add to `model`. Returns an
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> model = MOI.Nonlinear.Model();

julia> x = MOI.VariableIndex(1);
Expand Down Expand Up @@ -130,8 +126,6 @@ solution information.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> model = MOI.Nonlinear.Model();

julia> x = MOI.VariableIndex(1);
Expand Down Expand Up @@ -165,8 +159,6 @@ Delete the constraint index `c` from `model`.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> model = MOI.Nonlinear.Model()
A Nonlinear.Model with:
0 objectives
Expand Down Expand Up @@ -220,8 +212,6 @@ and used to modify the value of the parameter.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> model = MOI.Nonlinear.Model()
A Nonlinear.Model with:
0 objectives
Expand Down
12 changes: 0 additions & 12 deletions src/Nonlinear/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ The list of univariate operators that are supported by default.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> MOI.Nonlinear.DEFAULT_UNIVARIATE_OPERATORS
73-element Vector{Symbol}:
:+
Expand Down Expand Up @@ -141,8 +139,6 @@ The list of multivariate operators that are supported by default.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> MOI.Nonlinear.DEFAULT_MULTIVARIATE_OPERATORS
9-element Vector{Symbol}:
:+
Expand Down Expand Up @@ -550,8 +546,6 @@ If `op isa Integer`, then `op` is the index in
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> r = MOI.Nonlinear.OperatorRegistry();

julia> MOI.Nonlinear.eval_univariate_function(r, :abs, -1.2)
Expand Down Expand Up @@ -603,8 +597,6 @@ If `op isa Integer`, then `op` is the index in
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> r = MOI.Nonlinear.OperatorRegistry();

julia> MOI.Nonlinear.eval_univariate_gradient(r, :abs, -1.2)
Expand Down Expand Up @@ -656,8 +648,6 @@ If `op isa Integer`, then `op` is the index in
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> r = MOI.Nonlinear.OperatorRegistry();

julia> MOI.Nonlinear.eval_univariate_function_and_gradient(r, :abs, -1.2)
Expand Down Expand Up @@ -708,8 +698,6 @@ If `op isa Integer`, then `op` is the index in
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> r = MOI.Nonlinear.OperatorRegistry();

julia> MOI.Nonlinear.eval_univariate_hessian(r, :sin, 1.0)
Expand Down
2 changes: 0 additions & 2 deletions src/Test/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ For a nonlinear solver that finds local optima and does not support finding
dual variables or constraint names:

```jldoctest
julia> import MathOptInterface as MOI

julia> config = MOI.Test.Config(
Float64;
optimal_status = MOI.LOCALLY_SOLVED,
Expand Down
6 changes: 0 additions & 6 deletions src/Utilities/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,6 @@ The output of `canonical` can be assumed to be a copy of `f`, even for
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> x, y, z = MOI.VariableIndex.(1:3);

julia> f = MOI.ScalarAffineFunction(
Expand Down Expand Up @@ -1165,8 +1163,6 @@ want to first call [`canonical`](@ref) if that is not guaranteed.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> x = MOI.VariableIndex(1)
MOI.VariableIndex(1)

Expand Down Expand Up @@ -2557,8 +2553,6 @@ complex-valued).
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> MOI.Utilities.is_complex(MOI.VariableIndex)
false

Expand Down
2 changes: 0 additions & 2 deletions src/Utilities/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,6 @@ in MOI. It is parameterized by the coefficient type.
## Example

```jldoctest
julia> import MathOptInterface as MOI

julia> model = MOI.Utilities.Model{Float64}()
MOIU.Model{Float64}
├ ObjectiveSense: FEASIBILITY_SENSE
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ A utility function to aid writing tests.

## Example

```jldoctest; setup=:(import MathOptInterface as MOI)
```jldoctest
julia> model = MOI.Utilities.Model{Float64}();

julia> MOI.Utilities.loadfromstring!(model, \"\"\"
Expand Down
6 changes: 3 additions & 3 deletions src/Utilities/penalty_relaxation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ this function to compute the violation of the constraint.

## Example

```jldoctest; setup=:(import MathOptInterface as MOI)
```jldoctest
julia> model = MOI.Utilities.Model{Float64}();

julia> x = MOI.add_variable(model);
Expand Down Expand Up @@ -189,7 +189,7 @@ To modify variable bounds, rewrite them as linear constraints.

## Example

```jldoctest; setup=:(import MathOptInterface as MOI)
```jldoctest
julia> model = MOI.Utilities.Model{Float64}();

julia> x = MOI.add_variable(model);
Expand All @@ -214,7 +214,7 @@ julia> map[c] isa MOI.ScalarAffineFunction{Float64}
true
```

```jldoctest; setup=:(import MathOptInterface as MOI)
```jldoctest
julia> model = MOI.Utilities.Model{Float64}();

julia> x = MOI.add_variable(model);
Expand Down
Loading
Loading