public static int GetTotalLength(Result item) { int result = 0; for (int i = 0; i < item.SequenceIndexes.Length - 1; i++) { result += EvaluationLogic.GetSinglePartialSum(Global.Nucleotids[item.SequenceIndexes[i] - 1], Global.Nucleotids[item.SequenceIndexes[i + 1] - 1]); } return(result); }
private static int HandleFromPositionToMax(Result item, int startingPosition) { int position = Global.Nucleotids[0].Sequence.Length; int nucleotidsCounter = startingPosition; while (nucleotidsCounter < item.SequenceIndexes.Length - 1 && position < Global.MaxLength) { position += EvaluationLogic.GetSinglePartialSum(Global.Nucleotids[item.SequenceIndexes[nucleotidsCounter] - 1], Global.Nucleotids[item.SequenceIndexes[nucleotidsCounter + 1] - 1]); if (position <= Global.MaxLength) { nucleotidsCounter++; } } return(nucleotidsCounter + 1 - startingPosition); }
public static List <Tuple <int, int> > GetWeakConnectedNucleotidIndexes(Result item) { var results = new List <Tuple <int, int> >(); for (int i = 1; i < item.SequenceIndexes.Length - 1; i++) { int distanceLeft = EvaluationLogic.GetSinglePartialSum(Global.Nucleotids[item.SequenceIndexes[i - 1] - 1], Global.Nucleotids[item.SequenceIndexes[i] - 1]); int distanceRight = EvaluationLogic.GetSinglePartialSum(Global.Nucleotids[item.SequenceIndexes[i] - 1], Global.Nucleotids[item.SequenceIndexes[i + 1] - 1]); if (distanceLeft + distanceRight >= Global.Nucleotids[0].Sequence.Length) { results.Add(new Tuple <int, int>(i, distanceLeft + distanceRight)); } } return(results); }
public static Result GenerateGreedySolution() { IList <int> sequence = new List <int>(); IList <int> notUsed = Enumerable.Range(0, Global.Nucleotids.Count).ToList(); int starting = StaticRandom.Rand(Global.Nucleotids.Count - 1); sequence.Add(starting); notUsed.Remove(starting); while (sequence.Count != Global.Nucleotids.Count) { var current = sequence.Last(); var best = notUsed.Select(i => new Tuple <int, int>(i, EvaluationLogic.GetSinglePartialSum(Global.Nucleotids[current], Global.Nucleotids[i]))).OrderBy(i => i.Item2).First().Item1; sequence.Add(best); notUsed.Remove(best); } return(new Result() { SequenceIndexes = sequence.Select(i => i + 1).ToArray() }); }