Skip to content

Commit ab1555f

Browse files
authored
Test with HiGHS (#34)
1 parent e8ae6a8 commit ab1555f

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ julia> main()
100100
## Use with JuMP
101101

102102
You can also call MiniZinc from JuMP, using any solver that `libminizinc`
103-
supports. For example, if you have Gurobi installed:
103+
supports. By default, MiniZinc.jl is comiled with `"highs"`:
104+
104105
```julia
105106
using JuMP
106107
import MiniZinc
107-
model = Model(() -> MiniZinc.Optimizer{Float64}("gurobi"))
108+
model = Model(() -> MiniZinc.Optimizer{Float64}("highs"))
108109
@variable(model, 1 <= x[1:3] <= 3, Int)
109110
@constraint(model, x in MOI.AllDifferent(3))
110111
@objective(model, Max, sum(i * x[i] for i in 1:3))
@@ -114,12 +115,12 @@ optimize!(model)
114115

115116
## MathOptInterface API
116117

117-
The MiniZinc optimizer supports the following constraints and attributes.
118+
The MiniZinc `Optimizer{T}` supports the following constraints and attributes.
118119

119120
List of supported objective functions:
120121

121-
* [`MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}`](@ref)
122-
* [`MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{Float64}}`](@ref)
122+
* [`MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}`](@ref)
123+
* [`MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{T}}`](@ref)
123124
* [`MOI.ObjectiveFunction{MOI.VariableIndex}`](@ref)
124125

125126
List of supported variable types:
@@ -128,31 +129,31 @@ List of supported variable types:
128129

129130
List of supported constraint types:
130131

131-
* [`MOI.ScalarAffineFunction{Float64}`](@ref) in [`MOI.EqualTo{Float64}`](@ref)
132-
* [`MOI.ScalarAffineFunction{Float64}`](@ref) in [`MOI.GreaterThan{Float64}`](@ref)
133-
* [`MOI.ScalarAffineFunction{Float64}`](@ref) in [`MOI.Integer`](@ref)
134-
* [`MOI.ScalarAffineFunction{Float64}`](@ref) in [`MOI.Interval{Float64}`](@ref)
135-
* [`MOI.ScalarAffineFunction{Float64}`](@ref) in [`MOI.LessThan{Float64}`](@ref)
136-
* [`MOI.ScalarAffineFunction{Float64}`](@ref) in [`MOI.ZeroOne`](@ref)
137-
* [`MOI.VariableIndex`](@ref) in [`MOI.EqualTo{Float64}`](@ref)
138-
* [`MOI.VariableIndex`](@ref) in [`MOI.GreaterThan{Float64}`](@ref)
132+
* [`MOI.ScalarAffineFunction{T}`](@ref) in [`MOI.EqualTo{T}`](@ref)
133+
* [`MOI.ScalarAffineFunction{T}`](@ref) in [`MOI.GreaterThan{T}`](@ref)
134+
* [`MOI.ScalarAffineFunction{T}`](@ref) in [`MOI.Integer`](@ref)
135+
* [`MOI.ScalarAffineFunction{T}`](@ref) in [`MOI.Interval{T}`](@ref)
136+
* [`MOI.ScalarAffineFunction{T}`](@ref) in [`MOI.LessThan{T}`](@ref)
137+
* [`MOI.ScalarAffineFunction{T}`](@ref) in [`MOI.ZeroOne`](@ref)
138+
* [`MOI.VariableIndex`](@ref) in [`MOI.EqualTo{T}`](@ref)
139+
* [`MOI.VariableIndex`](@ref) in [`MOI.GreaterThan{T}`](@ref)
139140
* [`MOI.VariableIndex`](@ref) in [`MOI.Integer`](@ref)
140-
* [`MOI.VariableIndex`](@ref) in [`MOI.Interval{Float64}`](@ref)
141-
* [`MOI.VariableIndex`](@ref) in [`MOI.LessThan{Float64}`](@ref)
142-
* [`MOI.VariableIndex`](@ref) in [`MOI.Parameter{Float64}`](@ref)
143-
* [`MOI.VariableIndex`](@ref) in [`MOI.Semicontinuous{Float64}`](@ref)
144-
* [`MOI.VariableIndex`](@ref) in [`MOI.Semiinteger{Float64}`](@ref)
141+
* [`MOI.VariableIndex`](@ref) in [`MOI.Interval{T}`](@ref)
142+
* [`MOI.VariableIndex`](@ref) in [`MOI.LessThan{T}`](@ref)
143+
* [`MOI.VariableIndex`](@ref) in [`MOI.Parameter{T}`](@ref)
144+
* [`MOI.VariableIndex`](@ref) in [`MOI.Semicontinuous{T}`](@ref)
145+
* [`MOI.VariableIndex`](@ref) in [`MOI.Semiinteger{T}`](@ref)
145146
* [`MOI.VariableIndex`](@ref) in [`MOI.ZeroOne`](@ref)
146147
* [`MOI.VectorOfVariables`](@ref) in [`MOI.AllDifferent`](@ref)
147-
* [`MOI.VectorOfVariables`](@ref) in [`MOI.BinPacking{Float64}`](@ref)
148+
* [`MOI.VectorOfVariables`](@ref) in [`MOI.BinPacking{T}`](@ref)
148149
* [`MOI.VectorOfVariables`](@ref) in [`MOI.Circuit`](@ref)
149150
* [`MOI.VectorOfVariables`](@ref) in [`MOI.CountAtLeast`](@ref)
150151
* [`MOI.VectorOfVariables`](@ref) in [`MOI.CountBelongs`](@ref)
151152
* [`MOI.VectorOfVariables`](@ref) in [`MOI.CountDistinct`](@ref)
152153
* [`MOI.VectorOfVariables`](@ref) in [`MOI.CountGreaterThan`](@ref)
153154
* [`MOI.VectorOfVariables`](@ref) in [`MOI.Cumulative`](@ref)
154155
* [`MOI.VectorOfVariables`](@ref) in [`MOI.Path`](@ref)
155-
* [`MOI.VectorOfVariables`](@ref) in [`MOI.Table{Float64}`](@ref)
156+
* [`MOI.VectorOfVariables`](@ref) in [`MOI.Table{T}`](@ref)
156157

157158
List of supported model attributes:
158159

test/runtests.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,24 @@ function test_write_bool()
11891189
return
11901190
end
11911191

1192+
function test_highs()
1193+
model = MOI.Utilities.Model{Float64}()
1194+
x, x_int = MOI.add_constrained_variable(model, MOI.Integer())
1195+
c1 = MOI.add_constraint(model, x, MOI.GreaterThan(1.0))
1196+
c2 = MOI.add_constraint(model, x, MOI.LessThan(3.0))
1197+
@test MOI.is_valid(model, x)
1198+
@test MOI.is_valid(model, x_int)
1199+
@test MOI.is_valid(model, c1)
1200+
@test MOI.is_valid(model, c2)
1201+
solver = MiniZinc.Optimizer{Float64}("highs")
1202+
index_map, _ = MOI.optimize!(solver, model)
1203+
@test MOI.get(solver, MOI.TerminationStatus()) === MOI.OPTIMAL
1204+
@test MOI.get(solver, MOI.ResultCount()) >= 1
1205+
@test MOI.get(solver, MOI.VariablePrimal(), index_map[x]) in [1.0, 2.0, 3.0]
1206+
@test MOI.get(solver, MOI.RawStatusString()) == "SATISFIABLE"
1207+
return
1208+
end
1209+
11921210
end
11931211

11941212
TestMiniZinc.runtests()

0 commit comments

Comments
 (0)