Optimization algorithm for the creation of quantum entanglement purification (distillation) circuits.