Please refer to [Madhusudhan et al., 2006] for a full description of the variable gap penalty dynamic programming algorithm.