예제 #1
0
        public Individual(AlgoDb algoDb)
        {
            //initialize
            this.algoDb         = algoDb;
            this.invitees       = new List <Invitee>(algoDb.invitees);
            this.tables         = new List <Table>(algoDb.tables);
            this.invitessAmount = invitees.Count;
            this.tablesAmount   = tables.Count;
            gens = new Gen[invitessAmount];

            /*      //generate gens list - all invitess with random tables
             *    Gen gen = null;
             *    for (int i = 0; i < gens.Length; i++)
             *    {
             *        gen = generateRandomGen(i);
             *        if(gen != null)
             *        {
             *            gens[i] = gen;
             *        }
             *    }
             */
            for (int i = 0; i < gens.Length; i++)
            {
                gens[i] = generateRandomGen(i);
            }
        }
예제 #2
0
 public Individual(Individual copyIndividual)
 {
     this.algoDb = copyIndividual.algoDb;
     cloneGens(copyIndividual.getGens());
     this.invitees = copyIndividual.invitees;
     this.tables   = copyIndividual.tables;
 }
예제 #3
0
        public Individual RunAlgo(AlgoDb algoDb)
        {
            this.algoDb = algoDb;
            //Initialize population
            Population population = new Population(algoDb);

            population.initializePopulation(AlgoConsts.populationLength);

            //Calculate fitness of each individual + update Top X
            population.CalculateIndividualsFitness();
            updateTopX(population);

            //While not break condition
            while (!breakCondition())
            {
                //Do selection
                parentsCouplesList = Selection(population);

                //TODO - population includes individual which doesnt include algoDB! to fix!
                //Do crossover - get list of paretns - return new pointer for population
                population = CrossOver(parentsCouplesList);

                //Do mutation under a random probability
                if (algoUtils.AlgoRandom(1000) < 5)
                {
                    population.runMutation();
                }

                //Calculate new fitness value + update top X
                population.CalculateIndividualsFitness();
                updateTopX(population);

                iterations++;
            }

            return(GetIndividualWithBestResult());
        }
예제 #4
0
 public Population(AlgoDb algoDb)
 {
     this.algoDb   = algoDb;
     this.invitees = new List <Invitee>(algoDb.invitees);
     this.tables   = new List <Table>(algoDb.tables);
 }
예제 #5
0
 public Population(Individual[] individuals, AlgoDb algoDb)
 {
     cloneIndividuals(individuals);
     this.algoDb = algoDb;
 }
예제 #6
0
 public Individual(int gensSize, AlgoDb algoDb)
 {
     this.algoDb = algoDb;
     gens        = new Gen[gensSize];
 }