Hi, I am trying to see if it is possible to return multiple solutions from MiniZinc.jl. I am not sure how to set the flag to do so for the MiniZinc solver. Following the example at this stackoverflow question (Multiple output under minizinc - Stack Overflow) the following code returns 1 of 4 possible solutions. Thanks for any help anyone can provide!

julia> using JuMP
julia> import MiniZinc
julia> model = GenericModel{Int}(() -> MiniZinc.Optimizer{Int}("chuffed"));
julia> set_attribute(model, MOI.SolutionLimit(), 10) # Or some large value
julia> @variable(model, 1 <= x[1:2] <= 9, Int);
julia> @constraint(model, x in MOI.AllDifferent(2));
julia> @constraint(model, sum(x) == 3);
julia> optimize!(model)
julia> [value.(x; result = i) for i in 1:result_count(model)]
2-element Vector{Vector{Int64}}:
[1, 2]
[2, 1]

Thank you @odow! Ah, the JuMP syntax is much nicer than working at the â€śMOI levelâ€ť. Can you explain what GenericModel{Int} is, and why we need to set the optimizer as an anonymous function?

The default model = Model() constructor assumes coefficients are Float64. This is a feature to use Int coefficients (and variable values). See Arbitrary precision arithmetic Â· JuMP

why we need to set the optimizer as an anonymous function

Because you are passing an argument to MiniZinc.Optimizer. See Models Â· JuMP