sympy/sympy — pull request #1761 by mrocklin (2013-02-07 19:37:02+00:00)
Title: Treesearch

Two searching strategies.

`minimize` - tries several functions and returns the answer that minimizes an objective function

`treesearch` - composes `minimize` and `chain` to execute trees of functions. This enables expressions of the form

"Try either `factor` then `simplify` or try `expand` then `foosimp`"

into expressions of the form

([factor, simplify], [expand, foosimp])

You then specify an objective function like `lambda x: x.count_ops()` and treesimp will produce a function that tries the various branches of the tree greedily.