Performs memory-optimized run

Performs a memory-optimized run. Memory-optimized runs are for calculating specified nodes (targets) by consuming less memory. Memory-optimized runs are useful when the intermediate results contain large data.

A memory-optimized run actually involves two runs. The first run is invoked by calling generate_actions() and the second run is performed by calling execute_actions(). The generate_actions() method runs the model to generate and return a list of actions from a list of targets passed to the targets parameter. The user should set a small data set in the model before calling generate_actions(). The elements of targets should be ItemNode objects representing combinations of a Cells object and its arguments. Node objects can be created by passing the arguments to node() method. For example, the expression below creates a node object representing Model1.Space1.Cells3(x=2):


generate_actions() runs the model to analyze the dependency of the target nodes. generate_actions() identifies all the calculated nodes that the target nodes depend on, and sort the nodes in a topological order. Then the ordered nodes are split into groups so that each group has at most the number of nodes specified by step_size (1000 by default). Then generate_actions() generates actions to process each group. For each group, calc, paste, and clear actions are generated in this order. Each action is associted with nodes that the action applies to. A calc action indicates its associated nodes should be calculated. A paste action indicates its associted nodes should be value-pasted so that the values of the nodes persist after their precedents are cleared. A clear action indicates its associated nodes should be cleared to save memory.

generate_actions() returns a list of actions. Each action is also represented by a list, whose first element is a string, which is either 'calc', 'paste', or 'clear'. The string indicates the type of action to perform. The second element is a list of ItemNode, to which the action indicated by the first element apply. Below is an example of the action list.

    ['calc', [Model1.Space1.Cells1(), Model1.Space1.Cells2(x=0)]],
    ['paste', [Model1.Space1.Cells2(x=0), Model1.Space1.Cells1()]],
    ['clear', []],
    ['calc', [Model1.Space1.Cells2(x=1), Model1.Space1.Cells2(x=2)]],
    ['paste', [Model1.Space1.Cells2(x=2)]],
    ['clear', [Model1.Space1.Cells2(x=1), Model1.Space1.Cells2(x=0)]],
    ['calc', [Model1.Space1.Cells3(x=2)]],
    ['paste', [Model1.Space1.Cells3(x=2)]],
    ['clear', [Model1.Space1.Cells1(), Model1.Space1.Cells2(x=2)]]

execute_actions() executes actions passed as actions. Before calling execute_actions(), the user should set the entire data set instead of the small data set used for generating the actions. After the execusion, the target nodes are value-pasted, and the values of precedent nodes of the target nodes are all cleared. To clear the values call clear_at() for the targets or call Cells.clear_all or Space.clear_all or Model.clear_all.


actions (list) – The actions list