Beispiel #1
0
        public void Calculate(DateTime From, DateTime Till, uint history, uint forward)
        {
            if (From >= Till)
            {
                throw new ArgumentException("Date From must be less then date Till");
            }

            List <KeyValuePair <OptimisationType, DateTime[]> > data = new List <KeyValuePair <OptimisationType, DateTime[]> >();

            OptimisationType type = OptimisationType.History;

            DateTime _history = From;
            DateTime _forward = From.AddDays(history + 1);

            DateTime CalcEndDate()
            {
                return(type == OptimisationType.History ? _history.AddDays(history) : _forward.AddDays(forward));
            }

            while (CalcEndDate() <= Till)
            {
                DateTime from = type == OptimisationType.History ? _history : _forward;
                data.Add(new KeyValuePair <OptimisationType, DateTime[]>(type, new DateTime[2] {
                    from, CalcEndDate()
                }));

                if (type == OptimisationType.History)
                {
                    _history = _history.AddDays(forward + 1);
                }
                else
                {
                    _forward = _forward.AddDays(forward + 1);
                }

                type = type == OptimisationType.History ? OptimisationType.Forward : OptimisationType.History;
            }

            if (data.Count == 0)
            {
                throw new ArgumentException("Can`t create any date borders with setted In sample (History) step");
            }

            DateBorders?.Invoke(data);
        }
Beispiel #2
0
        /// <summary>
        /// Метод получающий список дат (коридоры оптимизаций) для тестера и оптимизатора
        /// </summary>
        /// <param name="pathToFile">Путь к файлу предварительно созданному методом SaveBorders данного класса</param>
        /// <returns>Список оптимизационных проходов</returns>
        public static List <KeyValuePair <DateBorders, OptimisationType> > GetBorders(string pathToFile)
        {
            XmlDocument document = new XmlDocument();

            document.Load(pathToFile);

            List <KeyValuePair <DateBorders, OptimisationType> > borders = new List <KeyValuePair <DateBorders, OptimisationType> >();

            foreach (XmlNode item in document["Borders"].ChildNodes)
            {
                DateBorders borderItem = new DateBorders(
                    DateTime.ParseExact(item["From"].InnerText, "dd.MM.yyyy HH:mm:ss.fff", null),
                    DateTime.ParseExact(item["Till"].InnerText, "dd.MM.yyyy HH:mm:ss.fff", null));
                OptimisationType type = (OptimisationType)Enum.Parse(typeof(OptimisationType), item["Type"].InnerText);

                borders.Add(new KeyValuePair <DateBorders, OptimisationType>(borderItem, type));
            }

            return(borders);
        }
Beispiel #3
0
 public StepItem(OptimisationType type)
 {
     Type = type;
 }