Ejemplo n.º 1
0
 public RegressionTaskV5()
 {
     LearningRange = new Range(0, 1, 0.025);
     Function = z => z * Math.Sin(25*z);
     MaxError = 0.5;
     IterationsCount = 102400 + 51200;
 }
Ejemplo n.º 2
0
 public void RangeLadenUndSpeichern()
 {
     var r=new Range(1, 3);
     var filename = "TestRange.xml";
     ObjectExtentions.SaveToXml(r, filename);
     var rGeladen = ObjectExtentions.LoadFromXml<Range>(filename);
     Assert.AreEqual(r, rGeladen);
 }
Ejemplo n.º 3
0
        private async Task<DownloadInfo> StartNewDownload(DownloadJob job)
        {
            var cookies = await _httpClient.GetCookiesAsync(_credentials);
            var webFileInfo = await _httpClient.GetFileInfoAsync(job.ExFileId.Value, cookies);

            var range = new Range
            {
                From = Position.From(job.BytesDownloaded),
                To = Position.From((int)webFileInfo.FileSize - 1),
            };

            var stream = await _httpClient.DownloadFileAsync(job.ExFileId.Value, cookies, range);
            
            var cts = new CancellationTokenSource();

            RegisterTokenSource(job.Id, cts);

            var ct = cts.Token;
            var downloadInfo = DownloadInfo.Default;

            Action<int> UIAction = pr => { };
            
            try
            {
                var storage = _storageAllocator.GetInstance(webFileInfo.FileName, startNew: job.Status == JobStatus.New);

                ValidateFile(storage, job);

                job.MarkAsStarted();

                await _downloader.Download(storage, UIAction, downloadInfo.UpdateBytesRead, ct, stream);

                job.MarkAsFinished();

                var intergrityValidator = new IntegrityValidator(storage);

                var isValid = await intergrityValidator.ValidateHash(job.ExpectedHash);

                if (!isValid)
                {
                    throw new Exception("File hash is wrong");
                }

                return downloadInfo.AsFinished();
            }
            catch (OperationCanceledException)
            {
                return downloadInfo;
            }
            finally
            {
                RemoveUsedToken(job.Id);
            }
        }
Ejemplo n.º 4
0
 public RegressionTaskV6()
 {
     LearningRange = new Range(-1, 1, 0.01);
 }
Ejemplo n.º 5
0
 public RegressionTaskV3()
 {
     LearningRange = new Range(0, 1, 0.025);
     Function = z => z * Math.Sin(15*z);
     MaxError = 0.5;
 }