pymzn.dict2dzn(objs, declare=False, assign=True, declare_enums=True, wrap=True, fout=None)

Serializes the objects in input and produces a list of strings encoding them into dzn format. Optionally, the produced dzn is written on a file.

Supported types of objects include: str, int, float, set, list or dict. List and dict are serialized into dzn (multi-dimensional) arrays. The key-set of a dict is used as index-set of dzn arrays. The index-set of a list is implicitly set to 1 .. len(list).

  • objs (dict) – A dictionary containing the objects to serialize, the keys are the names of the variables.

  • declare (bool) – Whether to include the declaration of the variable in the statements or just the assignment. Default is False.

  • assign (bool) – Whether to include assignment of the value in the statements or just the declaration.

  • declare_enums (bool) – Whether to declare the enums found as types of the objects to serialize. Default is True.

  • wrap (bool) – Whether to wrap the serialized values.

  • fout (str) – Path to the output file, if None no output file is written.


List of strings containing the dzn-encoded objects.

Return type