/// <summary> /// Targets to remove those sequences with low or the same fitness /// </summary> /// <param name="ucovLocList"></param> /// <param name="persistentUncoveredLocationStore"></param> private void RemoveSuggestionsWithLowFitness(UncoveredCodeLocationStoreList ucovLocList, PersistentUncoveredLocationStore pucls, List <MethodSignatureSequence> putspecificsequences) { pucls.NumberOfUnsuccessfulAttempts++; int bestFitness = pucls.Fitnessvalue; foreach (var ucovloc in ucovLocList.StoreList) { if (ucovloc.Fitnessvalue < bestFitness) { bestFitness = ucovloc.Fitnessvalue; } } var explorableType = ucovLocList.ExplorableType; var tempSuggestedSequences = new List <MethodSignatureSequence>(); tempSuggestedSequences.AddRange(pucls.SuggestedMethodSequences); //remove those suggestions that have lower fitness values foreach (var ucovloc in ucovLocList.StoreList) { //Get matching sequence from pucls MethodSignatureSequence matchingseq; if (!FactorySuggestionStore.TryGetMatchingSequence(ucovloc.MethodCallSequence, tempSuggestedSequences, out matchingseq)) { //This sequence is not there in our suggested sequence. This should have happened //due to the case that it came from other uncovered location stores, and is helping //the current store. if (ucovloc.Fitnessvalue <= bestFitness) { var mss = new MethodSignatureSequence(); foreach (var methodinucov in ucovloc.MethodCallSequence.Sequence) { if (methodinucov.Contains("..ctor(")) //Don't add constructors { continue; } if (!methodinucov.Contains(explorableType)) //Ignore the method calls from other types { continue; } mss.Sequence.Add(methodinucov); } if (mss.Sequence.Count > 0) { pucls.SuggestedMethodSequences.Add(mss); } } continue; } tempSuggestedSequences.Remove(matchingseq); if (ucovloc.Fitnessvalue > bestFitness) { //Previous sequence is of no use as it is leading to higher fitness value pucls.SuggestedMethodSequences.Remove(matchingseq); } } if (tempSuggestedSequences.Count != 0) { //Not all sequences are assigned fitness values. Raise warnings for other sequences this.Log.LogWarning(WikiTopics.MissingWikiTopic, "sequencematching", "Fitness values are not available for some previous sequences, Needs to handle this case!!!"); //Remove those suggestions whose fitness value is not evaluated at all. Ideally //this case should not happen. Needs additional debugging. //foreach (var seq in tempSuggestedSequences) // pucls.SuggestedMethodSequences.Remove(seq); } //Update the previous fitness value with the current. If there is any improvement in the fitness, reset the number //of unsuccessful attempts if (pucls.Fitnessvalue != bestFitness) { pucls.NumberOfUnsuccessfulAttempts = 0; pucls.Fitnessvalue = bestFitness; } }