#include "ProblemDomain.h"
#include <limits>

const FloatType ProblemDomain::POSITIVE_INFINITY = std::numeric_limits<FloatType>::infinity();
const FloatType ProblemDomain::NEGATIVE_INFINITY = -std::numeric_limits<FloatType>::infinity();

ProblemDomain::ProblemDomain() : numberOfGenes( 0 ), numberOfAlleles( NULL ) { /* Empty */ }

ProblemDomain::~ProblemDomain() {
  if ( numberOfAlleles )
    delete[] numberOfAlleles;
}

void ProblemDomain::setInitialBias( IprocessConvergedAllele *pca ) {
  return; // By default, do nothing.
}

ProblemDomain::TournamentReturn ProblemDomain::tournament( const AlleleType *individualLeft, const AlleleType *individualRight ) const {
  FloatType fitnessLeft = getFitness( individualLeft );
  FloatType fitnessRight = getFitness( individualRight );
  if ( fitnessLeft < fitnessRight )
    return TournamentReturn( TournamentReturn::RIGHT, fitnessRight );
  else if ( fitnessLeft > fitnessRight )
    return TournamentReturn( TournamentReturn::LEFT, fitnessLeft );
  else
    return TournamentReturn( TournamentReturn::TIE, fitnessLeft );
}

unsigned int ProblemDomain::getNumberOfGenes() const {
  return numberOfGenes;
}

const AlleleType * ProblemDomain::getNumberOfAlleles() const {
  return numberOfAlleles;
}
