oggy22 / MusicTools

Various musical tools including music hearing, machine composer and Chomsky music analyzer.
4 stars 2 forks source link

Speed up the Chomsky algorithm #72

Open oggy22 opened 5 years ago

oggy22 commented 5 years ago

The Chomsky algorithm performance could be improved further by storing swaps found in previous iteration.

Currently, the longest swap is sought in each iteration whilst the rest is dismissed. Instead, at least the second longest swap should be preserved (the first one is already accepted!), checked for validity (it may be invalid if it overlaps with the accepted swap) so in the next iteration it will be longest swap to begin with.

This idea can be advanced by keeping a collection of possible swaps sorted by length and passed through iterations.