# My ConstraintSolver.jl page

**URL:** <https://discourse.julialang.org/t/my-constraintsolver-jl-page/65430>\
**Category:** Optimization (Mathematical)\
**Created:** [July 28, 2021, 11:42am UTC](https://discourse.julialang.org/t/my-constraintsolver-jl-page/65430 "2021-07-28T11:42:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hakan\_Kjellerstrand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hakan_kjellerstrand/32/8447_2.png) [@Hakan\_Kjellerstrand](https://discourse.julialang.org/u/Hakan_Kjellerstrand)\
**Post date:** [July 28, 2021, 11:42am UTC](https://discourse.julialang.org/t/my-constraintsolver-jl-page/65430/1 "2021-07-28T11:42:14Z")

</div>

One of my (other) Julia-related interests is Ole Kröger’s [Home · ConstraintSolver](https://wikunia.github.io/ConstraintSolver.jl/stable/) .

My ConstraintSolver.jl models are here: [My Julia ConstraintSolver.jl page](http://www.hakank.org/julia/constraints/) , also available at [https://github.com/hakank/hakank/tree/master/julia/constraints](https://github.com/hakank/hakank/tree/master/julia/constraints) .

The page contains about 120 constraint models, such as these mandatory CSP problems:

- N-queens: [http://www.hakank.org/julia/constraints/nqueens.jl](http://www.hakank.org/julia/constraints/nqueens.jl)
- Sudoku: [http://www.hakank.org/julia/constraints/sudoku.jl](http://www.hakank.org/julia/constraints/sudoku.jl) and the instances: [http://www.hakank.org/julia/constraints/sudoku\_problems.jl](http://www.hakank.org/julia/constraints/sudoku_problems.jl)
- SEND+MORE=MONEY: [http://www.hakank.org/julia/constraints/send\_more\_money.jl](http://www.hakank.org/julia/constraints/send_more_money.jl) Generalized in the Alphametic model: [http://www.hakank.org/julia/constraints/alphametic.jl](http://www.hakank.org/julia/constraints/alphametic.jl)
- Zebra puzzle: [http://www.hakank.org/julia/constraints/zebra.jl](http://www.hakank.org/julia/constraints/zebra.jl)
- Magic Squares: [http://www.hakank.org/julia/constraints/magic\_square.jl](http://www.hakank.org/julia/constraints/magic_square.jl)
- Magic Sequence: [http://www.hakank.org/julia/constraints/magic\_sequence.jl](http://www.hakank.org/julia/constraints/magic_sequence.jl)
- Golomb ruler: [http://www.hakank.org/julia/constraints/golomb\_ruler.jl](http://www.hakank.org/julia/constraints/golomb_ruler.jl)
- Scheduling problem: [http://www.hakank.org/julia/constraints/furniture\_moving.jl](http://www.hakank.org/julia/constraints/furniture_moving.jl)
- Minesweeper problem: [http://www.hakank.org/julia/constraints/minesweeper.jl](http://www.hakank.org/julia/constraints/minesweeper.jl)

But also some that’s not very common problems:

- deBruijn sequences (both “classical” and “arbitrary”): [http://www.hakank.org/julia/constraints/debruijn.jl](http://www.hakank.org/julia/constraints/debruijn.jl)
- A Puzzle: [http://www.hakank.org/julia/constraints/a\_puzzle.jl](http://www.hakank.org/julia/constraints/a_puzzle.jl)
- Secret Santa: [http://www.hakank.org/julia/constraints/secret\_santa.jl](http://www.hakank.org/julia/constraints/secret_santa.jl) and Secret Santa 2: [http://www.hakank.org/julia/constraints/secret\_santa2.jl](http://www.hakank.org/julia/constraints/secret_santa2.jl)
- Sicherman Dice: [http://www.hakank.org/julia/constraints/sicherman\_dice.jl](http://www.hakank.org/julia/constraints/sicherman_dice.jl)
- Balanced brackets: [http://www.hakank.org/julia/constraints/balanced\_brackets.jl](http://www.hakank.org/julia/constraints/balanced_brackets.jl)

And here are some of the (decomposition) of global constraints that’s missing in ConstraintsSolver.jl (available in [http://www.hakank.org/julia/constraints/constraints\_utils.jl](http://www.hakank.org/julia/constraints/constraints_utils.jl) ):

- `all_different_except_c`
- `my_element`
- `global_cardinality_count`
- `cumulative`
- `circuit` and `circuit_path`
- `regular`
- `atmost`, `atleast`, and `exactly`
- `global_contiguity_regular`

[I’ve also implemented constraint models in other constraint programming languages/systems, see my “Common constraint programming models” for some examples: [http://www.hakank.org](http://www.hakank.org) /common\_cp\_models/ ]

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [July 28, 2021, 11:56am UTC](https://discourse.julialang.org/t/my-constraintsolver-jl-page/65430/2 "2021-07-28T11:56:38Z")

</div>

Woah! That looks like a lot of work. cc’ing @Wikunia

> I’ve also implemented constraint models in other constraint programming languages/systems

Nice! We have an upcoming talk from the MiniZinc folks at JuMP-dev [https://live.juliacon.org/talk/3BBA7L](https://live.juliacon.org/talk/3BBA7L). Can you compare and contrast the ergonomics of writing models in JuMP and MiniZinc? What could we change/do better?

---

<div class="post-metadata">

**Author:** ![Hakan\_Kjellerstrand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hakan_kjellerstrand/32/8447_2.png) [@Hakan\_Kjellerstrand](https://discourse.julialang.org/u/Hakan_Kjellerstrand)\
**Post date:** [July 28, 2021, 12:17pm UTC](https://discourse.julialang.org/t/my-constraintsolver-jl-page/65430/3 "2021-07-28T12:17:38Z")

</div>

@odow Thanks!

I’m looking forward to hear all your reactions on MiniZinc. It’s a really great constraint modelling language.

Regarding JuMP vs MiniZinc, I can only talk from my experience from ConstraintSolver.jl (which use JuMP) as I haven’t done much “plain” JuMP myself. I know that JuMP is a powerful mathematical programming system but haven’t much detailed knowledge in it.

From a constraint programmer’s perspective, I currently - and in general - prefer MiniZinc (and Picat) over ConstraintSolver.jl, since it supports many global constraints which are not yet implemented in ConstraintSolver, such as `element`, `regular`, `modulo` etc; and my decompositions of these are often not efficient enough. Also MiniZinc support general non linear constraints.

On the other hand, MiniZinc is not a full fledged programming language, so one have to pre-/post process the data to/from the solved model. Having a solver integrated with a language such as julia is much easier to work with. There’s a Python wrapper for MiniZinc ([MiniZinc Python — MiniZinc Python 0.7.0 documentation](https://minizinc-python.readthedocs.io/en/latest/)) but then it’s two different language one have to program in. (Hmm, I realized that I haven’t tested that Python package in Julia; I’ll put that on my TODO list.)

One other aspect is that MiniZinc requires that someone writes a FlatZinc solver. Here I think that JuMP has an advantage since it can use the Julia ecosystem with already existing solver.

I hope I somewhat answered your question.
