Greedy optimizer
EinExprs.Greedy
— TypeGreedy(; metric = removedsize, choose = pop!)
Greedy contraction path solver. Greedily selects contractions that maximize a metric.
Keywords
metric
is a function that evaluates candidate pairwise tensor contractions. Defaults toremovedsize
.choose
is a function that extracts a pairwise tensor contraction between candidates. Defaults to candidate that maximizemetric
usingpop!
.outer
Iftrue
, consider outer products as candidates. Defaults tofalse
.
Implementation
The implementation uses a binary heaptree to sort candidate pairwise tensor contractions. Then recursively,
- Selects and extracts a candidate from the heaptree using the
choose
function. - Updates the
metric
of the candidates which contain neighbouring indices to the one selected. - Append the selected index to the path and go back to step 1.