Exemplo n.º 1
0
        private static RunInfo RunOnce(BulldozerAlgorithm<double> algorithm, Properties properties, string evolutionLogName)
        {
            var success = false;
            Chromosome chromosome = null;
            var simplificationRules = AlgebraicRules.Get()
                                                    .Where(z => z.Tags.Contains(StdTags.SafeResection))
                                                    .ToList();
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < properties.IterationCount; ++i)
            {
                algorithm.MakeIteration();

                if (OnlineSimplification(algorithm, properties))
                {
                    if (Balancer.TraceEvolution) WriteEvolutionLog(algorithm, evolutionLogName);
                    algorithm.SimplifyPool(simplificationRules);
                }

                if (Balancer.ShowTrace) Trace(algorithm);
                if (Balancer.TraceEvolution) WriteEvolutionLog(algorithm, evolutionLogName);

                success = IsSuccess(algorithm, properties.Threshold, out chromosome);
                if(success)
                {
                    break;
                }
            }
            stopwatch.Stop();

            var treeChromosome = (TreeChromosome)chromosome;
            return new RunInfo
                       {
                           Success = success,
                           ElapsedSeconds = stopwatch.Elapsed.TotalSeconds,
                           ElapsedIterations = algorithm.CurrentIteration,
                           ID = chromosome != null ? treeChromosome.ID : -1,
                           ResultRepresentation = chromosome != null
                                                      ? treeChromosome.Tree.ToPrefixForm()
                                                      : null
                       };
        }
Exemplo n.º 2
0
 private static bool OnlineSimplification(BulldozerAlgorithm<double> algorithm, Properties properties)
 {
     return properties.OnlineSimplification
         && algorithm.CurrentIteration % properties.OnlineSimplificationRate == 0;
 }