jump-dev / MiniZinc.jl

A Julia interface to the MiniZinc constraint modeling language
https://www.minizinc.org/
MIT License
18 stars 4 forks source link

Fix writing integer variables with float bounds #78

Closed odow closed 3 months ago

odow commented 3 months ago

Closes #77

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.78%. Comparing base (8c7a7d3) to head (7504580).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #78 +/- ## ========================================== + Coverage 97.76% 97.78% +0.01% ========================================== Files 3 3 Lines 493 496 +3 ========================================== + Hits 482 485 +3 Misses 11 11 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

odow commented 3 months ago
julia> using JuMP

julia> import MiniZinc

julia> model = Model(() -> MiniZinc.Optimizer{Float64}("highs"))
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: MiniZinc

julia> @variable(model, 1 <= x[1:3] <= 3, Int)
3-element Vector{VariableRef}:
 x[1]
 x[2]
 x[3]

julia> @constraint(model, x in MOI.AllDifferent(3))
[x[1], x[2], x[3]] ∈ MathOptInterface.AllDifferent(3)

julia> @objective(model, Max, sum(i * x[i] for i in 1:3))
x[1] + 2 x[2] + 3 x[3]

julia> optimize!(model)

julia> @show value.(x)
value.(x) = [1.0, 2.0, 3.0]
3-element Vector{Float64}:
 1.0
 2.0
 3.0