Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13492


Ignore:
Timestamp:
01/10/16 17:13:27 (8 years ago)
Author:
aballeit
Message:

#2283 UCT parameter c

Location:
branches/HeuristicLab.Problems.GrammaticalOptimization
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/MainWindow.xaml

    r12840 r13492  
    115115                                        <d3:Header Content="Quality-Chart"/>
    116116                                        <d3:VerticalAxisTitle Content="Qualität" />
    117                                         <d3:HorizontalAxisTitle Content="Evaluierungen"/>
     117                                        <d3:HorizontalAxisTitle Content="Iterationen"/>
    118118                                    </d3:ChartPlotter>
    119119                                </Grid>
     
    130130                                    <d3:ChartPlotter Grid.Column="1" x:Name="SelectionChartPlotter" LegendVisible="False" EnableSmoothPanningForNumericAxes="True" >
    131131                                        <d3:VerticalAxisTitle Content="Qualität" />
    132                                         <d3:HorizontalAxisTitle Content="Evaluierungen"/>
     132                                        <d3:HorizontalAxisTitle Content="Iterationen"/>
    133133                                    </d3:ChartPlotter>
    134134                                </Grid>
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/MainWindow.xaml.cs

    r12840 r13492  
    142142                    run.TreeInfos = mctsSolver.GetTreeInfos();
    143143
    144                     //byte[] output = mctsSolver.GenerateSvg();
    145                     //if (output != null && output.Length > 0)
    146                     //{
    147                     //    run.SvgFile = string.Format("MCTS_SVG_#{0}_{1}.svg", run.RunNumber, DateTime.Now.Ticks);
    148                     //    File.WriteAllBytes(run.SvgFile, mctsSolver.GenerateSvg());
    149                     //}
     144                    byte[] output = mctsSolver.GenerateSvg();
     145                    if (output != null && output.Length > 0)
     146                    {
     147                        run.SvgFile = string.Format("MCTS_SVG_#{0}_{1}.svg", run.RunNumber, DateTime.Now.Ticks);
     148                        File.WriteAllBytes(run.SvgFile, mctsSolver.GenerateSvg());
     149                    }
    150150                    mctsSolver.FreeAll();
    151151                }
     
    192192            if (policy == typeof(UCTPolicy))
    193193            {
    194                 policyInstance = new UCTPolicy();
     194                policyInstance = new UCTPolicy(vm.Epsylon);
    195195            }
    196196            else if (policy == typeof(ThresholdAscentPolicy))
     
    457457            {
    458458                TextBoxEpsylon.Visibility = Visibility.Visible;
     459                TextBoxEpsylon.Text = Math.Sqrt(1).ToString();
     460                TextBlockEpsylon.Text = "Epsylon";
     461                TextBlockEpsylon.Visibility = Visibility.Visible;
     462            }
     463            else if (vm.SelectedPolicy == typeof (UCTPolicy))
     464            {
     465                TextBoxEpsylon.Visibility = Visibility.Visible;
     466                TextBoxEpsylon.Text = Math.Sqrt(2).ToString();
     467                TextBlockEpsylon.Text = "c";
    459468                TextBlockEpsylon.Visibility = Visibility.Visible;
    460469            }
     
    468477        private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
    469478        {
    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                     }
     479            if (vm.SelectedRun != null && vm.SelectedRun.RunState == RunState.Finished)
     480            {
     481
     482                if (ChartSelector.SelectedItem == TabSelectionIndicator)
     483                {
     484
     485                    ClearSelectionChart();
     486                    DrawSelectionChart(vm.SelectedRun);
     487                }
     488                else if (ChartSelector.SelectedItem == TabQualityChart)
     489                {
     490
     491                    ClearQualityChart();
     492                    DrawQualityChart(vm.SelectedRun);
     493                }
     494                else if (ChartSelector.SelectedItem == TabItemTree)
     495                {
     496                    DrawTreeChart(vm.SelectedRun);
    490497                }
    491498            }
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/UCTPolicy.cs

    r12503 r13492  
    1212    private readonly double c;
    1313
    14     public UCTPolicy(double c = 1.0) {
     14      // c = sqrt(2)
     15    public UCTPolicy(double c = 1.41421356237)
     16    {
    1517      this.c = c;
    1618    }
     
    3032          q = double.PositiveInfinity;
    3133        } else {
    32             q = aInfo.SumReward / aInfo.Tries + 2.0 * c * Math.Sqrt(Math.Log(totalTries) / aInfo.Tries);
     34            q = aInfo.SumReward / aInfo.Tries + c * Math.Sqrt(Math.Log(totalTries) / aInfo.Tries);
    3335        }
    3436        if (q > bestQ) {
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/StandardGP.cs

    r12840 r13492  
    3030      PopulationSize = 1000;
    3131      TournamentGroupSize = 4;
    32       MutationRate = 0.15;
    33       MaxSolutionSize = 201;
     32      MutationRate = 0.05;
     33      MaxSolutionSize = 40;
    3434      MaxSolutionDepth = 17;
    3535      this.saveAlg = saveAlg;
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch/Base/TreeNode.cs

    r12832 r13492  
    1 using System;
     1using HeuristicLab.Algorithms.Bandits;
    22using System.Collections.Generic;
    33using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using HeuristicLab.Algorithms.Bandits;
    7 using HeuristicLab.Algorithms.Bandits.BanditPolicies;
    8 using HeuristicLab.Problems.GrammaticalOptimization;
    94
    105namespace HeuristicLab.Algorithms.MonteCarloTreeSearch.Base
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch/MonteCarloTreeSearch.cs

    r12840 r13492  
    8686                        currentNode.GetChildActionInfos());
    8787                    currentNode = currentNode.children[currentActionIndex];
    88                     selections++;
    89                     CheckSelection(currentNode, selections);
     88                    //selections++;
     89                    //CheckSelection(currentNode, selections);
    9090                }
    9191
     
    9898                        currentNode.children[behaviourPolicy.SelectAction(random, currentNode.GetChildActionInfos())
    9999                            ];
    100                     selections++;
    101                     CheckSelection(currentNode, selections);
     100                    //selections++;
     101                    //CheckSelection(currentNode, selections);
    102102                }
    103103                if (currentNode.phrase.Length <= maxLen)
     
    223223        public byte[] GenerateSvg()
    224224        {
    225             if (GetTreeInfos().TotalNodes < 1000)
     225            if (GetTreeInfos().TotalNodes < 6000)
    226226            {
    227227                IGetStartProcessQuery getStartProcessQuery = new GetStartProcessQuery();
     
    233233                    getProcessStartInfoQuery,
    234234                    registerLayoutPluginCommand);
    235                 wrapper.GraphvizPath = @"../../../Graphviz2.38/bin";
     235                wrapper.GraphvizPath = @"../../../../Graphviz2.38/bin";
    236236                StringBuilder dotFile = new StringBuilder("digraph {");
    237237                dotFile.AppendLine();
     
    279279                        foreach (TreeNode childNode in currentNode.children)
    280280                        {
    281                             toDoNodes.Add(childNode);
    282                             // declare node
    283 
    284                             string hexColor = GetHexNodeColor(Color.White, Color.OrangeRed, childNode.actionInfo.Value);
    285                             dotFile.AppendLine(
    286                                 string.Format("{0} [label=\"{1}\\n{2:0.00}/{3}\", style=filled, fillcolor=\"{4}\"]",
    287                                     childNode.GetHashCode(),
    288                                     childNode.phrase, childNode.actionInfo.Value, childNode.actionInfo.Tries, hexColor));
    289                             // add edge
    290                             dotFile.AppendLine(string.Format("{0} -> {1}", currentNode.GetHashCode(),
    291                                 childNode.GetHashCode()));
     281                            if (childNode.actionInfo.Tries > 1)
     282                            {
     283                                toDoNodes.Add(childNode);
     284                                // declare node
     285
     286                                string hexColor = GetHexNodeColor(Color.White, Color.OrangeRed,
     287                                    childNode.actionInfo.Value);
     288                                dotFile.AppendLine(
     289                                    string.Format("{0} [label=\"{1}\\n{2:0.00}/{3}\", style=filled, fillcolor=\"{4}\"]",
     290                                        childNode.GetHashCode(),
     291                                        childNode.phrase, childNode.actionInfo.Value, childNode.actionInfo.Tries,
     292                                        hexColor));
     293                                // add edge
     294                                dotFile.AppendLine(string.Format("{0} -> {1}", currentNode.GetHashCode(),
     295                                    childNode.GetHashCode()));
     296                            }
    292297                        }
    293298                    }
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch/MonteCarloTreeSearch_PruneLeaves.cs

    r12840 r13492  
    4848                        // already removed all child nodes so remove it too..
    4949                        currentNode.parent.RemoveChildren(currentNode);
     50                        i--;
    5051                        continue;
    5152                    }
     
    7576                    Propagate(currentNode, quality);
    7677                }
     78                else
     79                {
     80                    i--;
     81
     82                }
    7783            }
    7884        }
Note: See TracChangeset for help on using the changeset viewer.