Package com.trimga.matingstrategies

Source Code of com.trimga.matingstrategies.DuplicatesCombinant

/*
Copyright 2009 Jon Tait

This file is part of TrimGA.

TrimGA is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

TrimGA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with TrimGA.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.trimga.matingstrategies;

import java.util.List;

import com.trimga.Chromosome;
import com.trimga.IllegalChromosomeException;
import com.trimga.Phenotype;

public class DuplicatesCombinant implements MatingStrategy {

  public Phenotype makeChildFromParents(Phenotype parent1, Phenotype parent2)
      throws IllegalChromosomeException
  {
    List<Chromosome> childChromosomeList = ChromosomeUtilities.makeCrossoverChild(
        parent1.getChromosomes(), parent2.getChromosomes());
     
      ChromosomeUtilities.randomlyPluckOutChromosomes(childChromosomeList);
      ChromosomeUtilities.randomlyMutateChromosomes(childChromosomeList);
      ChromosomeUtilities.randomlyAddGeneratedChromosomes(childChromosomeList);

    Phenotype childPhenotype = parent1.createPhenotype(childChromosomeList);
      return childPhenotype;
  }

}
TOP

Related Classes of com.trimga.matingstrategies.DuplicatesCombinant

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.