Model.execute_actions#
- Model.execute_actions(actions)[source]#
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 callingexecute_actions(). Thegenerate_actions()method runs the model to generate and return a list of actions from a list of targets passed to thetargetsparameter. The user should set a small data set in the model before callinggenerate_actions(). The elements oftargetsshould beItemNodeobjects representing combinations of aCellsobject and its arguments. Node objects can be created by passing the arguments tonode()method. For example, the expression below creates a node object representingModel1.Space1.Cells3(x=2):Model1.Space1.Cells3.node(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 bystep_size(1000 by default). Thengenerate_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 ofItemNode, 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 asactions. Before callingexecute_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 callclear_at()for the targets or callCells.clear_allorSpace.clear_allorModel.clear_all.- Parameters:
actions (
list) – The actions list
See also