# -*- coding: utf-8 -*-
"""
Created on Tue Nov 27 19:35:39 2018

@author: davidcamara
"""
import numpy as np

from selection.tournament import Tournament
from heuristic_calculation.heuristic.keenEvaluation import keenEvaluation
from population.population import Population

pop = Population(4, 4)
pop.populate()
evalu = keenEvaluation()
selection = Tournament(0.1)

attacks, result = evalu.heuristic(pop)
print("attacks:", attacks)
print(pop.population)
print("")
print(selection.execute(pop, attacks).population)
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 27 19:35:39 2018

@author: davidcamara
"""
import numpy as np

from selection.tournament import Tournament
from KeenProblem.evaluation.keenEvaluation import KeenEvaluation
from population.population import Population
from recomendation.crossover.crossover import Crossover

popClass = Population(4, 4)
popClass.populate()

evalu = KeenEvaluation()

cross = Crossover()

crossoverPopulation = np.zeros((popClass.numChromosomes, popClass.numGenes))
for ch in range(0, popClass.numChromosomes - 1, 2):
    parent0 = popClass.population[ch]
    parent1 = popClass.population[ch + 1]
    print("parent", parent0, parent1)

    #    create childs
    childs = [0, 0]
    for child in range(len(childs)):
        randomGens = np.random.randint(0, 2, popClass.numGenes)