예제 #1
0
        IList <Line> EvaluateWholeEvening(Network ann, Track track, INormalizer velocityNormalizer, Line[] morning)
        {
            const int hvc = AnnInput.HistoricalVelocitiesCount;
            var       lastLinesOfMorning =
                morning.Where(x => x.Time <= TimeConstants.T18).Reverse().Take(hvc + 1).Reverse().ToArray();
            var input = new AnnInput
            {
                HistoricalVelocities = lastLinesOfMorning.Take(hvc).Select(x => x.Velocity.Value).ToArray(),
                Time = lastLinesOfMorning.Last().Time
            };

            while (!Close10(input.Time, TimeConstants.T18))
            {
                double next = ann.Compute(input)[0];
                input = input.Shift(next, input.Time.AddMinutes(TimeConstants.Interval));
            }

            var res = new List <Line>();

            for (int i = TimeConstants.EarlyEvening; i < TimeConstants.LastMeasurement; i++)
            {
                double next = ann.Compute(input)[0];
                res.Add(new Line {
                    Day = track.Day, Street = track.Street, Time = TimeConstants.EveningTime(i), Velocity = velocityNormalizer.Denormalize(next)
                });

                input = input.Shift(next, TimeConstants.EveningTime(i + 1));
            }

            return(res);
        }
예제 #2
0
        IList <TrainingPrecedent <AnnInput> > BuildTrainingSet(IEnumerable <Track> tracks)
        {
            var res = new List <TrainingPrecedent <AnnInput> >();

            foreach (var track in tracks)
            {
                if (track.Lines.Length < AnnInput.HistoricalVelocitiesCount + 1)
                {
                    continue;
                }

                var currentInput = new AnnInput
                {
                    HistoricalVelocities = track.Lines.Take(AnnInput.HistoricalVelocitiesCount).Select(x => x.Velocity.Value).ToArray(),
                    Time = track.Lines[AnnInput.HistoricalVelocitiesCount].Time
                };
                var newLines = track.Lines.Skip(AnnInput.HistoricalVelocitiesCount).ToArray();

                for (int i = 0; i < newLines.Length - 1; i++)
                {
                    var l  = newLines[i];
                    var ln = newLines[i + 1];

                    if (ln.Time >= TimeConstants.T18 || !Close10(l.Time, ln.Time))
                    {
                        break;
                    }

                    var precedent = new TrainingPrecedent <AnnInput> {
                        Output = l.Velocity.Value, Input = currentInput
                    };
                    res.Add(precedent);

                    currentInput = currentInput.Shift(l.Velocity.Value, ln.Time);
                }
            }
            return(res);
        }