pymzn.dzn2dict

pymzn.dzn2dict(dzn, *, rebase_arrays=True, types=None, return_enums=False)

Parses a dzn string or file into a dictionary of variable assignments.

Parameters
  • dzn (str) – A dzn content string or a path to a dzn file.

  • rebase_arrays (bool) – Whether to return arrays as zero-based lists or to return them as dictionaries, preserving the original index-sets.

  • types (dict) – Dictionary of variable types. Types can either be dictionaries, as returned by the minizinc --model-types-only, or strings containing a type in dzn format. If the type is a string, it can either be the name of an enum type or one of the following: bool, int, float, enum, set of <type>, array[<index_sets>] of <type>. The default value for var_types is None, in which case the type of most dzn assignments will be inferred automatically from the value. Enum values can only be parsed if their respective types are available.

  • return_enums (bool) – Whether to return the parsed enum types included in the dzn content.

Returns

A dictionary containing the variable assignments parsed from the input file or string.

Return type

dict