Package gpinterpreter.stack

Examples of gpinterpreter.stack.StackInstruction


  }

  public StackInstructionGene(Configuration aConfiguration)
      throws InvalidConfigurationException {
    super(aConfiguration);
    inst = new StackInstruction(NOP);

  }
View Full Code Here


  }

  public StackInstructionGene(Configuration aConfiguration, int gs)
      throws InvalidConfigurationException {
    super(aConfiguration);
    inst = new StackInstruction(NOP);
    graphSize = gs;

  }
View Full Code Here

  }

  @Override
  public void applyMutation(int index, double percentage) {

    StackInstruction toMutate = inst;
    double pc = percentage;
    percentage = Math.abs(percentage);

    if (pc >= 0) {
     
      double operand = toMutate.getOperand() + graphSize * pc;
     
      operand = operand % graphSize + 1;
     
      toMutate.setOperand((int) Math.round(operand));
     
   

    if (toMutate.getOperand() > graphSize)
      toMutate.setOperand((int) (toMutate.getOperand() % (double) graphSize));

     
     
    }else{


      double places = (symbols.length - 1) * percentage;
      switch (toMutate.getType()) {
      case PUSH:
        places++;
      case CLUSTER:
        places++;
      case NOP:
        places++;
      }
      places = Math.round(places) % (symbols.length);

      toMutate.setType(symbols[(int) places]);
    }




View Full Code Here

    double places = (symbols.length - 1) * arg0.nextDouble();
    places = Math.abs(Math.round(places) % (symbols.length));
                if(graphSize < 1){
                    System.err.println("graphSize is less than 1. Please check your input!");
                }
    inst = new StackInstruction(symbols[(int) places], arg0.nextInt(graphSize) + 1);

    StackInstruction lastInst = inst;
    if (lastInst.getOperand() <= 0)
      lastInst.setOperand(1);


  }
View Full Code Here

      } else {
        return -1;
      }
    }

    StackInstruction p2 = (StackInstruction) ((StackInstructionGene) o).getAllele();

    if (p2 != inst) {

      if (p2.getType() == NOP && inst.getType() != NOP)
        return 1;
      if (inst.getType() == NOP && p2.getType() != NOP)
        return -1;

    }

    return 0;
View Full Code Here

TOP

Related Classes of gpinterpreter.stack.StackInstruction

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.