This function walks the input tree, finds basic blocks to optimize, i.
This function walks the input tree, finds basic blocks to optimize, i.e. matrix product chains that are not interrupted by summations. One example: A*B*C*(D+E)*(F*G) => "basic blocks" are ABC, D, E, and FG
+ it now does "global" optimization - i.e. over optimize over basic blocks. In the above example, we'd treat (D+E) as a temporary matrix T and optimize the whole chain ABCTFG
Not sure if making use of distributivity to generate more variants would be good. In the above example, we could also generate ABCDFG + ABCEFG and have basic blocks: ABCDFG, and ABCEFG. But this would be almost twice as much work with the current cost estimation.
The original prototype that employs the standard O(n^3) dynamic programming procedure to optimize a matrix chain factorization.
The original prototype that employs the standard O(n^3) dynamic programming procedure to optimize a matrix chain factorization.
Now, it also "prefers" more spread out / bushy / less deep factorization which reflects more the Map/Reduce nature.