/*
ga2main.cc
Selah Lynch July '04
*/

#include <mpi.h>
#include <fstream.h>
#include <stdio.h>
#include "population.h"
#include "problem.h"
#include "ga2.h"

//get rid off
#include<math.h>

int main(int cnt, char **args){
  MPI_Init(&cnt,&args);
  int myrank, ROOT=0;
  MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

  Problem prob("circle.data");

  Population pop(30,prob);

  GAProb ga(prob, pop);
  //makes a genetic algorithm linked to the population that alters 
  //the population

  Solution s1 (ga.BestSlnOverTime());

  ga.RunFor(200);
  Solution s2 (ga.BestSlnOverTime());

  ga.RunFor(100000);
  Solution s3 (ga.BestSlnOverTime());



  s1.Display();cout<<'\t'<<s1.GetDist(prob)<<endl;

  for(int i=0; i<1000000; i++) sqrt(945.3293);
  MPI_Barrier(MPI_COMM_WORLD);
  MPI_Barrier(MPI_COMM_WORLD);
  if(myrank==ROOT)printf("\n\n");


  s2.Display(); cout<<'\t'<<s2.GetDist(prob)<<endl;

  for(int i=0; i<1000000; i++) sqrt(945.3293);
  MPI_Barrier(MPI_COMM_WORLD);
  MPI_Barrier(MPI_COMM_WORLD);
  if(myrank==ROOT)printf("\n\n");


  s3.Display(); cout<<'\t'<<s3.GetDist(prob)<<endl;

  //ga.BestOverCluster(s).Display(); cout<<endl;

  //for(int i=0; i<1000000; i++) sqrt(945.3293);






  MPI_Finalize();
  return 0;
}


