Skip to content

Commit 0aff518

Browse files
committed
Add guideline in doc
1 parent b634ecd commit 0aff518

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

docs/src/apimanual.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,4 +565,39 @@ If `canaddconstraint` returns `false`, then calling `addconstraint!` must throw
565565

566566
### Package Naming
567567

568-
MOI solver interfaces may be in the same package as the solver itself (either the C wrapper if the solver is accessible through C, or the Julia code if the solver is written in Julia, for example). In some cases it may be more appropriate to host the MOI wrapper in its own package; in this case it is recommended that the MOI wrapper package be named `MathOptInterfaceXXX` where `XXX` is the solver name.
568+
MOI solver interfaces may be in the same package as the solver itself (either the C wrapper if the solver is accessible through C, or the Julia code if the solver is written in Julia, for example).
569+
The guideline for naming the file containing the MOI wrapper is `src/MOIWrapper.jl` and `test/MOIWrapper.jl` for the tests.
570+
In some cases it may be more appropriate to host the MOI wrapper in its own package; in this case it is recommended that the MOI wrapper package be named `MathOptInterfaceXXX` where `XXX` is the solver name.
571+
572+
### Testing guideline
573+
574+
The skeleton below can be used for the wrapper test file of a solver name `FooBar`:
575+
```julia
576+
using MathOptInterface
577+
const MOI = MathOptInterface
578+
const MOIT = MOI.Test
579+
const MOIU = MOI.Utilities
580+
const MOIB = MOI.Bridges
581+
582+
# Include here the functions/sets supported by the solver wrapper (not those that are supported through bridges)
583+
MOIU.@model FooBarModelData () (EqualTo, GreaterThan, LessThan) (Zeros, Nonnegatives, Nonpositives) () (SingleVariable,) (ScalarAffineFunction,) (VectorOfVariables,) (VectorAffineFunction,)
584+
585+
MOIB.@bridge SplitInterval MOIB.SplitIntervalBridge () (Interval,) () () () (ScalarAffineFunction,) () ()
586+
MOIB.@bridge GeoMean MOIB.GeoMeanBridge () () (GeometricMeanCone,) () () () (VectorOfVariables,) (VectorAffineFunction,)
587+
MOIB.@bridge RootDet MOIB.RootDetBridge () () (RootDetConeTriangle,) () () () (VectorOfVariables,) (VectorAffineFunction,)
588+
589+
const optimizer = FooBarOptimizer()
590+
const config = MOIT.TestConfig(atol=1e-6, rtol=1e-6)
591+
592+
@testset "MOI Continuous Linear" begin
593+
MOIT.contlineartest(SplitInterval{Float64}(MOIU.CachingOptimizer(FooBarModelData{Float64}(), optimizer)), config)
594+
end
595+
596+
@testset "MOI Continuous Conic" begin
597+
MOIT.contlineartest(RootDet{Float64}(GeoMean{Float64}(MOIU.CachingOptimizer(FooBarModelData{Float64}(), optimizer))), config)
598+
end
599+
600+
@testset "MOI Integer Conic" begin
601+
MOIT.intconictest(MOIU.CachingOptimizer(FooBarModelData{Float64}(), optimizer), config)
602+
end
603+
```

0 commit comments

Comments
 (0)