Exemplo n.º 1
0
 /// <summary>
 /// Construct with the provided number of generations per champion, weight to the hall
 /// of fame fitness, and other parameters.
 /// The number of parallel threads defaults to Environment.ProcessorCount.
 /// </summary>
 public ParallelHallOfFameListEvaluator(uint generationsPerChampion,
                                        double hallOfFameWeight,
                                        AbstractGenerationalAlgorithm <TGenome> ea,
                                        IGenomeListEvaluator <TGenome> innerEvaluator,
                                        IGenomeDecoder <TGenome, TPhenome> genomeDecoder,
                                        ICoevolutionPhenomeEvaluator <TPhenome> phenomeEvaluator)
     : this(generationsPerChampion, hallOfFameWeight, ea, innerEvaluator, genomeDecoder, phenomeEvaluator, new ParallelOptions())
 {
 }
Exemplo n.º 2
0
        /// <summary>
        /// Called when a new evolution algorithm is initialized. Clean up any existing event listeners and
        /// connect up to the new evolution algorithm.
        /// </summary>
        public void Reconnect(AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            // Clean up.
            if(null != _ea) {
                _ea.UpdateEvent -= new EventHandler(_ea_UpdateEvent);
            }

            // Reconnect.
            _ea = ea;
            _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when a new evolution algorithm is initialized. Clean up any existing event listeners and
        /// connect up to the new evolution algorithm.
        /// </summary>
        public void Reconnect(AbstractGenerationalAlgorithm <NeatGenome> ea)
        {
            // Clean up.
            if (null != _ea)
            {
                _ea.UpdateEvent -= new EventHandler(_ea_UpdateEvent);
            }

            // Reconnect.
            _ea              = ea;
            _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Construct the form with the provided details and data sources.
        /// </summary>
        public SummaryGraphForm(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle,
                         SummaryDataSource[] dataSourceArray, AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            InitializeComponent();

            this.Text = string.Format("SharpNEAT - {0}", title);
            _dataSourceArray = dataSourceArray;
            InitGraph(title, xAxisTitle, y1AxisTitle, y2AxisTitle, dataSourceArray);

            _ea = ea;
            if(null != ea) {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Construct the form with the provided details and data sources.
        /// </summary>
        public TimeSeriesGraphForm(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle,
                         TimeSeriesDataSource[] dataSourceArray, AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            InitializeComponent();

            this.Text = string.Format("SharpNEAT Graph - {0}", title);
            _dataSourceArray = dataSourceArray;
            InitGraph(title, xAxisTitle, y1AxisTitle, y2AxisTitle, dataSourceArray);

            _ea = ea;
            if(null != ea) {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Construct with the provided form title, genome view/renderer and evolution algorithm. We listen to update events
        /// from the evolution algorithm and cleanly detach from it when this form closes.
        /// </summary>
        public GenomeForm(string title, AbstractGenomeView genomeViewControl, AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            InitializeComponent();
            this.Text = title;

            _genomeViewControl = genomeViewControl;
            genomeViewControl.Dock = DockStyle.Fill;
            this.Controls.Add(genomeViewControl);

            _ea = ea;
            if(null != ea) {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Called when a new evolution algorithm is initialized. Clean up any existing event listeners and
        /// connect up to the new evolution algorithm.
        /// </summary>
        public void Reconnect(AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            // Clean up.
            if(null != _ea) {
                _ea.UpdateEvent -= new EventHandler(_ea_UpdateEvent);
            }

            foreach(PointPairList ppl in _pointPlotArray) {
                ppl.Clear();
            }

            // Reconnect.
            _ea = ea;
            _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Called when a new evolution algorithm is initialized. Clean up any existing event listeners and
        /// connect up to the new evolution algorithm.
        /// </summary>
        public void Reconnect(AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            // Clean up.
            if(null != _ea) {
                _ea.UpdateEvent -= new EventHandler(_ea_UpdateEvent);
            }

            foreach(RollingPointPairList ppl in _pointPlotArray) {
                ppl.Clear();
            }

            // Reconnect.
            _ea = ea;
            _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Construct with the provided form title, genome view/renderer and evolution algorithm. We listen to update events
        /// from the evolution algorithm and cleanly detach from it when this form closes.
        /// </summary>
        public GenomeForm(string title, AbstractGenomeView genomeViewControl, AbstractGenerationalAlgorithm <NeatGenome> ea)
        {
            InitializeComponent();
            this.Text = title;

            _genomeViewControl     = genomeViewControl;
            genomeViewControl.Dock = DockStyle.Fill;
            this.Controls.Add(genomeViewControl);

            _ea = ea;
            if (null != ea)
            {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Construct the form with the provided details and data sources.
        /// </summary>
        public SummaryGraphForm(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle,
                                SummaryDataSource[] dataSourceArray, AbstractGenerationalAlgorithm <NeatGenome> ea)
        {
            InitializeComponent();

            this.Text        = $"SharpNEAT - {title}";
            _dataSourceArray = dataSourceArray;
            InitGraph(title, xAxisTitle, y1AxisTitle, y2AxisTitle, dataSourceArray);

            _ea = ea;
            if (null != ea)
            {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
        /// <summary>
        /// Construct with the provided form title, genome view/renderer and evolution algorithm. We listen to update events
        /// from the evolution algorithm and cleanly detach from it when this form closes.
        /// </summary>
        public ProblemDomainForm(string title, AbstractDomainView domainViewControl, AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            InitializeComponent();
            this.Text = title;

            _domainViewControl = domainViewControl;
            domainViewControl.Dock = DockStyle.Fill;
            this.Controls.Add(domainViewControl);
            this.Size = domainViewControl.WindowSize;

            _ea = ea;
            if(null != ea) {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Construct with the provided form title, genome view/renderer and evolution algorithm. We listen to update events
        /// from the evolution algorithm and cleanly detach from it when this form closes.
        /// </summary>
        public ProblemDomainForm(string title, AbstractDomainView domainViewControl, AbstractGenerationalAlgorithm <NeatGenome> ea)
        {
            InitializeComponent();
            this.Text = title;

            _domainViewControl     = domainViewControl;
            domainViewControl.Dock = DockStyle.Fill;
            this.Controls.Add(domainViewControl);
            this.Size = domainViewControl.WindowSize;

            _ea = ea;
            if (null != ea)
            {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Construct with the provided number of generations per champion, weight to the hall
        /// of fame fitness, parallel options, and other parameters.
        /// </summary>
        public ParallelHallOfFameListEvaluator(uint generationsPerChampion,
                                               double hallOfFameWeight,
                                               AbstractGenerationalAlgorithm <TGenome> ea,
                                               IGenomeListEvaluator <TGenome> innerEvaluator,
                                               IGenomeDecoder <TGenome, TPhenome> genomeDecoder,
                                               ICoevolutionPhenomeEvaluator <TPhenome> phenomeEvaluator,
                                               ParallelOptions options)
        {
            Debug.Assert(hallOfFameWeight >= 0d);
            Debug.Assert(hallOfFameWeight <= 1d);

            _generationsPerChampion = generationsPerChampion;
            _hallOfFameWeight       = hallOfFameWeight;
            _innerEvaluator         = innerEvaluator;
            _genomeDecoder          = genomeDecoder;
            _phenomeEvaluator       = phenomeEvaluator;
            _parallelOptions        = options;

            _hallOfFame     = new List <TGenome>();
            ea.UpdateEvent += new EventHandler(ea_UpdateEvent);
        }
Exemplo n.º 14
0
        private void ea_UpdateEvent(object sender, EventArgs e)
        {
            // Make sure that the event sender is an EA.
            Debug.Assert(sender is AbstractGenerationalAlgorithm <TGenome>);

            // Cast the EA so we can access the current champion.
            AbstractGenerationalAlgorithm <TGenome> ea = (AbstractGenerationalAlgorithm <TGenome>)sender;

            // Update every few generations.
            if (ea.CurrentGeneration < (_generationsPerChampion + _lastUpdate))
            {
                return;
            }

            // Update the update counter.
            _lastUpdate = ea.CurrentGeneration;

            // Add the genome to the hall of fame.
            _hallOfFame.Add(ea.CurrentChampGenome);

            Console.WriteLine("Hall of Fame Updated. Size: {0}", _hallOfFame.Count);
        }