public void nextGeneration() throws Exception
    {
        generationCount++;
        List<MyIndividual<U>> left,right;
        left=new ArrayList<>();
        right=new ArrayList<>();
        for(int i =0; i<population.size(); i++)
        {
            if(i%2==0)
            {
                left.add(population.get(i));
            }
            else
            {
                right.add(population.get(i));
            }
        }
        
        List<MyIndividual<U>> newPopulation = new ArrayList<>();
        left=left.stream().sorted((one,two)-> two.getFitness()-one.getFitness()).collect(Collectors.toList());
        right=right.stream().sorted((one,two)-> two.getFitness()-one.getFitness()).collect(Collectors.toList());
        
        for(int i =0; i<left.size(); i++)
        {
            //System.out.println("i"+i);
            try
            {
                if(Math.random()<0.25)//might need tweekeing
                {
                    newPopulation.add(left.get(i).getOffspring(right.get(i)));
                    newPopulation.add(right.get(i).getOffspring(left.get(i)));
                    newPopulation.add(left.get(i).getOffspring(right.get(i)));
                }
                else
                {
                    newPopulation.add(left.get(i).getOffspring(right.get(i)));
                    newPopulation.add(right.get(i).getOffspring(left.get(i)));
                }
                
            }
            catch (Exception e)
            {
                System.err.println("i:"+i+" ex:"+e.getMessage());
            }
        }
        if(newPopulation.size()<population.size())
        {
            newPopulation.add(left.get(1).getOffspring(right.get(1)));
        }
        this.population = newPopulation.subList(0, population.size());  //maybe mutate the population size
        System.out.println("population size"+newPopulation.size());
    }