/// <summary> /// the micro-mutation is derived from Linear Genetic Programming 2004 chapter 6 section 6.2.2 /// three type selection probability are first determined and roulette wheel is used to decide which /// mutation type is to be performed /// 1. if micro-mutate-operator type is selected, then randomly pick an instruction and /// randomly select an instruction and mutate its operator to some other operator from the operator set /// 2. if micro-mutate-register type is selected, then randomly pick an instruction and /// randomly select one of the two operands, then /// 2.1 with a constant selection probability p_{const}, a randomly selected constant register is assigned to the selected operand /// 2.2 with probability 1-p_{const}, a randomly selected variable register is assigned to the selected operand /// p_{const} is the proportion of instruction that holds a constant value. /// 3. if micro-mutate-constant type is selected, then randomly pick an effective instruction with a constant as one /// of its register value, mutate the constant to c+$N(0, \omega_{\mu}$ /// </summary> public void MicroMutate(Statistics.Gaussian gauss) { double micro_mutate_operator_rate = MicroMutateOperatorRate; double micro_mutate_register_rate = MicroMutateRegisterRate; double micro_mutate_constant_rate = MicroMutateConstantRate; double operator_sector = micro_mutate_operator_rate; double register_sector = operator_sector + micro_mutate_register_rate; double r = Statistics.DistributionModel.GetUniform(); if (r < operator_sector) { MutateInstructionOperator(); } else if (r < register_sector) { MutateInstructionRegister(); } else { MutateInstructionConstant(gauss); } TrashFitness(); }
public virtual void MutateConstant(Statistics.Gaussian gauss, double standard_deviation) { if (mOperand1.IsConstant) { mOperand1.Mutate(gauss, standard_deviation); } else { mOperand2.Mutate(gauss, standard_deviation); } }
/// <summary> /// this is derived from the micro mutation implementation in section /// 6.2.2 of Linear Genetic Programming /// 1. randomly select an (effective) instruction with a constant c /// 2. change constant c through a standard deviation from the current value /// c:=c + normal(mean:=0, standard_deviation) /// </summary> public void MutateInstructionConstant(Statistics.Gaussian guass) { LGPInstruction selected_instruction = null; foreach (LGPInstruction instruction in mInstructions) { if (!instruction.IsStructuralIntron && (instruction.IsOperand1ConstantRegister || instruction.IsOperand2ConstantRegister)) { if (selected_instruction == null) { selected_instruction = instruction; } else if (Statistics.DistributionModel.GetUniform() < 0.5) { selected_instruction = instruction; } } } if (selected_instruction != null) { selected_instruction.MutateConstant(guass, MicroMutateConstantStandardDeviation); } }
public virtual void Mutate(Statistics.Gaussian gaussian, double standard_deviation) { mValue += gaussian.GetNormal() * standard_deviation; }