Comments (8)
The reverse process dzn2dict also seems to have problems with this.
Output of solver:
slots = [{Slot1_20180602, Slot2_20180602}]
Output I get from solutions in python:
{'slots': [20180602, 20180602]}
That is, it just seems to drop everything that doesn't look numeric.
from pymzn.
Yeah, the enums are still not supported by PyMzn unfortunately.
They are a bit of a mess to convert to python so I've never actually got into them.
The standard workaround is of course with to map the enum to an array of integers, which you then convert back in the python code when you get the result.
I was actually planning to add support for them, but I decided to wait for the release of MiniZinc 2.2.0 before adding any new major feature.
I'll keep this issue open as a reminder!
from pymzn.
Thank you for the detailed information. My workaround now is this:
- I create the input data file myself with jinja2, still based on enums
- To get the enums in the result I return the results as "json" instead of "dict". This will return only the integer values and no enums.
from pymzn.
Hi Paolo,
Thanks for the tool is been really helpful. Is this still an open issue? experiencing the same problem as Nitrogenics, and wondering if there is any feasible workaround yet.
Cheers!
from pymzn.
Hi alvarohivery, yes, this is still an issue unfortunately, I'm planning to give a round of big improvements like this once the MiniZinc 2.2.0 becomes a bit more stable.
The workaround is simply to use integer variables or arrays to encode enum values. In the python code then you'll have the resulting integers mapped to whatever you want.
Hope this helps
from pymzn.
from pymzn.
Hi Paolo,
I was trying to duplicate the minizinc example.
I got the same error for profit, capacity, and consumption similar to this "expected array[Products] of int', actual
array[int] of int'" .
Do we have any work around here?
Products = {ChocolateCake, BananaCake};
profit = array1d(1..2, [400, 450]);
Resources = {Butter, Banana, Flour, Sugar, Cocoa};
capacity = array1d(1..5, [4000, 6, 2000, 500, 500]);
consumption = array2d(1..2, 1..5, [250.0, 75.0, 0.0, 0.0, 150.0, 2.0, 100.0, 200.0,
150.0, 75.0]);
from pymzn.
Fixed in 0.18.1.
from pymzn.
Related Issues (20)
- Model Flattening generates no fzn and ozn file HOT 7
- Can you please cut a new release? Current pip version isn't compatible with 3.7 HOT 1
- Is there any way to set flattener two-pass options? HOT 4
- Incorrect preprocessing of `.mzn` files, instead of `.pmzn` files HOT 3
- pymzn.minizinc timeout leads to type error HOT 1
- Output error: expecting end of file HOT 2
- Added output fails on enum type. HOT 3
- parallel argument leads to type error HOT 1
- Cannot import templates HOT 1
- Lists containing empty sets are not translated correctly to dzn. HOT 1
- What's the correct sequence of dict2dzn HOT 2
- Returning "INCOMPLETE" instead a "ERROR" HOT 6
- ValueError is raised with pymzn but working with MinizincIDE HOT 4
- Add an option to obtain the minizinc stats HOT 1
- async mod with windows 10
- Question: output of objective value using gurobi solver with pymzn.minizinc() function HOT 3
- pymzn doesnt work with minizinc 2.5.0 HOT 3
- FileNotFoundError: [Errno 2] No such file or directory: 'mzn2fzn': 'mzn2fzn' HOT 1
- An issue when using pymzn with gurobi solver
- i cant enable the addon
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymzn.