Package org.jgap.impl

Examples of org.jgap.impl.IntegerGene


  {
    ArrayList<Gene> genes = new ArrayList<Gene>();
    for (int i = 0; i < CHROMOSOME_LENGTH; i++)
      try
      {
        IntegerGene g = new IntegerGene(conf, 0, requiredActions.size() - 1);
        g.setAllele(0);
        genes.add(g);
      }
      catch (InvalidConfigurationException e)
      {
        StringWriter sw = new StringWriter();
View Full Code Here


    int CC = 0;
    for (EcAction a : bo.actions)
    {
      if (++CC > CHROMOSOME_LENGTH)
        continue;
      IntegerGene g = new IntegerGene(conf, 0, requiredActions.size() - 1);
      Integer allele = EcAction.findAllele(requiredActions, a);
      if (allele == null)
        break;
      g.setAllele(allele);
      genes.add(g);

    }
    while (genes.size() < CHROMOSOME_LENGTH)
    {
      IntegerGene g = new IntegerGene(conf, 0, requiredActions.size() - 1);
      g.setAllele(0);
      genes.add(g);
    }
    Chromosome c = new Chromosome(conf);
    c.setGenes(genes.toArray(new Gene[genes.size()]));
    c.setIsSelectedForNextGeneration(true);
View Full Code Here

  {
    EcBuildOrder s;
    s = source.clone();
    for (Gene g1 : arg0.getGenes())
    {
      IntegerGene g = (IntegerGene) g1;
      Integer i = (Integer) g.getAllele();
      try
      {
        s.addAction((EcAction) requiredActions.get(i).newInstance());
      }
      catch (InstantiationException e)
View Full Code Here

        for (int i = 0; i < program.size(); i++) {

            Gene g = program.get(i);

            if (g instanceof IntegerGene) {
                IntegerGene ig = (IntegerGene) g;
                inst = IntegerInstructionGene.getInstruction(ig.intValue(),
                        size);
            } else if (g instanceof InstructionGene) {
                inst = ((InstructionGene) g).getInstruction();
            }
View Full Code Here

        for (int i = 0; i < individual.size(); i++) {
            Instruction inst = null;
            switch (geneType) {
                case INTEGER:
                    IntegerGene g = (IntegerGene) (individual.get(i));
                    inst = IntegerInstructionGene.getInstruction(g.intValue(),
                            in.getSize());
                    break;
                case BITFIELD:
                    FixedBinaryGene fbg = (FixedBinaryGene) (individual.get(i));
                    inst = BitFieldInstructionGene.getInstruction(
View Full Code Here

                    case BITFIELD:
                        return new BitFieldInstructionGene(gaConf,size);
                    case STACK:
                        return new StackInstructionGene(gaConf, size);
                    case FLAT:
                        return new IntegerGene(gaConf, 0, size);
                    case HCLUST:
                        return new IntegerGene(gaConf, 0, size + 2*(size - 1));
                    default:
                        throw new RuntimeException("Gene Type \"" + type
          + "\" is not a valid option.");
                }
               
View Full Code Here

                    if(ind instanceof InstructionGene){
                        copy.add(((InstructionGene)ind).clone());
                    }else if(ind instanceof StackInstructionGene){
                        copy.add(((StackInstructionGene)ind).clone());
                    }else if(ind instanceof IntegerGene){
                        IntegerGene c = (IntegerGene)ind;
                        IntegerGene n = null;
                        try {
                            n = new IntegerGene(ind.getConfiguration(), c.getLowerBounds(), c.getUpperBounds());
                        } catch (InvalidConfigurationException ex) {
                            Logger.getLogger(RandomMutationHillClimbingSearch.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        n.setAllele(c.intValue());
                        copy.add(n);
                    }else{
                        throw new RuntimeException(String.format("Can't make a clone of gene of type %s object is: %s ",ind.getClass().toString(), ind));
                    }
                   
View Full Code Here

TOP

Related Classes of org.jgap.impl.IntegerGene

Copyright © 2018 www.massapicom. 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.