예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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()
            });
        }