pymzn.dict2dzn(objs, declare=False, assign=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 in 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 for backward compatibility)
  • assign (bool) – Wheter to include assignment of the value in the statements or just the declaration.
  • 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: