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

FlatZinc interface: Missing output #9

Open
Dekker1 opened this issue Jun 18, 2022 · 5 comments
Open

FlatZinc interface: Missing output #9

Dekker1 opened this issue Jun 18, 2022 · 5 comments

Comments

@Dekker1
Copy link

Dekker1 commented Jun 18, 2022

I'm trying to use the FlatZinc solver according to the instructions in fz/README. I've compiled mistral-fzn using make, and the binary seems to work. Both -h and --version give the correct output, both using mistral-fzn and mistral-fz.

However, when I run mistral on an actual FlatZinc file, I'm not getting any results.
I'm using a simple model:

include "all_different.mzn";
array[1..4] of var 1..4: x;
constraint all_different(x);
solve maximize sum(x);

which flattens down to:

array [1..2] of int: X_INTRODUCED_5_ = [1,-1];
var 1..4: X_INTRODUCED_0_;
var 1..4: X_INTRODUCED_1_;
var 1..4: X_INTRODUCED_2_;
var 1..4: X_INTRODUCED_3_;
var 4..16: X_INTRODUCED_4_:: is_defined_var;
array [1..4] of var int: x:: output_array([1..4]) = [X_INTRODUCED_0_,X_INTRODUCED_1_,X_INTRODUCED_2_,X_INTRODUCED_3_];
constraint int_lin_ne(X_INTRODUCED_5_,[X_INTRODUCED_0_,X_INTRODUCED_1_],0);
constraint int_lin_ne(X_INTRODUCED_5_,[X_INTRODUCED_0_,X_INTRODUCED_2_],0);
constraint int_lin_ne(X_INTRODUCED_5_,[X_INTRODUCED_0_,X_INTRODUCED_3_],0);
constraint int_lin_ne(X_INTRODUCED_5_,[X_INTRODUCED_1_,X_INTRODUCED_2_],0);
constraint int_lin_ne(X_INTRODUCED_5_,[X_INTRODUCED_1_,X_INTRODUCED_3_],0);
constraint int_lin_ne(X_INTRODUCED_5_,[X_INTRODUCED_2_,X_INTRODUCED_3_],0);
constraint int_lin_eq([1,1,1,1,-1],[X_INTRODUCED_0_,X_INTRODUCED_1_,X_INTRODUCED_2_,X_INTRODUCED_3_,X_INTRODUCED_4_],0):: ctx_pos:: defines_var(X_INTRODUCED_4_);
solve  maximize X_INTRODUCED_4_;

Running ./mistral-fz test.fzn does not give any output.

Directly running ./mistral-fzn test.fzn does give output, but does not seem to output any results:

 d PARSETIME 0
 c Maximize r10
 c +===========================================+
 c |       17         182        0 |        10 | 
 c +===========================================+

Did I do anything wrong? Am I missing some step in mistral's compilation?

@siala
Copy link
Collaborator

siala commented Jun 18, 2022

Hi,

If you use g++, you have to use version 5. There is no problem if you use clang. To make it work, you should replace g++ by g++-5 in /Makefile /template.mk and fz/template.mk.

By the way, the documentation is not up to date. You can, however, follow the basic steps in the README file in fz/.

Also, the solver is well installed in docker following the Minizinc docker image.

Let me know how it goes.

@Dekker1
Copy link
Author

Dekker1 commented Jun 18, 2022

Thank you for the quick response. I am compiling with clang 13.0.1 (the current version distributed with macOS 12.4) on an M1 Mac, so I'm not sure if this is just an issue with older versions of GCC. I can see the docker image, but would still like to be able to just use it on my own machine (directly). It makes trying different solvers a lot easier.

(I'm also trying to make my efforts reproducible so other Homebrew users can easily install many open MiniZinc solvers: Dekker1/homebrew-minizinc#17)

@siala
Copy link
Collaborator

siala commented Jun 21, 2022

Hi,
Could you please try now?

Also, can I ask you why didn't you use the mzn lib to flatten with all diff?

@Dekker1
Copy link
Author

Dekker1 commented Jun 22, 2022

The test now seems to pass locally again on my machine, but does not pass on the Ubuntu CI. Would this now be the GCC issue that you spoke of, or was that the one you resolved.


Regarding the MiniZinc library. I did actually use the library, but it overrides all_different_int. A user predicate that is no longer in general use in MiniZinc. When writing all_different, the MiniZinc library rewrites it into the solver level fzn_all_different_int: https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/std/all_different.mzn#L11-L13

A few years ago the MiniZinc library was restructured to have a clear separation between the library managed by the MiniZinc project, and the solvers. This ensures that certain guarantees can be given to the solver predicates, and more rewriting and checks can be done in the general MiniZinc library without the need to copy it into each solver library.

Generally the idea is thus that solvers should only override fzn_* globals and predicates noted in the FlatZinc builtins.

@Dekker1
Copy link
Author

Dekker1 commented Jun 22, 2022

To add details, the Ubuntu CI machine is not receiving any output when running mistral-fz:

/home/linuxbrew/.linuxbrew/Cellar/mistral/2022-06-21/bin/mistral-fz test.fzn
[72](https://github.com/Dekker1/homebrew-minizinc/runs/6995303694?check_suite_focus=true#step:8:74)
  Error: dekker1/minizinc/mistral: failed
[73](https://github.com/Dekker1/homebrew-minizinc/runs/6995303694?check_suite_focus=true#step:8:75)
  An exception occurred within a child process:
[74](https://github.com/Dekker1/homebrew-minizinc/runs/6995303694?check_suite_focus=true#step:8:76)
    Minitest::Assertion: Expected /\-\-\-\-\-\-\-\-\-\-/ to match ""

https://github.com/Dekker1/homebrew-minizinc/runs/6995303694

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants