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::AST::TypeError with chuffed and output_vars #20

Closed
HelgeS opened this issue Mar 13, 2018 · 2 comments
Closed

FlatZinc::AST::TypeError with chuffed and output_vars #20

HelgeS opened this issue Mar 13, 2018 · 2 comments

Comments

@HelgeS
Copy link
Contributor

HelgeS commented Mar 13, 2018

When generating a MiniZinc model with output variables, pymzn adds output annotations, such as output_array([1..52]). When using Chuffed as a solver, this leads to an error FlatZinc::AST::TypeError.

Example

Using the attached files, running chuffed fails, while mzn-gecode works:

$ mzn-chuffed pymzn_lo34fh_5.mzn pymzn_lo34fh_5.dzn
terminate called after throwing an instance of 'FlatZinc::AST::TypeError'

The error is issued by the annotations in lines 5-6 in the mzn file:

array[1..52] of var 1..52: x :: output_array([1..52]);
array[1..52] of var 1..52: y :: output_array([1..52]);

In pymzn, they are added in _redefine_output_vars in model.py.

pymzn was invoked via:
pymzn.minizinc('black-hole.mzn' , data={'layout': [[10, 11, 12], [30, 7, 4], [20, 36, 22], [37, 18, 9], [33, 19, 29], [26, 2, 51], [31, 44, 25], [50, 52, 43], [38, 48, 41], [27, 49, 42], [34, 3, 46], [5, 47, 24], [28, 21, 16], [45, 14, 15], [32, 23, 40], [39, 6, 35], [8, 17, 13]]}, all_solutions=False, solver=pymzn.chuffed, output_vars=['x', 'y'], output_mode='dict', force_flatten=True, keep=False)

force_flatten=True is not relevant for the problem, but a workaround for this issue.

I'm not entirely sure in which cases the output annotations might be necessary. For now, I've removed the call to this method locally, but that's only a workaround.

pymzn_lo34fh_5.dzn.txt
pymzn_lo34fh_5.mzn.txt
black-hole.mzn.txt

@paolodragone
Copy link
Owner

I don't recall exactly in which case the output annotations were needed, probably when using some old version of MiniZinc in some very particular case, such as when you have no optimization variables but you want to compute a function of the input using solve satisfy.
I will add the option to avoid using output annotations when compiling the model.

@paolodragone
Copy link
Owner

Solved in version 0.16.9.
You can now add the option no_output_annotations=True to the function pymzn.minizinc to disallow output annotation when compiling the model.

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