Changeset 15275 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Selector
- Timestamp:
- 07/20/17 11:39:53 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Selector/LexicaseSelector.cs
r15189 r15275 37 37 /// <summary> 38 38 /// A lexicase selection operator which considers all successful evaluated training cases for selection. 39 ///40 /// ToDo: LexicaseSelector and ICaseSingleObjectiveSelector are ISingleObjectiveOperator, which contains Maximization and Qualities which is not needed41 39 /// </summary> 42 40 [Item("LexicaseSelector", "A lexicase selection operator which considers all successful evaluated training cases for selection.")] … … 45 43 public ILookupParameter<ItemArray<DoubleArray>> CaseQualitiesParameter 46 44 { 47 get { return (ILookupParameter<ItemArray<DoubleArray>>)Parameters[ PushProblem.CaseQualitiesScopeParameterName]; }45 get { return (ILookupParameter<ItemArray<DoubleArray>>)Parameters[IntegerVectorPushProblem.CaseQualitiesScopeParameterName]; } 48 46 } 49 47 … … 57 55 public LexicaseSelector() { 58 56 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>( 59 PushProblem.CaseQualitiesScopeParameterName,57 IntegerVectorPushProblem.CaseQualitiesScopeParameterName, 60 58 "The quality of every single training case for each individual.")); 61 59 } … … 68 66 var selected = new IScope[count]; 69 67 var caseQualities = CaseQualitiesParameter.ActualValue; 70 var repeats = Math.Ceiling(count / (double)population.Count);68 var repeats = (int)Math.Ceiling(count / (double)population.Count); 71 69 var caseCount = caseQualities[0].Length; 72 70 var source = Enumerable.Range(0, population.Count).ToList(); … … 77 75 78 76 // copy list if required 79 var pool = k == repeats -1 ? source : new List<int>(source);77 var pool = repeats == 1 ? source : new List<int>(source); 80 78 var countLimit = Math.Min(count - k * population.Count, population.Count); 81 79 82 80 for (var i = 0; i < countLimit; i++) { 83 var bestIndividuals = pool;81 var candidates = pool; 84 82 85 for (var j = 0; j < fitnessCaseIndexes.Count && bestIndividuals.Count > 1; j++) 86 bestIndividuals = GetBestIndividuals(maximization, caseQualities, bestIndividuals, fitnessCaseIndexes[j]); 83 for (var j = 0; j < fitnessCaseIndexes.Count && candidates.Count > 1; j++) { 84 candidates = GetBestIndividuals(maximization, caseQualities, candidates, fitnessCaseIndexes[j]); 85 } 87 86 88 87 /* If only one individual remains, it is the chosen parent. If no more fitness cases are left, a parent is 89 88 chosen randomly from the remaining individuals */ 90 var bestIndividualIndex = bestIndividuals.Count == 1 ? bestIndividuals[0] : bestIndividuals.Random(random);89 var bestIndividualIndex = candidates.Count == 1 ? candidates[0] : candidates.Random(random); 91 90 var bestIndividual = population[bestIndividualIndex]; 92 91
Note: See TracChangeset
for help on using the changeset viewer.