modelx v0.8.0 (6 July 2020)

This release introduces new methods to copy Spaces and Cells, functions and methods to save models to zip files, and a feature to output input values to a log file.

Enhancements

Introduction of copy methods

The UserSpace.copy and Cells.copy methods are introduced.

Writing/reading models to/from zip files (GH33)

The new zip_model() function and Model.zip method work exactly the same as write_model() and Model.write, except that they write a model into a zip file. The contents of the zip file is identical to the contents of a folder output by write_model() or Model.write, i.e. unzipping the zip file produces the same files and folders as the folders and files output by write_model() or Model.write.

Input value logging (GH32)

When writing a model, input values in Cells are stored in a binary file with their object IDs. The object IDs change every time the same model is written, even though the input values themselves have not changed. So it is not possible to know whether the input values have changed or not just by looking at the output files. To compensate for this limitation, a feature to output the string representations of Cells input keys values is introduced, as a parameter of the write and zip methods and functions.

write_model(), Model.write, the new zip_model() function and Model.zip method now have a parameter log_input. If True is given, the string representations of Cells input keys and values are output in a file named _input_log.txt under the model folder.

The sample code below writes a model into a model folder and output _input_log.txt under the model folder.

import modelx as mx

m = mx.new_model()

@mx.defcells
def foo(x):
    return x

foo[0] = 1
foo[1] = "foo"

m.write("model", log_input=True)

Below is the contents of _input_log.txt under the model folder:

Space1.foo(x=0)=1
Space1.foo(x=1)='foo'