Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/01/17 09:28:34 (7 years ago)
Author:
pkimmesw
Message:

#2665 Fixed Benchmark Problem Definition, Converted LoopExpressions to stateless expressions, Added several unit test to ensure funcionality, Fixed UI bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views/PushDebuggerView.cs

    r14952 r15017  
    1515
    1616  public partial class PushDebuggerView : ItemView {
    17     private readonly IDictionary<StackTypes, ListBox> debugControlDict = new Dictionary<StackTypes, ListBox>();
     17    private readonly IDictionary<StackTypes, ListBox> debugListDict = new Dictionary<StackTypes, ListBox>();
     18    private readonly IDictionary<StackTypes, PushProgramTreeView> debugPushProgramDict = new Dictionary<StackTypes, PushProgramTreeView>();
    1819
    1920    private PooledPushInterpreter interpreter;
     
    157158
    158159    private void ClearDebugLists() {
    159       foreach (var list in debugControlDict.Values) {
     160      foreach (var list in debugListDict.Values) {
    160161        list.Items.Clear();
    161162      }
     163
     164      foreach (var treeView in debugPushProgramDict.Values) {
     165        treeView.Nodes.Clear();
     166      }
    162167    }
    163168
    164169    private void UpdateExecList() {
    165       execList.Items.Clear();
    166       var expressions = interpreter.ExecStack.AsEnumerable()
    167         .Reverse()
    168         .Select(e => e.StringRepresentation)
    169         .ToArray();
    170 
    171       execList.Items.AddRange(expressions);
    172       execGroupBox.Text = string.Format(GROUP_BOX_TEXT_STRING_FORMAT, Enum.GetName(typeof(StackTypes), StackTypes.Exec), interpreter.ExecStack.Count);
     170      execTreeView.LoadExpressions(interpreter.ExecStack.Reverse());
     171      exec2GroupBox.Text = string.Format(GROUP_BOX_TEXT_STRING_FORMAT, Enum.GetName(typeof(StackTypes), StackTypes.Exec), interpreter.ExecStack.Count);
    173172    }
    174173
    175174    private void InitDebugLists(IReadOnlyPushConfiguration config) {
    176       debugControlDict.Clear();
     175      debugListDict.Clear();
     176      debugPushProgramDict.Clear();
    177177
    178178      // 2 = ExecList + EmptyColumn which is required to fill empty space
     
    185185        if (stackType != StackTypes.Exec &&
    186186            ExpressionTable.GetExpressionsByStackTypes(stackType).Intersect(config.EnabledExpressions).Any()) {
    187           var list = CreateDebugList(stackType);
    188           debugControlDict.Add(stackType, list);
     187
     188          switch (stackType) {
     189            case StackTypes.Code:
     190              var treeView = CreatePushProgramTreeView(stackType);
     191              debugPushProgramDict.Add(stackType, treeView);
     192              break;
     193            default:
     194              var list = CreateDebugList(stackType);
     195              debugListDict.Add(stackType, list);
     196              break;
     197          }
    189198        }
    190199      }
    191200    }
    192201
     202    private PushProgramTreeView CreatePushProgramTreeView(StackTypes type) {
     203
     204      var treeView = new PushProgramTreeView {
     205        Dock = DockStyle.Fill
     206      };
     207
     208      AddStackControlToTableLayout(type, treeView, 400);
     209
     210      return treeView;
     211    }
     212
     213    private void AddStackControlToTableLayout(StackTypes type, Control control, int width) {
     214      var groupBox = CreateStackGroupBox(type);
     215      groupBox.Controls.Add(control);
     216
     217      debugTableLayout.ColumnCount++;
     218      debugTableLayout.ColumnStyles.Insert(1, new ColumnStyle(SizeType.Absolute, width));
     219      debugTableLayout.Controls.Add(groupBox);
     220      debugTableLayout.Controls.SetChildIndex(groupBox, 1);
     221    }
     222
    193223    private ListBox CreateDebugList(StackTypes type) {
    194       var groupBox = new GroupBox {
    195         Anchor = AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top,
    196         AutoSize = true,
    197         AutoSizeMode = AutoSizeMode.GrowAndShrink,
    198         Text = Enum.GetName(typeof(StackTypes), type)
    199       };
    200 
    201224      var list = new ListBox {
    202225        Dock = DockStyle.Fill
     
    227250      }
    228251
    229       groupBox.Controls.Add(list);
    230 
    231       var columnWidth = stackEntryType == typeof(Expression) ? 250 : 150;
    232 
    233       debugTableLayout.ColumnCount++;
    234       debugTableLayout.ColumnStyles.Insert(1, new ColumnStyle(SizeType.Absolute, columnWidth));
    235       debugTableLayout.Controls.Add(groupBox);
    236       debugTableLayout.Controls.SetChildIndex(groupBox, 1);
     252      AddStackControlToTableLayout(type, list, 150);
    237253
    238254      return list;
    239255    }
    240256
     257    private static GroupBox CreateStackGroupBox(StackTypes type) {
     258      return new GroupBox {
     259        Anchor = AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top,
     260        AutoSize = true,
     261        AutoSizeMode = AutoSizeMode.GrowAndShrink,
     262        Text = Enum.GetName(typeof(StackTypes), type)
     263      };
     264    }
    241265
    242266    private void UpdateDebugLists() {
     
    246270        return;
    247271
    248       foreach (var pair in debugControlDict) {
     272      foreach (var pair in debugPushProgramDict) {
    249273        var name = Enum.GetName(typeof(StackTypes), pair.Key);
    250         var items = InterpreterStackStringifier.StringifyStack(interpreter, pair.Key).ToArray();
     274        var stack = (IPushStack<Expression>)interpreter.Stacks[pair.Key];
     275
     276        pair.Value.AddExpressions(stack);
     277        ((GroupBox)pair.Value.Parent).Text = string.Format(GROUP_BOX_TEXT_STRING_FORMAT, name, pair.Value.Nodes.Count);
     278      }
     279
     280      foreach (var pair in debugListDict) {
     281        var name = Enum.GetName(typeof(StackTypes), pair.Key);
     282        var items = interpreter.StringifyStack(pair.Key).ToArray();
    251283
    252284        pair.Value.Items.AddRange(items);
Note: See TracChangeset for help on using the changeset viewer.