Exemplo n.º 1
0
        private void HandleIterationComplete(object sender, IterationCompleteEventArgs args)
        {
            // Don't update every iteration if they happen very frequently
            if ((DateTime.Now - _lastUpdateTime).TotalSeconds >= MinSecondsBetweenUpdates)
            {
                if (InvokeRequired)
                {
                    BeginInvoke((MethodInvoker) (() => HandleIterationComplete(sender, args)), null);
                }
                else
                {
                    var totalIterations = args.IterationNumber + args.IterationsRemaining;
                    var elapsedTime = DateTime.Now - _startTime;
                    var remainingTime =
                        TimeSpan.FromMilliseconds((elapsedTime.TotalMilliseconds / args.IterationNumber) *
                                                  args.IterationsRemaining);

                    progressBar1.Value = (int) (((double) args.IterationNumber / totalIterations) * 100);
                    iterationLabel.Text = string.Format("Iteration: {0} / {1}", args.IterationNumber, totalIterations);
                    timeRemainingLabel.Text = string.Format("Time remaining: {0:00}:{1:00}:{2:00}", remainingTime.Hours,
                                                            remainingTime.Minutes, remainingTime.Seconds);

                    args.Stop |= _stop;

                    _lastUpdateTime = DateTime.Now;
                }
            }
        }
Exemplo n.º 2
0
        private bool OnIterationComplete(GeneScore score, int iterationCount, int iterationsRemaining)
        {
            if (IterationComplete != null)
            {
                var args = new IterationCompleteEventArgs(score, iterationCount, iterationsRemaining);
                IterationComplete(this, args);

                return(args.Stop);
            }

            return(false);
        }
Exemplo n.º 3
0
        private void HandleIterationComplete(object sender, IterationCompleteEventArgs args)
        {
            _iterationNumber = args.IterationNumber;

            args.Stop = UserAbort;
            _parameterWriter.WriteParamValues(args.IterationNumber, args.Score.Fitness, args.Score.Gene);

            if (__lastParameters.ScreeningThreshold > 0 && args.Score.Fitness > __lastParameters.ScreeningThreshold)
            {
                Strategy.Print(Strategy.Instrument.FullName + ": Met threshold of " +
                               __lastParameters.ScreeningThreshold + " with fitness of " +
                               args.Score.Fitness.ToString("N2") + " on iteration " + (_iterationNumber + 1));

                args.Stop = true;
            }
        }
Exemplo n.º 4
0
        private bool OnIterationComplete(GeneScore score, int iterationCount, int iterationsRemaining)
        {
            if (IterationComplete != null)
            {
                var args = new IterationCompleteEventArgs(score, iterationCount, iterationsRemaining);
                IterationComplete(this, args);

                return args.Stop;
            }

            return false;
        }