00001 /*using System; 00002 using System.Collections.Generic; 00003 using System.Linq; 00004 using System.Text; 00005 00006 namespace GEP.Core.Common.GeneticOperators 00007 { 00008 class OperatorsGroup : GeneticOperator 00009 { 00010 GeneticOperator[] _operators; 00011 double[] _operatorsComulativeProbabilityDistribution; 00012 double _totalComulativeProbability; 00013 public GeneticOperator Next 00014 { 00015 get 00016 { 00017 double rd = _random.NextDouble(); 00018 if (_operatorsComulativeProbabilityDistribution[ 00019 _operatorsComulativeProbabilityDistribution.Length - 1] <= rd) 00020 return _operators[_operators.Length - 1]; 00021 int i = 0; 00022 while (rd < _operatorsComulativeProbabilityDistribution[i]) 00023 { 00024 i++; 00025 } 00026 return _operators[i]; 00027 } 00028 } 00029 00030 public OperatorsGroup(GeneticOperator[] operators, double[] operatorsComulativeProbabilityDistribution, 00031 bool applyOnNewGeneration, GenotypeSelection.GenotypeSelection selection, string name) 00032 : base(0, 0, false, applyOnNewGeneration, selection, name) 00033 { 00034 _operators = operators; 00035 _operatorsComulativeProbabilityDistribution = operatorsComulativeProbabilityDistribution; 00036 if (operators.Length - 1 != operatorsComulativeProbabilityDistribution.Length) 00037 throw new GepException( 00038 "The number of operators in an operators group must be greater than the length of the array, holding the comulative probability distribution, with exactly 1."); 00039 for (int i = operatorsComulativeProbabilityDistribution.Length - 2; 0 <= i; i--) 00040 { 00041 if (operatorsComulativeProbabilityDistribution[i] > operatorsComulativeProbabilityDistribution[i + 1]) 00042 throw new GepException( 00043 "Invalid operators comulative probability distribution."); 00044 if (operatorsComulativeProbabilityDistribution[ 00045 operatorsComulativeProbabilityDistribution.Length - 1] > 1) 00046 throw new GepException( 00047 "Invalid operators comulative probability distribution."); 00048 } 00049 } 00050 00051 public override void Apply(Genotype[] parameters, int[] selectionIndexes, Genotype[] destination, ref int destIndex) 00052 { 00053 throw new NotImplementedException(); 00054 } 00055 00056 public override void Apply(Genotype[] parameters, int[] selectionIndexes) 00057 { 00058 throw new NotImplementedException(); 00059 } 00060 } 00061 } 00062 */