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

What's the correct sequence of dict2dzn #42

Closed
shuaiwang88 opened this issue Aug 30, 2019 · 2 comments
Closed

What's the correct sequence of dict2dzn #42

shuaiwang88 opened this issue Aug 30, 2019 · 2 comments

Comments

@shuaiwang88
Copy link

shuaiwang88 commented Aug 30, 2019

Why the output sequence does not match the original input?

import pymzn

a_string = {'e1', 'e2', 'e3', 'e4'}

pymzn.dict2dzn({'out':a_string}, fout="test.dzn")

##out = {e2, e4, e3, e1};

I am not sure the index of the paramter is valid or not.

@paolodragone
Copy link
Owner

Hi @shuaiwang88
That's because {'e1', 'e2', 'e3', 'e4'} is a set (both in Python and MiniZinc). Sets are unordered data structures so the order of iteration is not guaranteed.
If you need the to keep the order you need to use Python lists, which are converted into minizinc arrays.
Does this help?

@shuaiwang88
Copy link
Author

shuaiwang88 commented Aug 30, 2019

@paolodragone I am looping over the a_string as index domain to simulate a parameter in array. This could effect the sequence of the parameter since the set is not order while the array is ordered.

I will try the list form. Thanks!

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