Esempio n. 1
0
//TODO default to HAMMING
//Note: it returns the distance that is not normalised
float Permutation::distance(const Permutation &permCompare, const distanceMetric_t &type) const
{
  float score=0;

  //cout << "*****Permutation::distance" <<endl;
  //cout << "Ref:" << endl;
  //dump();
  //cout << "Comp:" << endl;
  //permCompare.dump();

  if (type == HAMMING_DISTANCE) {
    score = calculateHamming(permCompare);
  } else if (type == KENDALL_DISTANCE) {
    score = calculateKendall(permCompare);
  } else {
    throw runtime_error("Distance type not valid");
  }

  float brevityPenalty = 1.0 - (float) permCompare.getTargetLength()/getTargetLength()  ;//reflength divided by trans length
  if (brevityPenalty < 0.0) {
    score = score * exp(brevityPenalty);
  }

  //cout << "Distance type:" <<  type << endl;
  //cout << "Score: "<< score << endl;
  return score;
}