Live data from Hacker News

MiniZinc

minizinc.org

61–70 of 76 posts

Re: MiniZinc

#61

Earlier quoted context omitted.

How can you be sure that your constraint model is correct? When the models are so complex that seems like a real challenge! In your case was it possible to take a proposed solution and verify that it does not have any issues? Are there many other safeguards in place to prevent train collisions or invalid schedules?

Fortunately the colleague who proposed this project was a former train controller with encyclopaedic knowledge of the particular yard and its operations. You find that all of these experienced train controllers can just look at a schedule and instantly tell you if it's viable or not. This was a really important part of development because I had rapid feedback and could prioritise the features that were really importa…

This sounds like an amazing project. Thank you very much for sharing it here. You should be proud! Few people can really point to a project and say "people use this and its a genuine improvement." The world needs more people like you!

Re: MiniZinc

#62
post #53

Whenever MiniZinc, or constraint programming, comes up, I post this link to a programming challenge a friend gave me...14 years ago. I was learning J, and the challenge was me in J, her in javascript or php (she never completed the solution). Here's the link: https://gcanyon.wordpress.com/2009/10/28/a-programming-puzzl... And a person I didn't know posted a solution using MiniZinc. That person happens to also be on H…

Hakan’s examples have illustrated so many constraint programming principles, his site is a wealth of knowledge! For the comments referring to examples more complex than Sudoku, his website is the best that I have found! Thanks Hakan.

Thanks for your kind words.

Re: MiniZinc

#63
MiniZinc is high-level modeling language, before using it I'd suggest taking course https://www.coursera.org/learn/discrete-optimization where you could use/create different solvers.

Only after it makes sense to take https://www.coursera.org/learn/basic-modeling and https://www.coursera.org/learn/advanced-modeling courses.

If you want a quick start read really good tutorial on official website https://www.minizinc.org/doc-2.7.2/en/part_2_tutorial.html and play with examples at online playground https://play.disopt.com/ or locally installing MiniZincIDE.

Re: MiniZinc

#64

I wrote a thesis on using constraint satisfaction with minizinc to solve the genome edit distance problem: https://github.com/jpnelson/genome-edit/blob/master/thesis.p... My takeaway: modeling problems in minizinc correctly is exceptionally difficult for non-trivial problems. You can model it correctly, but you'll likely still need to add additional "constraints" that improve the performance of the solver to the degr…

How is MiniZinc in this aspect compared to Picat or other constraints solving languages?

I find the outputs command of MiniZinc particularly counter-intuitive and hard to use.

Re: MiniZinc

#65

Im sure this is useful but these languages (proof langs, constraints, etc) are always so difficult to parse or read Adoption for these systems might be higher if they had a more readable syntax (and bonus if they could transpile down to source code you can tweak) Also maybe I missed it on mobile, but I would love examples of the syntax and examples of application usage on the first page. Maybe this is useful to me! W…

Yes exactly, we need typescript style solution to get best 80% of ocaml/haskell available to joes kind of thing.

Do you not find this idea somewhat embarrassing?

Why does everything need to look like JavaScript in order for Average Joe programmer to be able to read it?

Re: MiniZinc

#66

I wrote a thesis on using constraint satisfaction with minizinc to solve the genome edit distance problem: https://github.com/jpnelson/genome-edit/blob/master/thesis.p... My takeaway: modeling problems in minizinc correctly is exceptionally difficult for non-trivial problems. You can model it correctly, but you'll likely still need to add additional "constraints" that improve the performance of the solver to the degr…

How is MiniZinc in this aspect compared to Picat or other constraints solving languages? I find the outputs command of MiniZinc particularly counter-intuitive and hard to use.

I really like MiniZinc, especially that one can test a lot of different type of solvers for a problem.

But one of its drawbacks is its limitation of handling input and output (including preprocessing and postprocessing). In some cases - for example when the output is rather simple - I use for example Picat/Python to transform input to MiniZinc format (.dzn format or JSON) and then run MiniZinc.

But for more fancy output I tend to use Picat or Python + (OR-tools CP/SAT or CPMpy or minizinc-python).

That being said, one can do fancier output in MiniZinc, though it requires some work. Here is a model for certain scheduling problems which exemplifies this: http://hakank.org/minizinc/scheduling_with_assignments.mzn . But the output was a little easier to do in Picat: http://hakank.org/picat/scheduling_with_assignments.pi

Re: MiniZinc

#67
How does this kind of constraint modeling compare with logic based approaches like Answer Set Programming (https://potassco.org)? Years ago, I got excited by the possibilities of ASP but it does not seem to have progressed much

Re: MiniZinc

#68

Earlier quoted context omitted.

Yes exactly, we need typescript style solution to get best 80% of ocaml/haskell available to joes kind of thing.

Do you not find this idea somewhat embarrassing? Why does everything need to look like JavaScript in order for Average Joe programmer to be able to read it?

It absolutely doesn’t.

But I can’t use OCaml or Coq at work.

I can use typescript. I can use algebraic data types, well typed functional combinators, exhaustive switch statements (through linter) and other functional design patterns.

I’d like to be able to use formal proofs. If it means dumbed down version that average joe can work with that can gain wider adoption - that’s much better situation to be in than not having anything at all.

There must be more developers in similar situation.

Re: MiniZinc

#69

I used Minizinc to come up with tiling patterns for a patio. I had m 2x2 tiles and n 3x2 tiles and wrote a model to generate patterns that had: * a certain aspect ratio, * rotational symmetry, * no spots where four corners touch, and a few other ad-hoc constraints that I can't remember exactly, to exclude certain sub-patterns.

do you have a pic of the result?

I should have, but wasn't able to find any right now. This is what the pattern looks like, at least: https://imgur.com/a/WpbxDNu

Re: MiniZinc

#70
post #50

I used Minizinc to come up with tiling patterns for a patio. I had m 2x2 tiles and n 3x2 tiles and wrote a model to generate patterns that had: * a certain aspect ratio, * rotational symmetry, * no spots where four corners touch, and a few other ad-hoc constraints that I can't remember exactly, to exclude certain sub-patterns.

That sounds super cool! I'm at the very early planning (read: daydreaming ;) stage for a tiling project of my own, (where my "constraints" are "has to be nerdy-awesome"). Like find a specific conway's game of life still life, or perhaps use the newly discovered aperiodic "hat" tileing. Any chance you would be willing to dump your notes somewhere I can see?

I used a pretty straightforward formulation, with a binary decision variable for each possible tile placement/orientation, and constraints to ensure that the pattern is possible to build: uses correct number of tiles of each type, no overlap ("if there's a 2x2 tile at (x,y), there is no 2x2 tile at (x,y+1)").

Another approach to the constraints could be to define the set of covered subsquares for each placement, and have a single constraint that says that each subsquare must be covered exactly once.

It was a pretty small patio (about 2 by 3 meters), with 17 square tiles and 12 rectangle tiles, and this formulation worked well enough to find all solutions to that in reasonable time. However, you get a lot of minor variations on the same general pattern. On this small scale just quickly scrolling these variations was manageable, but with a larger project you'd have to do something more intelligent.

Post reply on HN