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/MainWindow.xaml.cs

    r12781 r12815  
    11using System.Collections.ObjectModel;
     2using System.Security.AccessControl;
    23using System.Threading;
    34using System.Xml.Serialization;
     
    3233        private EvaluationViewModel vm;
    3334
    34         private DispatcherTimer updateCollectionTimer;
    35 
    3635        private DrawingPage treeDrawingPage;
    3736
     
    4241            this.DataContext = vm = new EvaluationViewModel();
    4342            vm.MaxLen = 100;
    44             vm.MaxEvaluations = 1000000;
     43            vm.MaxIterations = 1000000;
    4544            vm.NrRuns = 10;
    46             vm.VerticalAxisString = "SolutionQuality";
    47             vm.HorizontalAxisString = "Iteration";
    4845        }
    4946
     
    5855        }
    5956
    60         private void DrawLineChart(Run run)
     57        private void DrawQualityChart(Run run)
    6158        {
    6259            List<FoundSolution> solutions = new List<FoundSolution>(run.FoundSolutions);
     
    7673
    7774            graph.StrokeThickness = 2;
    78             graph.AddToPlotter(ChartPlotter);
     75            graph.AddToPlotter(QualityChartPlotter);
     76        }
     77
     78        private void DrawSelectionChart(Run run)
     79        {
     80            List<SelectionIndicator> selectionIndicators = new List<SelectionIndicator>(run.SelectionIndicators);
     81
     82            var ds = new EnumerableDataSource<SelectionIndicator>(selectionIndicators);
     83
     84            ds.SetXMapping(x => x.TotalSelections);
     85            ds.SetYMapping(y => y.Indicator);
     86
     87            LineGraph graph = new LineGraph(ds);
     88
     89            graph.StrokeThickness = 2;
     90            graph.AddToPlotter(SelectionChartPlotter);
    7991        }
    8092
     
    93105            run.StartTime = DateTime.Now;
    94106
    95             run.Solver.Run(run.MaxEvaluations);
     107            run.Solver.Run(run.MaxIterations);
    96108
    97109            run.EndTime = DateTime.Now;
     
    136148        {
    137149            ButtonRun.IsEnabled = true;
    138             TextBoxMaxEvaluations.IsEnabled = true;
     150            TextBoxMaxIterations.IsEnabled = true;
    139151            TextBoxMaxLen.IsEnabled = true;
    140152            TextBoxRuns.IsEnabled = true;
     
    162174                policyInstance = new ThresholdAscentPolicy();
    163175            }
     176            else if (policy == typeof(BoltzmannExplorationPolicy))
     177            {
     178                policyInstance = new BoltzmannExplorationPolicy(2);
     179            }
    164180            else
    165181            {
     
    197213                }
    198214
    199                 Run run = new Run(problem, policyInstance, solver, i + 1, vm.MaxEvaluations, vm.MaxLen);
     215                Run run = new Run(problem, policyInstance, solver, i + 1, vm.MaxIterations, vm.MaxLen);
    200216
    201217                vm.Runs.Add(run);
     
    205221        }
    206222
    207         private void ClearLineChart()
    208         {
    209             ChartPlotter.Children.RemoveAll<LineGraph>();
     223        private void ClearQualityChart()
     224        {
     225            QualityChartPlotter.Children.RemoveAll<LineGraph>();
    210226        }
    211227
     
    215231        }
    216232
     233        private void ClearSelectionChart()
     234        {
     235            SelectionChartPlotter.Children.RemoveAll<LineGraph>();
     236        }
     237
    217238        private void ButtonRun_OnClick(object sender, RoutedEventArgs e)
    218239        {
    219             ClearLineChart();
     240            ClearQualityChart();
    220241            ClearComparisonChart();
     242            ClearSelectionChart();
    221243
    222244            vm.Runs.Clear();
    223245            vm.SelectedRun = null;
    224246            ButtonRun.IsEnabled = false;
    225             TextBoxMaxEvaluations.IsEnabled = false;
     247            TextBoxMaxIterations.IsEnabled = false;
    226248            TextBoxMaxLen.IsEnabled = false;
    227249            TextBoxRuns.IsEnabled = false;
     
    287309                vm.SelectedRun.Solver.FoundNewBestSolution += SelectedRun_FoundNewBestSolution;
    288310
    289                 ClearLineChart();
    290                 DrawLineChart(vm.SelectedRun);
     311                ClearQualityChart();
     312                DrawQualityChart(vm.SelectedRun);
     313
     314                if (vm.SelectedRun.RunState == RunState.Finished)
     315                {
     316                    ClearSelectionChart();
     317                    DrawSelectionChart(vm.SelectedRun);
     318                }
    291319                //DrawTreeChart(vm.SelectedRun);
    292320            }
     
    301329            Dispatcher.BeginInvoke(new Action(() =>
    302330            {
    303                 ClearLineChart();
    304                 DrawLineChart(vm.SelectedRun);
     331                ClearQualityChart();
     332                DrawQualityChart(vm.SelectedRun);
    305333            }));
    306334        }
Note: See TracChangeset for help on using the changeset viewer.