Ejemplo n.º 1
0
        public override Harmony <StopTimeInfo> GenerateRandomHarmony()
        {
            var randomArguments = GetRandomArguments();

            var objectiveValue = ObjectiveFunction.GetObjectiveValue(randomArguments);

            return(new Harmony <StopTimeInfo>(objectiveValue, randomArguments));
        }
        /// <summary>
        /// Pitches the adjust harmony.
        /// </summary>
        /// <param name="harmony">The harmony.</param>
        /// <returns></returns>
        public override Harmony <StopTimeInfo> PitchAdjustHarmony(Harmony <StopTimeInfo> harmony)
        {
            if (harmony.Arguments.Length < 2 || harmony.Arguments.Last().StopDto.Name.TrimToLower() == Destination.Name.TrimToLower())
            {
                return(harmony);
            }

            var randomIndex = harmony.Arguments.GetRandomIndexMinimum(1);

            var predecessorStopTimeId = harmony.Arguments[randomIndex - 1].Id;
            var predecessorNode       = Graph[predecessorStopTimeId];

            var pitchAdjustedSuccessor = GetRandomNeighborNodeExceptExisting(predecessorNode, harmony.Arguments);

            if (pitchAdjustedSuccessor != null)
            {
                harmony.Arguments[randomIndex] = pitchAdjustedSuccessor.Data;
            }

            harmony.ObjectiveValue = ObjectiveFunction.GetObjectiveValue(harmony.Arguments);

            return(harmony);
        }