Giter Site home page Giter Site logo

Comments (8)

Nitrogenycs avatar Nitrogenycs commented on September 6, 2024

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.

paolodragone avatar paolodragone commented on September 6, 2024

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.

Nitrogenycs avatar Nitrogenycs commented on September 6, 2024

Thank you for the detailed information. My workaround now is this:

  1. I create the input data file myself with jinja2, still based on enums
  2. 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.

alvarohivery avatar alvarohivery commented on September 6, 2024

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.

paolodragone avatar paolodragone commented on September 6, 2024

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.

alvarohivery avatar alvarohivery commented on September 6, 2024

from pymzn.

shuaiwang88 avatar shuaiwang88 commented on September 6, 2024

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.

paolodragone avatar paolodragone commented on September 6, 2024

Fixed in 0.18.1.

from pymzn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.