Changeset 12840 for branches/HeuristicLab.Problems.GrammaticalOptimization
- Timestamp:
- 08/08/15 19:49:05 (9 years ago)
- Location:
- branches/HeuristicLab.Problems.GrammaticalOptimization
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/MainWindow.xaml
r12833 r12840 102 102 </Grid.RowDefinitions> 103 103 <ListBox Name="ListBoxRuns" Grid.Column="0" Width="100" ItemsSource="{Binding Runs}" SelectionChanged="ListBoxRuns_OnSelectionChanged"/> 104 <TabControl Grid.Column="1">105 <TabItem Header="Quality-Chart">104 <TabControl Name="ChartSelector" Grid.Column="1" SelectionChanged="Selector_OnSelectionChanged"> 105 <TabItem Name="TabQualityChart" Header="Quality-Chart"> 106 106 <Grid> 107 107 <Grid.RowDefinitions> … … 114 114 <d3:ChartPlotter Grid.Column="1" x:Name="QualityChartPlotter" LegendVisible="False" EnableSmoothPanningForNumericAxes="True"> 115 115 <d3:Header Content="Quality-Chart"/> 116 <d3:VerticalAxisTitle Content="Qualit y" />117 <d3:HorizontalAxisTitle Content="Evalu ation"/>116 <d3:VerticalAxisTitle Content="Qualität" /> 117 <d3:HorizontalAxisTitle Content="Evaluierungen"/> 118 118 </d3:ChartPlotter> 119 119 </Grid> 120 120 </TabItem> 121 <TabItem Header="SelectionIndicator-Chart">121 <TabItem Name="TabSelectionIndicator" Header="SelectionIndicator-Chart"> 122 122 <Grid> 123 123 <Grid.RowDefinitions> … … 128 128 <ColumnDefinition Width="*"></ColumnDefinition> 129 129 </Grid.ColumnDefinitions> 130 <d3:ChartPlotter Grid.Column="1" x:Name="SelectionChartPlotter" LegendVisible="False" EnableSmoothPanningForNumericAxes="True"> 131 <d3:Header Content="SelectionIndicator-Chart"/> 132 <d3:VerticalAxisTitle Content="SelectionIndicator" /> 133 <d3:HorizontalAxisTitle Content="SelectedNodes"/> 130 <d3:ChartPlotter Grid.Column="1" x:Name="SelectionChartPlotter" LegendVisible="False" EnableSmoothPanningForNumericAxes="True" > 131 <d3:VerticalAxisTitle Content="Qualität" /> 132 <d3:HorizontalAxisTitle Content="Evaluierungen"/> 134 133 </d3:ChartPlotter> 135 134 </Grid> -
branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/MainWindow.xaml.cs
r12833 r12840 5 5 using System.Threading.Tasks; 6 6 using System.Windows.Documents; 7 using System.Windows.Media; 7 8 using System.Xml.Serialization; 8 9 using Evaluation.ViewModel; … … 43 44 CenterWindowOnScreen(); 44 45 this.DataContext = vm = new EvaluationViewModel(); 45 vm.MaxLen = 23;46 vm.MaxIterations = 500000;46 vm.MaxLen = 17; 47 vm.MaxIterations = 300000; 47 48 vm.NrRuns = 20; 48 vm.MaxThreads = 5;49 vm.MaxThreads = 10; 49 50 } 50 51 … … 72 73 73 74 ds.SetXMapping(x => x.Iteration); 74 ds.SetYMapping(y => y.Quality );75 ds.SetYMapping(y => y.Quality / run.BestKnownQuality); 75 76 76 77 LineGraph graph = new LineGraph(ds); … … 82 83 private void DrawSelectionChart(Run run) 83 84 { 85 // quality line 86 List<FoundSolution> solutions = new List<FoundSolution>(run.FoundSolutions); 87 88 if (run.BestSolutionFoundAt < run.Evaluations) 89 { 90 solutions.Add(new FoundSolution(run.EndTime, run.Evaluations, run.BestQuality, run.BestSolution)); 91 } 92 93 var ds = new EnumerableDataSource<FoundSolution>(solutions); 94 95 96 ds.SetXMapping(x => x.Iteration); 97 ds.SetYMapping(y => y.Quality / run.BestKnownQuality); 98 99 LineGraph graph = new LineGraph(ds); 100 graph.StrokeThickness = 2; 101 graph.AddToPlotter(SelectionChartPlotter); 102 103 // selection indicator line 84 104 List<SelectionIndicator> selectionIndicators = new List<SelectionIndicator>(run.SelectionIndicators); 85 105 86 var ds = new EnumerableDataSource<SelectionIndicator>(selectionIndicators); 87 88 ds.SetXMapping(x => x.TotalSelections); 89 ds.SetYMapping(y => y.Indicator); 90 91 LineGraph graph = new LineGraph(ds); 92 106 var dssi = new EnumerableDataSource<SelectionIndicator>(selectionIndicators); 107 108 dssi.SetXMapping(x => x.Evaluation); 109 dssi.SetYMapping(y => y.Indicator); 110 111 graph = new LineGraph(dssi); 93 112 graph.StrokeThickness = 2; 113 graph.Stroke = Brushes.Red; 94 114 graph.AddToPlotter(SelectionChartPlotter); 95 115 } … … 182 202 policyInstance = new BoltzmannExplorationPolicy(2); 183 203 } 184 else if (policy == typeof 204 else if (policy == typeof(EpsGreedyPolicy)) 185 205 { 186 206 policyInstance = new EpsGreedyPolicy(vm.Epsylon); … … 228 248 } 229 249 Task.Run(() => 230 Parallel.For(0, vm.NrRuns, new ParallelOptions { MaxDegreeOfParallelism = vm.MaxThreads},250 Parallel.For(0, vm.NrRuns, new ParallelOptions { MaxDegreeOfParallelism = vm.MaxThreads }, 231 251 i => DoRun(vm.Runs[i]))); 232 252 } … … 434 454 private void ComboBoxPolicies_OnSelectionChanged(object sender, SelectionChangedEventArgs e) 435 455 { 436 if (vm.SelectedPolicy == typeof 456 if (vm.SelectedPolicy == typeof(EpsGreedyPolicy)) 437 457 { 438 458 TextBoxEpsylon.Visibility = Visibility.Visible; … … 445 465 } 446 466 } 467 468 private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e) 469 { 470 if (ChartSelector.SelectedItem == TabSelectionIndicator) 471 { 472 if (vm.SelectedRun != null) 473 { 474 if (vm.SelectedRun.RunState == RunState.Finished) 475 { 476 ClearSelectionChart(); 477 DrawSelectionChart(vm.SelectedRun); 478 } 479 } 480 } 481 else if (ChartSelector.SelectedItem == TabQualityChart) 482 { 483 if (vm.SelectedRun != null) 484 { 485 if (vm.SelectedRun.RunState == RunState.Finished) 486 { 487 ClearQualityChart(); 488 DrawQualityChart(vm.SelectedRun); 489 } 490 } 491 } 492 } 447 493 } 448 494 } -
branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/Run.cs
r12824 r12840 1 using HeuristicLab.Algorithms.Bandits; 1 using System.Diagnostics; 2 using HeuristicLab.Algorithms.Bandits; 2 3 using HeuristicLab.Algorithms.GrammaticalOptimization; 3 4 using HeuristicLab.Algorithms.MonteCarloTreeSearch; … … 41 42 RunState = RunState.NotStarted; 42 43 FoundSolutions = new List<FoundSolution>(); 43 CurrentSelectionIndicator = new SelectionIndicator(0, 0 );44 CurrentSelectionIndicator = new SelectionIndicator(0, 0, 0); 44 45 45 46 BestKnownQuality = problem.BestKnownQuality(maxLen); … … 60 61 { 61 62 MonteCarloTreeSearch mcts = (MonteCarloTreeSearch)solver; 62 mcts. NodeSelected += mcts_NodeSelected;63 } 64 } 65 66 private void mcts_ NodeSelected(int goodSelections, int totalSelections)67 { 68 CurrentSelectionIndicator.GoodSelections = goodSelections;69 CurrentSelectionIndicator.TotalSelections = totalSelections;70 this.OnPropertyChanged("CurrentSelectionIndicator");71 //CurrentSelectionIndicator = new SelectionIndicator(goodSelections, totalSelections);72 //selectionIndicators.Add(CurrentSelectionIndicator);63 mcts.IterationFinished += mcts_IterationFinished; 64 } 65 } 66 67 private void mcts_IterationFinished(int goodSelections, int totalSelections) 68 { 69 //CurrentSelectionIndicator.GoodSelections = goodSelections; 70 //CurrentSelectionIndicator.TotalSelections = totalSelections; 71 //this.OnPropertyChanged("CurrentSelectionIndicator"); 72 CurrentSelectionIndicator = new SelectionIndicator(goodSelections, totalSelections, selectionIndicators.Count); 73 selectionIndicators.Add(CurrentSelectionIndicator); 73 74 } 74 75 -
branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/SelectionIndicator.cs
r12824 r12840 13 13 14 14 } 15 public SelectionIndicator(int goodSelections, int totalSelections )15 public SelectionIndicator(int goodSelections, int totalSelections, int evaluation) 16 16 { 17 17 GoodSelections = goodSelections; 18 18 TotalSelections = totalSelections; 19 Evaluation = evaluation; 19 20 } 20 21 … … 22 23 public int TotalSelections { get; set; } 23 24 25 public int Evaluation { get; set; } 26 24 27 public double Indicator { get { return Math.Round((double)GoodSelections / TotalSelections, 5); } } 25 28 } -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/StandardGP.cs
r12827 r12840 31 31 TournamentGroupSize = 4; 32 32 MutationRate = 0.15; 33 MaxSolutionSize = 40;33 MaxSolutionSize = 201; 34 34 MaxSolutionDepth = 17; 35 35 this.saveAlg = saveAlg; -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch/MonteCarloTreeSearch.cs
r12832 r12840 43 43 } 44 44 45 public event Action<int, int> NodeSelected;46 47 protected virtual void On NodeSelectedChanged(int value, int selections)48 { 49 Raise NodeSelectedChanged(value, selections);50 } 51 52 private void Raise NodeSelectedChanged(int value, int selections)53 { 54 var handler = NodeSelected;45 public event Action<int, int> IterationFinished; 46 47 protected virtual void OnIterationFinishedChanged(int value, int selections) 48 { 49 RaiseIterationFinishedChanged(value, selections); 50 } 51 52 private void RaiseIterationFinishedChanged(int value, int selections) 53 { 54 var handler = IterationFinished; 55 55 if (handler != null) handler(value, selections); 56 56 } … … 66 66 goodSelections++; 67 67 } 68 69 OnNodeSelectedChanged(goodSelections, selections);70 68 } 71 69 … … 88 86 currentNode.GetChildActionInfos()); 89 87 currentNode = currentNode.children[currentActionIndex]; 90 //selections++;91 //CheckSelection(currentNode, selections);88 selections++; 89 CheckSelection(currentNode, selections); 92 90 } 93 91 … … 100 98 currentNode.children[behaviourPolicy.SelectAction(random, currentNode.GetChildActionInfos()) 101 99 ]; 102 //selections++;103 //CheckSelection(currentNode, selections);100 selections++; 101 CheckSelection(currentNode, selections); 104 102 } 105 103 if (currentNode.phrase.Length <= maxLen) … … 108 106 OnSolutionEvaluated(simulatedPhrase, quality); 109 107 108 OnIterationFinishedChanged(goodSelections, selections); 110 109 Propagate(currentNode, quality); 111 110 } -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch/MonteCarloTreeSearch_PruneLeaves.cs
r12832 r12840 35 35 currentNode.GetChildActionInfos()); 36 36 currentNode = currentNode.children[currentActionIndex]; 37 //selections++;38 //CheckSelection(currentNode, selections);37 selections++; 38 CheckSelection(currentNode, selections); 39 39 } 40 40 … … 56 56 currentNode.children[behaviourPolicy.SelectAction(random, currentNode.GetChildActionInfos()) 57 57 ]; 58 //selections++;59 //CheckSelection(currentNode, selections);58 selections++; 59 CheckSelection(currentNode, selections); 60 60 } 61 61 else … … 71 71 OnSolutionEvaluated(simulatedPhrase, quality); 72 72 73 OnIterationFinishedChanged(goodSelections, selections); 74 73 75 Propagate(currentNode, quality); 74 76 } -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs
r12815 r12840 217 217 public void GenerateProblemSolutions(int maxLen) 218 218 { 219 if (maxLen > 17)220 {221 throw new NotImplementedException();222 }223 219 solutions = new string[12]; 224 220 solutions[0] = "?(m)(ll?(m)(r))mr";
Note: See TracChangeset
for help on using the changeset viewer.