#include<iostream>
#include<stdlib.h>
#include<time.h>
#include"models.h"
#include"methods.h"

int main(){
	time_t start = time(nullptr);
	srand(1);//time(NULL));
	/*
	Data Exp1("Experience1");
	Exp1.randSet(100,1,1.);
	LinearApprox Lin1(Exp1);
	//std::cout << Exp1.getName() << " " << Lin1.getExpData().getName() << std::endl;
	//Exp1.displayData();
	//Lin1.getExpData().displayData();
	Model* Mod1 = new LinearApprox(Lin1);
	//std::cout << Mod1->getCost() << std::endl;
	//Lin1.exportModel();
	//Mod1->exportModel();
	SimulatedAnnealing Opti1(Mod1);
	Opti1.initialise();
	Opti1.execute();
	Opti1.finalise();
	free(Mod1);


	Data Exp2("Experience2");
	Exp2.randSet(100,2,5.);
	PolynomialApprox Pol2(Exp2,2);
	//std::cout << Exp2.getName() << " " << Pol2.getExpData().getName() << std::endl;
	//Exp2.displayData();
	//Pol2.getExpData().displayData();
	Model* Mod2 = new PolynomialApprox(Pol2);
	//std::cout << Mod2->getCost() << std::endl;
	//Pol2.exportModel();
	//Mod2->exportModel();
	SimulatedAnnealing Opti2(Mod2);
	Opti2.initialise();
	Opti2.execute();
	Opti2.finalise();
	free(Mod2);


	Data Exp3("Experience3");
	Exp3.randSet(50,4,150.);
	PolynomialApprox Pol3(Exp3,4);
	//std::cout << Exp3.getName() << " " << Pol3.getExpData().getName() << std::endl;
	//Exp3.displayData();
	//Pol3.getExpData().displayData();
	Model* Mod3 = new PolynomialApprox(Pol3);
	//std::cout << Mod3->getCost() << std::endl;
	//Pol3.exportModel();
	//Mod3->exportModel();
	SimulatedAnnealing Opti3(Mod3);
	Opti3.initialise();
	Opti3.execute();
	Opti3.finalise();
	free(Mod3);
	*/

	Data Exp4("30Villes");
	Exp4.randSet(30);
	Exp4.exportData();

	TSP TSP4(Exp4);
	//std::cout << Exp4.getName() << " " << TSP4.getSol().getName() << std::endl;
	//Exp4.displayData();
	//TSP4.getExpData().displayData();
	//TSP4.displayModel();
	Model* Mod4 = new TSP(TSP4);
	//std::cout << Mod4->getCost()<< std::endl;
	//TSP4.getParam();
	//Mod4->exportModel();
	SimulatedAnnealing Opti4(Mod4);
	Opti4.initialise();
	Opti4.execute();
	Opti4.finalise();
	free(Mod4);

	/*
	Data Exp5("100villes");
	Exp5.fromFile("Villes.data");
	TSP TSP5(Exp5);
	Model* Mod5 = new TSP(TSP5);
	SimulatedAnnealing Opti5(Mod5,0.1,1000.,1.,1.-1./100.,100,5);
	Opti5.initialise();
	Opti5.execute();
	Opti5.finalise();
	free(Mod5);
	*/
	std::cout << "Elapsed time : " << difftime(time(nullptr),start) << "s." << std::endl;
	return 0;
}
