Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/10/17 21:42:09 (7 years ago)
Author:
pkimmesw
Message:

#2665 Renamings due to typos, ManagedPool tests, Skip Noops in Debugger

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views
Files:
3 edited

Legend:

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

    r14727 r14744  
    2626      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PushProgramDebuggerView));
    2727      this.execGroupBox = new System.Windows.Forms.GroupBox();
    28       this.execList = new System.Windows.Forms.ListBox();
     28      this.execList = new System.Windows.Forms.ListView();
    2929      this.integerGroupBox = new System.Windows.Forms.GroupBox();
    3030      this.integerList = new System.Windows.Forms.ListBox();
     
    4444      this.stepWidthBox = new System.Windows.Forms.NumericUpDown();
    4545      this.runButton = new System.Windows.Forms.Button();
     46      this.skipNoopsCheckBox = new System.Windows.Forms.CheckBox();
    4647      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    4748      this.execGroupBox.SuspendLayout();
     
    8384            | System.Windows.Forms.AnchorStyles.Left)
    8485            | System.Windows.Forms.AnchorStyles.Right)));
    85       this.execList.FormattingEnabled = true;
    86       this.execList.HorizontalScrollbar = true;
    87       this.execList.Location = new System.Drawing.Point(7, 20);
     86      this.execList.Location = new System.Drawing.Point(3, 16);
    8887      this.execList.Name = "execList";
    89       this.execList.SelectionMode = System.Windows.Forms.SelectionMode.None;
    90       this.execList.Size = new System.Drawing.Size(231, 602);
    91       this.execList.TabIndex = 0;
     88      this.execList.Size = new System.Drawing.Size(235, 605);
     89      this.execList.TabIndex = 1;
     90      this.execList.UseCompatibleStateImageBehavior = false;
     91      this.execList.View = System.Windows.Forms.View.List;
     92      this.execList.VirtualMode = true;
    9293      //
    9394      // integerGroupBox
     
    254255      // exampleComboBox
    255256      //
    256       this.exampleComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    257             | System.Windows.Forms.AnchorStyles.Left)
     257      this.exampleComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    258258            | System.Windows.Forms.AnchorStyles.Right)));
    259259      this.exampleComboBox.FormattingEnabled = true;
     
    325325      this.runButton.UseVisualStyleBackColor = true;
    326326      //
     327      // skipNoopsCheckBox
     328      //
     329      this.skipNoopsCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     330      this.skipNoopsCheckBox.AutoSize = true;
     331      this.skipNoopsCheckBox.Checked = true;
     332      this.skipNoopsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
     333      this.skipNoopsCheckBox.Location = new System.Drawing.Point(150, 704);
     334      this.skipNoopsCheckBox.Name = "skipNoopsCheckBox";
     335      this.skipNoopsCheckBox.Size = new System.Drawing.Size(81, 17);
     336      this.skipNoopsCheckBox.TabIndex = 11;
     337      this.skipNoopsCheckBox.Text = "Skip NOOP";
     338      this.skipNoopsCheckBox.UseVisualStyleBackColor = true;
     339      //
    327340      // PushProgramDebuggerView
    328341      //
    329342      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    330343      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     344      this.Controls.Add(this.skipNoopsCheckBox);
    331345      this.Controls.Add(this.runButton);
    332346      this.Controls.Add(this.stepWidthBox);
     
    348362      this.Controls.SetChildIndex(this.stepWidthBox, 0);
    349363      this.Controls.SetChildIndex(this.runButton, 0);
     364      this.Controls.SetChildIndex(this.skipNoopsCheckBox, 0);
    350365      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    351366      this.execGroupBox.ResumeLayout(false);
     
    370385    private System.Windows.Forms.GroupBox booleanGroupBox;
    371386    private System.Windows.Forms.GroupBox nameGroupBox;
    372     private System.Windows.Forms.ListBox execList;
    373387    private System.Windows.Forms.ListBox integerList;
    374388    private System.Windows.Forms.ListBox floatList;
     
    383397    private System.Windows.Forms.NumericUpDown stepWidthBox;
    384398    private System.Windows.Forms.Button runButton;
     399    private System.Windows.Forms.CheckBox skipNoopsCheckBox;
     400    private System.Windows.Forms.ListView execList;
    385401  }
    386402}
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views/PushProgramDebuggerView.cs

    r14727 r14744  
    88  using System.Linq;
    99
    10   using HeuristicLab.BenchmarkSuite.Problems;
     10  using HeuristicLab.BenchmarkSuite;
    1111  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
    1212  using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter;
    1313  using HeuristicLab.Problems.ProgramSynthesis.Push.Problem;
     14  using HeuristicLab.Random;
    1415
    1516  [View("Push Program Debugger")]
    1617  [Content(typeof(PushSolution), true)]
    1718  public partial class PushProgramDebuggerView : NamedItemView {
     19    private const string Separator = ", ";
     20    private PushProgram program;
     21
     22    private ListViewItem[] execListCache; //array to cache items for the virtual list
     23    private int firstExecListItemIndex; //stores the index of the first item in the cache
     24
    1825    private const string exampleSplitter = " => ";
    19     private PushGpInterpreter interpreter;
     26    private PushInterpreter interpreter;
    2027
    2128    public PushProgramDebuggerView() {
     
    2835      resetButton.Click += ResetButtonClick;
    2936      stepButton.Click += StepButtonClick;
    30     }
    31 
    32     protected override void OnReadOnlyChanged() {
    33       base.OnReadOnlyChanged();
    34 
     37
     38      execList.RetrieveVirtualItem += ExecListRetrieveVirtualItem;
     39      execList.CacheVirtualItems += ExecListCacheVirtualItems;
     40
     41      execList.View = View.Details;
     42      execList.HeaderStyle = ColumnHeaderStyle.Nonclickable;
     43      execList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.None);
     44      execList.Columns.Add(new ColumnHeader { Width = execList.Width - 40 });
     45      execList.VirtualMode = true;
     46      execList.VirtualListSize = 100;
     47    }
     48
     49    private void ExecListCacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) {
     50      //We've gotten a request to refresh the cache.
     51      //First check if it's really neccesary.
     52      if (execListCache != null &&
     53        e.StartIndex >= firstExecListItemIndex &&
     54        e.EndIndex <= firstExecListItemIndex + execListCache.Length) {
     55        //If the newly requested cache is a subset of the old cache,
     56        //no need to rebuild everything, so do nothing.
     57        return;
     58      }
     59
     60      //Now we need to rebuild the cache.
     61      UpdateListCache(e.StartIndex, e.EndIndex);
     62    }
     63
     64    private void ExecListRetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) {
     65      //check to see if the requested item is currently in the cache
     66      if (execListCache == null ||
     67        e.ItemIndex < firstExecListItemIndex ||
     68        e.ItemIndex >= firstExecListItemIndex + execListCache.Length) {
     69        UpdateListCache(e.ItemIndex, execList.VirtualListSize);
     70      }
     71
     72      e.Item = e.ItemIndex >= firstExecListItemIndex && e.ItemIndex < firstExecListItemIndex + execListCache.Length
     73          ? execListCache[e.ItemIndex - firstExecListItemIndex]
     74          : e.Item = new ListViewItem();
     75    }
     76
     77    private void UpdateListCache(int startIndex, int endIndex) {
     78      if (interpreter == null) {
     79        execListCache = new ListViewItem[0];
     80        return;
     81      }
     82
     83      this.firstExecListItemIndex = startIndex;
     84      var length = Math.Min(endIndex - startIndex + 1, interpreter.ExecStack.Count); //indexes are inclusive
     85      this.execListCache = new ListViewItem[length];
     86
     87      var expressions = this.interpreter.ExecStack.Peek(length);
     88
     89      //Fill the cache with the appropriate ListViewItems.
     90      for (var i = 0; i < length; i++)
     91        this.execListCache[i] = new ListViewItem(expressions[length - 1 - i].ToString());
     92
     93      execList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.None);
     94      execList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     95    }
     96
     97    //protected override void OnEnabledChanged(EventArgs e) {
     98    //  SetReadonlyFields();
     99    //}
     100
     101    //protected override void OnReadOnlyChanged() {
     102    //  base.OnReadOnlyChanged();
     103
     104    //  SetReadonlyFields();
     105    //}
     106
     107    //protected override void SetEnabledStateOfControls()
     108    //{
     109    //  SetReadonlyFields();
     110    //}
     111
     112    private void SetReadonlyFields() {
    35113      exampleComboBox.Enabled = !ReadOnly;
    36114      execList.Enabled = !ReadOnly;
     
    40118      floatList.Enabled = !ReadOnly;
    41119      booleanList.Enabled = !ReadOnly;
     120      stepButton.Enabled = !ReadOnly;
     121      runButton.Enabled = !ReadOnly;
     122      resetButton.Enabled = !ReadOnly;
     123      skipNoopsCheckBox.Enabled = !ReadOnly;
     124      stepWidthBox.Enabled = !ReadOnly;
    42125    }
    43126
     
    54137
    55138    private void SyncExecList() {
    56       execList.Items.RemoveAt(0);
    57 
    58       if (!interpreter.ExecStack.SequenceEqual(execList.Items.Cast<Expression>().Reverse())) {
    59         UpdateExecList();
    60       }
    61 
    62       this.execGroupBox.Text = string.Format("Exec [{0}]", this.execList.Items.Count);
     139      UpdateExecList();
     140
     141      this.execGroupBox.Text = string.Format("Exec [{0}]", this.interpreter.ExecStack.Count);
    63142    }
    64143
     
    70149
    71150      for (var i = 0; i < count; i++) {
    72         interpreter.Step();
     151        if (skipNoopsCheckBox.Checked) {
     152          bool noop;
     153
     154          do {
     155            noop = !interpreter.Step();
     156          }
     157          while (interpreter.CanStep && noop);
     158        } else interpreter.Step();
    73159      }
    74160
     
    114200      interpreter.Clear();
    115201
    116       var example = Content.Data.Examples[this.exampleComboBox.SelectedIndex];
     202      var example = Content.DataDescriptor.Examples[this.exampleComboBox.SelectedIndex];
    117203
    118204      interpreter.BooleanStack.Push(example.InputBoolean);
     
    120206      interpreter.FloatStack.Push(example.InputFloat);
    121207
    122       interpreter.Run(Content.Program, true);
     208      interpreter.Run(program, true);
    123209      stepWidthBox.Maximum = interpreter.ExecStack.Count;
    124210
     
    131217      if (Content == null) return;
    132218
    133       interpreter = Content.Pool.GetInstance(Content.Random);
    134 
    135       UpdateExamples(Content.Data);
     219      var random = Content.Random ?? new FastRandom();
     220      interpreter = new PushInterpreter(Content.Config, random);
     221      program = Content.IntegerVector.MapToPushProgram(Content.Config.EnabledExpressions);
     222
     223      UpdateExamples(Content.DataDescriptor);
    136224
    137225      if (this.exampleComboBox.SelectedIndex < 0) {
     
    151239
    152240    private void UpdateExecList() {
    153       execList.Items.Clear();
    154 
    155       foreach (var item in interpreter.ExecStack.Reverse())
    156         this.execList.Items.Add(item);
     241      UpdateListCache(0, execList.VirtualListSize);
     242      execList.Update();
    157243
    158244      this.execGroupBox.Text = string.Format("Exec [{0}]", this.execList.Items.Count);
     
    226312    }
    227313
    228     private void UpdateExamples(Data data) {
    229       const string seperator = ", ";
     314    private void UpdateExamples(IBenchmarkSuiteDataDescriptor data) {
     315      if (data == null) return;
     316
    230317      var stringRepresentations = data.Examples.Select(e =>
    231         string.Join(seperator, e.InputArgs) +
     318        string.Join(Separator, e.InputArgs) +
    232319        exampleSplitter +
    233         string.Join(seperator, e.OutputArgs));
     320        string.Join(Separator, e.OutputArgs));
    234321
    235322      exampleComboBox.Items.Clear();
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views/PushProgramDebuggerView.resx

    r14727 r14744  
    11<?xml version="1.0" encoding="utf-8"?>
    22<root>
    3   <!-- 
    4     Microsoft ResX Schema 
    5    
     3  <!--
     4    Microsoft ResX Schema
     5
    66    Version 2.0
    7    
    8     The primary goals of this format is to allow a simple XML format 
    9     that is mostly human readable. The generation and parsing of the 
    10     various data types are done through the TypeConverter classes 
     7
     8    The primary goals of this format is to allow a simple XML format
     9    that is mostly human readable. The generation and parsing of the
     10    various data types are done through the TypeConverter classes
    1111    associated with the data types.
    12    
     12
    1313    Example:
    14    
     14
    1515    ... ado.net/XML headers & schema ...
    1616    <resheader name="resmimetype">text/microsoft-resx</resheader>
     
    2727        <comment>This is a comment</comment>
    2828    </data>
    29                
    30     There are any number of "resheader" rows that contain simple 
     29
     30    There are any number of "resheader" rows that contain simple
    3131    name/value pairs.
    32    
    33     Each data row contains a name, and value. The row also contains a 
    34     type or mimetype. Type corresponds to a .NET class that support 
    35     text/value conversion through the TypeConverter architecture. 
    36     Classes that don't support this are serialized and stored with the 
     32
     33    Each data row contains a name, and value. The row also contains a
     34    type or mimetype. Type corresponds to a .NET class that support
     35    text/value conversion through the TypeConverter architecture.
     36    Classes that don't support this are serialized and stored with the
    3737    mimetype set.
    38    
    39     The mimetype is used for serialized objects, and tells the 
    40     ResXResourceReader how to depersist the object. This is currently not 
     38
     39    The mimetype is used for serialized objects, and tells the
     40    ResXResourceReader how to depersist the object. This is currently not
    4141    extensible. For a given mimetype the value must be set accordingly:
    42    
    43     Note - application/x-microsoft.net.object.binary.base64 is the format 
    44     that the ResXResourceWriter will generate, however the reader can 
     42
     43    Note - application/x-microsoft.net.object.binary.base64 is the format
     44    that the ResXResourceWriter will generate, however the reader can
    4545    read any of the formats listed below.
    46    
     46
    4747    mimetype: application/x-microsoft.net.object.binary.base64
    48     value   : The object must be serialized with 
     48    value   : The object must be serialized with
    4949            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
    5050            : and then encoded with base64 encoding.
    51    
     51
    5252    mimetype: application/x-microsoft.net.object.soap.base64
    53     value   : The object must be serialized with 
     53    value   : The object must be serialized with
    5454            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
    5555            : and then encoded with base64 encoding.
    5656
    5757    mimetype: application/x-microsoft.net.object.bytearray.base64
    58     value   : The object must be serialized into a byte array 
     58    value   : The object must be serialized into a byte array
    5959            : using a System.ComponentModel.TypeConverter
    6060            : and then encoded with base64 encoding.
Note: See TracChangeset for help on using the changeset viewer.