import java.io.*;
import java.text.*;
import java.util.Locale;

class TSP_montecarlo
{
public TSP_gene G;    // string of variables makes a genotype1
public int    POPSIZE;           // population size
double xi[],yi[]; //şehir adresleri
      
  public TSP_montecarlo(String name,int POPSİZEi)
  {double a[][]=Text.readDoubleT(name);  
   double xi[]=a[0];
   double yi[]=a[1];
   POPSIZE=POPSİZEi;
   TSP_gene G1=new TSP_gene(xi,yi);
   double toplameniyi=1e20;
   double distance;
   int counter;
   for(int i=0;i<POPSIZE;i++)
   {G1=new TSP_gene(xi,yi);
   distance=G1.distance();
   counter=i%1000000;
   if(counter==0) System.out.println("i="+i);
   if(distance < toplameniyi) {toplameniyi=distance;G=new TSP_gene(G1);System.out.println("i="+i+"\n"+G.toString());}
   }
   }
  	
  public static void main(String arg[])
  {
    TSP_montecarlo sg=new TSP_montecarlo("cities.txt",100000000);
    //System.out.println("selected generations : "+sg.G.toString());
    sg.G.plot();
  }

}  
