Skip to content

Commit

Permalink
Update to [email protected] (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Jul 17, 2024
1 parent feaa954 commit d3fef25
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name = "MiniZinc"
uuid = "a7f392d2-6c35-496e-b8cc-0974fbfcbf91"
authors = ["odow <[email protected]>"]
version = "0.3.10"
version = "0.3.11"

[deps]
Chuffed_jll = "77125aae-c893-5498-99e3-e30470bfa328"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
MiniZinc_jll = "3677d96b-3d39-5184-a844-8e8b2839af35"

[compat]
Chuffed_jll = "=0.10.4"
Chuffed_jll = "=0.10.4, =0.13.2"
MathOptInterface = "1.21"
MiniZinc_jll = "=2.7.6"
Test = "<0.0.1, 1.6"
Expand Down
21 changes: 15 additions & 6 deletions src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

Chuffed() = joinpath(Chuffed_jll.artifact_dir, "chuffed.msc")
function Chuffed()
for subdir in ["", joinpath("share", "minizinc", "solvers")]
file = joinpath(Chuffed_jll.artifact_dir, subdir, "chuffed.msc")
if isfile(file)
return file
end
end
end

function run_flatzinc(solver_cmd::F, filename, args = String[]) where {F}
try
return String(read(`$(solver_cmd()) $(vcat(args, filename))`))
catch
return ""
end
io = IOBuffer()
run(pipeline(`$(solver_cmd()) $(vcat(args, filename))`; stdout = io))
seekstart(io)
return read(io, String)
end

"""
Expand Down Expand Up @@ -91,6 +97,9 @@ function _run_minizinc(dest::Optimizer)
end
catch
status = "=====ERROR=====\n"
if isfile(_stdout)
status *= read(_stdout, String)
end
if isfile(_stderr)
status *= read(_stderr, String)
end
Expand Down
10 changes: 5 additions & 5 deletions test/assets/einstein.fzn
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ array [1..5] of var 1..5: c :: output_array([1..5]);
array [1..5] of var 1..5: d :: output_array([1..5]);
array [1..5] of var 1..5: k :: output_array([1..5]);
array [1..5] of var 1..5: s :: output_array([1..5]);
constraint all_different_int(a);
constraint all_different_int(c);
constraint all_different_int(d);
constraint all_different_int(k);
constraint all_different_int(s);
constraint fzn_all_different_int(a);
constraint fzn_all_different_int(c);
constraint fzn_all_different_int(d);
constraint fzn_all_different_int(k);
constraint fzn_all_different_int(s);
constraint int_abs(INT____00001, 1);
constraint int_abs(INT____00003, 1);
constraint int_abs(INT____00005, 1);
Expand Down
2 changes: 1 addition & 1 deletion test/examples/nqueens_solveall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
function _test_nqueens_solve_num_solutions(
model,
q,
actual_count = 92,
actual_count = 52,
termination_status = MOI.OPTIMAL,
)
n = 8
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,8 @@ function test_chuffed_basic()
end

function test_chuffed_one_solution()
@test _test_chuffed_asset("one_solution.fzn") ==
"x = 10;\n\n----------\n==========\n"
solution = "x = 10;\n\n----------\n==========\n"
@test startswith(_test_chuffed_asset("one_solution.fzn"), solution)
return
end

Expand Down Expand Up @@ -1170,7 +1170,7 @@ end
function test_moi_tests()
model = MOI.Utilities.CachingOptimizer(
MOI.Utilities.Model{Int}(),
MiniZinc.Optimizer{Int}("chuffed"),
MiniZinc.Optimizer{Int}("highs"),
)
config = MOI.Test.Config(Int)
MOI.Test.runtests(model, config, include = String["test_cpsat_"])
Expand Down

0 comments on commit d3fef25

Please sign in to comment.