Solver Configuration File

189 views
Skip to first unread message

max.os...@potassco.com

unread,
Mar 30, 2021, 6:11:29 AM3/30/21
to MiniZinc

Hi,
I'm trying to create a solver configuration file for my flatzingo solver,
such that deployment will be easier in the future.

Flatzingo uses solver specific predicates.
Currently, the call
minizinc -c --output-fzn-to-stdout -G ../../../../myshared/flatzingo problem.mzn
works just fine to use these specific predicates (all in the specified directory, given relative to the minizinc installation share folder) in the translation process.

Now I created a flatzingo.msc json format file in the directory $HOME/.minizinc/solvers/

{
  "id": "org.potassco.flatzingo",
  "name": "Flatzingo",
  "description": "Flatzingo FlatZinc executable",
  "version": "1.6.0",
  "mznlib": "../flatzingo",
  "executable": "fzn-flatzingo.sh",
  "tags": ["cp","lcg","int"],
  "stdFlags": ["-a","-f","-n","-r","-s","-t","-v"],
  "supportsMzn": false,
  "supportsFzn": true,
  "needsSolns2Out": true,
  "needsMznExecutable": false,
  "needsStdlibDir": false,
  "isGUIApplication": false
}

I can now call:
minizinc --solver flatzingo -c --output-fzn-to-stdout --verbose-compilation --compiler-statistics
and it does something. Unfortunately, as seen in the verbose output, it does not use any predicate redefinition files in the
$HOME/.minizinc/flatzingo/
directory.
I copied all my redefinitions.mzn and other fzn_*.mzn files to this directory.
It should be "relative to solver configuration file by the given path "../flatzingo" and minizinc also seems to check for the existence of this directory (if I change the mznlib to something else I do get an error that the directory does not exist).
Still, the verbose output shows that minizinc only processes files in the folder:
"/someinstalldir/MiniZincIDE-2.4.3-bundle-linux-x86_64/share/minizinc/std//".

Currently using MiniZincIDE-2.4.3 on Linux (Fedora). Any idea of what I could be doing wrong and how this relative mznlib path works ?
Everything else works, just not the specific redefinitions.
Thanks a lot,
Max

max.os...@potassco.com

unread,
Mar 30, 2021, 6:33:22 AM3/30/21
to MiniZinc
If I use an absolute path name instead, it works fine:

"mznlib": "/home/myname/.minizinc/flatzingo",

Why doesnt it work with the relative path.

Jip J. Dekker

unread,
Mar 30, 2021, 6:37:35 AM3/30/21
to mini...@googlegroups.com
Hi Max,

It might be worthwhile to try the newest version of MiniZinc (2.5.5). I’m not a 100% sure if this was an issue we solved, but it does sound familiar.

Cheers,
Jip

-- 
You received this message because you are subscribed to the Google Groups "MiniZinc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minizinc+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/minizinc/50e2cecc-17b1-42bc-b27e-dd0d456b0fc7n%40googlegroups.com.

signature.asc

max.os...@potassco.com

unread,
Mar 30, 2021, 6:51:12 AM3/30/21
to MiniZinc
Thanks a lot.
which does not seem to have an "installation" option for the command line, so no MZN_SOLVER_PATH or anything is set, but I can still call the command line minizinc executable.
Unfortunately, the problem still persists.
Is there anything else I can try to help you find the problem ?
Best,
Max

Cyderize

unread,
Mar 30, 2021, 7:21:52 PM3/30/21
to MiniZinc
Is there a chance that there's a directory called 'flatzingo' above the current working directory where you're running minizinc? I think there's an issue at the moment where file paths are first resolved relative to the current working directory, and only if they do not exist are they resolved relative to the .msc file. Other than that I'm not sure why a relative path wouldn't work.

Thank you,
Jason

max.os...@potassco.com

unread,
Mar 31, 2021, 3:59:38 AM3/31/21
to MiniZinc
Wow, you are awesome. My working directory was of course called "flatzingo", and as my relative path was "../flatzingo" this is also a valid directory relative to my working directory (the working directory itself :D ).
So it would be great if this (don't know how or if it is intended) could be fixed, but now I have something to work with. Thanks a lot.

max.os...@potassco.com

unread,
Mar 31, 2021, 4:31:42 AM3/31/21
to MiniZinc
As it is quite common to have the project name the same in both places I wonder if there is a recommended layout for the ~/.minizinc folder?
Currently I have:
~./minizinc/solvers/flatzingo.msc
and
~/.minizinc/share/flatzingo/*.mzn for the redefinition (introducing the additional share subfolder avoided the problem for me)

The relative path in flatzingo.msc is now:
"mznlib": "../share/flatzingo",

guido.tack

unread,
Mar 31, 2021, 6:35:01 PM3/31/21
to MiniZinc
Hi,

The .minizinc directory isn't really meant as a place to install solvers (it works, but at least it's not how we intended it to be used). The usual way to install a solver would depend on the operating system. But in general the file system structure would be $PREFIX/bin for the binary, $PREFIX/share/minizinc/solvers/$SOLVERNAME.msc for the .msc file, and $PREFIX/share/minizinc/$SOLVERNAME/ for the MiniZinc library directory. So your mznlib entry would be ../$SOLVERNAME. Obviously that can cause problems due to the current bug if ../$SOLVERNAME can be resolved from the current working directory, but we'll fix that for the next release.

The $PREFIX would depend on the OS. For a global installation on Linux and macOS it would probably be /usr/local (or /usr on Linux), whereas on Windows it would probably be the program files directory. To install just for the current user, I'm not sure about the usual recommendations for the different platforms, but I'd suggest following the same directory structure.

To then make the solver available to MiniZinc, you can add an entry to .minizinc/Preferences.json of the form

"mzn_solver_path" : [$PREFIX/share/minizinc/solvers]

We will add functionality to the IDE to make editing the mzn_solver_path easier, and document this properly for the next release.

Cheers,
Guido

max.os...@potassco.com

unread,
Apr 1, 2021, 6:21:37 AM4/1/21
to MiniZinc
Thanks a lot, once the new version is available I'll change the directory structure for my solver.
Furthermore it would be awesome to have a way to install the solver locally (without need to have admin priviledges to access /usr/local) and without using the IDE.

Thanks a lot for your help and all the fast answers.
Best,
Max

Jip J. Dekker

unread,
Apr 1, 2021, 10:06:30 PM4/1/21
to mini...@googlegroups.com
Hi Max,

You are still able to install solvers in places other than the standard PREFIX for the system by extending MZN_SOLVER_PATH environmental variable with “LOCAL_PREFIX/share/minizinc/solvers”. The only difference between these custom paths and system paths like “/usr” and “/usr/local” is that you have to add them to MZN_SOLVER_PATH since they are not standardised.

Cheers,
Jip


signature.asc

guido.tack

unread,
Apr 6, 2021, 7:16:46 PM4/6/21
to MiniZinc
You don't even have to set an environment variable, as I mentioned earlier you can add a solver to the MiniZinc search path using the  .minizinc/Preferences.json file. The only thing we'll change in the next release is to add functionality to the IDE for editing that path, but you can already do it by hand.

Cheers,
Guido

max.os...@potassco.com

unread,
Apr 7, 2021, 3:43:14 AM4/7/21
to MiniZinc
About that ".minizinc/Preferences.json" file. How can I generically find it. How is this file generated?
I would like to write an installer for my solver, that installs it locally, ready to be used with minizinc.
But currently I can't find a way to "install" minizinc.
I (on Linux) currently just download the linux bundle and execute the command line minizinc from there. Everything works fine. I can move these binaries and stuff to any directory that is in my PATH etc... .
But I have not found a way to "install" minizinc, which adds an environment variable for me to look up where to find it or creates the .minizinc folder in some default location. Nor is there a default directory where I would find minizinc. (Then I could also find the Preferences.json file).

What is the common way to install minizinc.

guido.tack

unread,
Apr 7, 2021, 5:17:07 AM4/7/21
to MiniZinc
That file would most likely be generated by the IDE, but you can also create it yourself if it isn't there yet. To find out the appropriate paths that MiniZinc will use, you can call minizinc with the --config-dirs option, which will output something like this (this is for my own installation):

{
  "globalConfigFile" : "/Applications/MiniZincIDE.app/Contents/Resources/share/minizinc/Preferences.json",
  "userConfigFile" : "/Users/tack/.minizinc/Preferences.json",
  "userSolverConfigDir" : "/Users/tack/.minizinc/solvers",
  "mznStdlibDir" : "/Applications/MiniZincIDE.app/Contents/Resources/share/minizinc"
}

You could parse this (it's JSON) and then install your solver accordingly.

Cheers,
Guido

max.os...@potassco.com

unread,
Apr 7, 2021, 5:36:29 AM4/7/21
to MiniZinc
This actually helps a lot thanks. Also the file/folder information is already in the correct OS specific format. Awesome.
Reply all
Reply to author
Forward
0 new messages