Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to [email protected] #74

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"),
odow marked this conversation as resolved.
Show resolved Hide resolved
)
config = MOI.Test.Config(Int)
MOI.Test.runtests(model, config, include = String["test_cpsat_"])
Expand Down
Loading