brocksam / pycollo

General-purpose optimal control, trajectory optimisation and parameter optimisation using direct collocation
https://brocksam.github.io/pycollo/
MIT License
8 stars 3 forks source link

Expression graph recursion bug fix #13

Closed brocksam closed 4 years ago

brocksam commented 4 years ago

Fixes a bug that caused Python's maximum recursion depth to be exceeded. During expression graph creation, if a non-root node was created without an associated equation/expression then it would be cached with these attributes set to None. Upon attempting to supply an equation for the already instantiated node from the problem's auxiliary data two bugs were encountered:

  1. The already instantiated intermediate node could not be accessed from the cache by its Pycollo symbol; and
  2. The already instantiated intermediate node's equation/expression attributes were not checked for None and thus were not updated. (1.) has been fixed in the ExpressionGraph class by first passing a symbol through the Pycollo-symbols-to-user-symbols-mapping during expression branch traversal. (2.) has been fixed by amending the Cached metaclass in the node module to check for is not None during the object dunder call.