||Get the value of a configuration variable.|
||Set the value of configuration variable.|
||Writes the changes to the configuration file.|
PyMzn can be configured with custom executable paths and other variables.
To inspect the current value of a variable one can use the PyMzn executable, if installed:
$ pymzn config mzn2fzn
$ python3.5 -m pymzn config mzn2fzn
Similarly, to configure a variable:
$ pymzn config mzn2fzn /path/to/mzn2fzn
$ python3.5 -m pymzn config mzn2fzn /path/to/mzn2fzn
The configuration of PyMzn is contained into a configuration file located in the home directory of the current user. The exact path of the configuration file is dependent on the operating system:
- Linux: ~/.local/share/pymzn/config.yml
- MacOS: ~/Library/Application Support/pymzn/config.yml
- Windows: %APPDATA%Localpymznconfig.yml
This is a YAML configuration file, which can be also manually modified.
PyMzn can also be configured programmatically using the module
import pymzn.config # config.set sets the variable only for the current execution pymzn.config.set('mzn2fzn', 'path/to/mzn2fzn') pymzn.config.set('solns2out', 'path/to/solns2out') # to make the changes persistent pymzn.dump()
The configurable properties used by PyMzn are the following:
- mzn2fzn: Path to the mzn2fzn executable;
- solns2out: Path to the solns2out executable;
- dzn_width: The horizontal character limit for dzn files; This property is used to wrap long dzn statements when writing dzn files. This property is also used in the
pymzn.minizincfunction as a limit to decide whether to write the inline data into a file.
One can also configure custom properties to be used for custom solvers.
PyMzn can also be set to print debugging messages on standard output via:
This function is meant to be used in interactive sessions or in
applications that do not configure the
logging library. If you configure the
logging library in your application, then PyMzn will print logging messages
as well. The logging level in PyMzn is always
DEBUG. To disable debugging
messages you can then call: