/************************* ALGORITHMTSP.CPP ***********************************
* TSP Algorithms : AlgorithmTSP                                    21.11.2008 *
*                                                                             *
* TSP Algorithms' base class.                                                 *
*                                                             Beycan Kahraman *
******************************************************************************/

#include "AlgorithmTSP.h"

AlgorithmTSP::AlgorithmTSP(short dist[][SZ], int n)
{
	this->n = n;
	this->dist = new short*[n];
	for(int i=0; i<n; ++i)
	{
		this->dist[i] = new short[n];
		for(int j=0; j<n; ++j)
			this->dist[i][j] = dist[i][j];
	}

	sequence = new int[n];
	for(int i=0; i<n; ++i)
		sequence[i] = i;
	
	random_mersenne = new CRandomMersenne(21112008);
	best_cycle = new int[this->n];
	min_cycle = 32767;
}

void AlgorithmTSP::Run()
{
	duration = clock();
	// Algorithm TSP runs here ...
	duration = clock() - duration;
}

unsigned AlgorithmTSP::GetDuration()
{
	return duration;
}

int AlgorithmTSP::MinCycyle()
{
	return min_cycle;
}

int AlgorithmTSP::BestCycyle(int k)
{
	return best_cycle[k];
}

AlgorithmTSP::~AlgorithmTSP(void)
{
	for(int i=0; i<n; ++i)
		delete dist[i];
	delete dist;
	delete best_cycle;
}
