Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/30/15 16:37:14 (9 years ago)
Author:
aballeit
Message:

#2283 added SelectionIndicator for MCTS and problems SantaFeAnt, SymbolicRegression10, RoyalSymbol; updated SantaFeAnt grammar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/Run.cs

    r12781 r12815  
    11using HeuristicLab.Algorithms.Bandits;
    22using HeuristicLab.Algorithms.GrammaticalOptimization;
     3using HeuristicLab.Algorithms.MonteCarloTreeSearch;
    34using HeuristicLab.Algorithms.MonteCarloTreeSearch.Base;
    45using HeuristicLab.Problems.GrammaticalOptimization;
     
    2627
    2728        public Run(ISymbolicExpressionTreeProblem problem, IBanditPolicy banditPolicy, ISolver solver, int runNumber,
    28             int maxEvaluations, int maxLen)
     29            int maxIterations, int maxLen)
    2930        {
    3031            Problem = problem;
     
    3233            Solver = solver;
    3334            RunNumber = runNumber;
    34             MaxEvaluations = maxEvaluations;
     35            MaxIterations = maxIterations;
    3536            MaxLen = maxLen;
    3637
     38            selectionIndicators = new List<SelectionIndicator>();
    3739            Evaluations = 0;
    3840            BestQuality = double.MinValue;
    3941            RunState = RunState.NotStarted;
    4042            FoundSolutions = new List<FoundSolution>();
     43            CurrentSelectionIndicator = new SelectionIndicator(0, 0);
    4144
    4245            BestKnownQuality = problem.BestKnownQuality(maxLen);
     
    5255                }
    5356            };
     57            if (solver is MonteCarloTreeSearch)
     58            {
     59                MonteCarloTreeSearch mcts = (MonteCarloTreeSearch)solver;
     60                mcts.NodeSelected += mcts_NodeSelected;
     61            }
     62        }
     63
     64        private void mcts_NodeSelected(int goodSelections, int totalSelections)
     65        {
     66            CurrentSelectionIndicator.GoodSelections = goodSelections;
     67            CurrentSelectionIndicator.TotalSelections = totalSelections;
     68            this.OnPropertyChanged("CurrentSelectionIndicator");
     69            //CurrentSelectionIndicator = new SelectionIndicator(goodSelections, totalSelections);
     70            //selectionIndicators.Add(CurrentSelectionIndicator);
     71        }
     72
     73        private List<SelectionIndicator> selectionIndicators;
     74
     75        public List<SelectionIndicator> SelectionIndicators { get { return selectionIndicators; } }
     76
     77
     78        private SelectionIndicator currentSelectionIndicator;
     79
     80        public SelectionIndicator CurrentSelectionIndicator
     81        {
     82            get { return this.currentSelectionIndicator; }
     83            set { this.currentSelectionIndicator = value; this.OnPropertyChanged("CurrentSelectionIndicator"); }
    5484        }
    5585
     
    102132        }
    103133
    104         private int maxEvaluations;
    105 
    106         public int MaxEvaluations
    107         {
    108             get { return this.maxEvaluations; }
    109             set
    110             {
    111                 this.maxEvaluations = value;
    112                 this.OnPropertyChanged("MaxEvaluations");
     134        private int maxIterations;
     135
     136        public int MaxIterations
     137        {
     138            get { return this.maxIterations; }
     139            set
     140            {
     141                this.maxIterations = value;
     142                this.OnPropertyChanged("MaxIterations");
    113143            }
    114144        }
     
    297327        protected void OnPropertyChanged(string propertyName)
    298328        {
    299             if (PropertyChanged != null)
    300                 this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     329            try
     330            {
     331                if (PropertyChanged != null)
     332                    this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     333            }
     334            catch (Exception) { }
    301335        }
    302336
Note: See TracChangeset for help on using the changeset viewer.