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

minizinc: gecode integration broken #383881

Open
3 tasks done
stessaris opened this issue Feb 21, 2025 · 0 comments
Open
3 tasks done

minizinc: gecode integration broken #383881

stessaris opened this issue Feb 21, 2025 · 0 comments
Labels
0.kind: bug Something is broken

Comments

@stessaris
Copy link

Nixpkgs version

  • Stable (24.11)

Describe the bug

Using gecode solver with a model that imports globals.mzn raises several import related warnings, and according to the constraints used might lead to syntactic errors. My feeling is that, when gecode is used, libraries that the system uses are not aligned with their counterparts in minizinc, resulting in clashes among the functions and predicates definitions. The cbc solver doesn't seems to have the same problem.

I'm not familiar enough with minizinc internals to really track down the real issue.

Steps to reproduce

Use gecode solver for a model that requires standard library predicates, e.g.:

% nqueens.mzn

include "globals.mzn";
int: n = 8;
array[1..n] of var 1..n: queens;
constraint all_different(queens);
constraint all_different([queens[i]+i | i in 1..n]);
constraint all_different([queens[i]-i | i in 1..n]);
solve satisfy;

The model can be solved with the minizic distribution downloaded from minizinc.org or their online playground but fails on nixpkgs#minizinc:

❯ nix run nixpkgs#minizinc -- nqueens.mzn --solver gecode
...
Error: type error: no function or predicate with this signature found: `global_cardinality(array[int] of var opt int,array[int] of int,array[int] of var int)'
Cannot use the following functions or predicates with the same identifier:
function array [$Y] of var int : global_cardinality(array [$X] of var $$E: x,array [$Y] of $$E: cover):: promise_total;
    (requires 2 arguments, but 3 given)
function array [$Y] of var int : global_cardinality(array [$X] of var opt $$E: x,array [$Y] of $$E: cover):: promise_total;
    (requires 2 arguments, but 3 given)
predicate global_cardinality(array [int] of var int: x,array [int] of int: cover,array [int] of var int: counts);
    (argument 1 expects type array[int] of var int, but type array[int] of var opt int given)

/nix/store/irhwkcrl1p5741kf5ab1yifdqf24qls6-minizinc-2.8.7/share/minizinc/std/global_cardinality_fn.mzn:20.20-66

Solving with cbc works as expected:

❯ nix run nixpkgs#minizinc -- nqueens.mzn --solver cbc
queens = [3, 7, 2, 8, 5, 1, 4, 6];
----------

Same problem in Linux and OSX

Expected behaviour

gecode should solve the model without errors

Screenshots

No response

Relevant log output

Warning: included file "sum_pred.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "sort.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "roots.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "regular.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "range.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "partition_set.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "nvalue.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "link_set_to_booleans.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "inverse_set.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "inverse.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "int_set_channel.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "global_cardinality_low_up_closed.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "global_cardinality_low_up.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "global_cardinality_closed.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "global_cardinality.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "distribute.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "disjunctive_strict.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "disjoint.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "diffn.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: included file "cumulative.mzn" overrides a global constraint file from the standard library. This is deprecated. For a solver-specific redefinition of a global constraint, override "fzn_<global>.mzn" instead.

Warning: Further warnings have been suppressed.

Error: type error: no function or predicate with this signature found: `global_cardinality(array[int] of var opt int,array[int] of int,array[int] of var int)'
Cannot use the following functions or predicates with the same identifier:
function array [$Y] of var int : global_cardinality(array [$X] of var $$E: x,array [$Y] of $$E: cover):: promise_total;
    (requires 2 arguments, but 3 given)
function array [$Y] of var int : global_cardinality(array [$X] of var opt $$E: x,array [$Y] of $$E: cover):: promise_total;
    (requires 2 arguments, but 3 given)
predicate global_cardinality(array [int] of var int: x,array [int] of int: cover,array [int] of var int: counts);
    (argument 1 expects type array[int] of var int, but type array[int] of var opt int given)

/nix/store/irhwkcrl1p5741kf5ab1yifdqf24qls6-minizinc-2.8.7/share/minizinc/std/global_cardinality_fn.mzn:20.20-66

Additional context

No response

System metadata

  • system: "x86_64-darwin"
  • host os: Darwin 22.6.0, macOS 10.16
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.24.12
  • channels(root): "nixpkgs"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixpkgs

Notify maintainers

@sheenobu


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

@stessaris stessaris added the 0.kind: bug Something is broken label Feb 21, 2025
stessaris added a commit to unibz-ailab/ailab that referenced this issue Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant