Changeset 14744 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views
- Timestamp:
- 03/10/17 21:42:09 (8 years ago)
- 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 26 26 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PushProgramDebuggerView)); 27 27 this.execGroupBox = new System.Windows.Forms.GroupBox(); 28 this.execList = new System.Windows.Forms.List Box();28 this.execList = new System.Windows.Forms.ListView(); 29 29 this.integerGroupBox = new System.Windows.Forms.GroupBox(); 30 30 this.integerList = new System.Windows.Forms.ListBox(); … … 44 44 this.stepWidthBox = new System.Windows.Forms.NumericUpDown(); 45 45 this.runButton = new System.Windows.Forms.Button(); 46 this.skipNoopsCheckBox = new System.Windows.Forms.CheckBox(); 46 47 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 47 48 this.execGroupBox.SuspendLayout(); … … 83 84 | System.Windows.Forms.AnchorStyles.Left) 84 85 | 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); 88 87 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; 92 93 // 93 94 // integerGroupBox … … 254 255 // exampleComboBox 255 256 // 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) 258 258 | System.Windows.Forms.AnchorStyles.Right))); 259 259 this.exampleComboBox.FormattingEnabled = true; … … 325 325 this.runButton.UseVisualStyleBackColor = true; 326 326 // 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 // 327 340 // PushProgramDebuggerView 328 341 // 329 342 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 330 343 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 344 this.Controls.Add(this.skipNoopsCheckBox); 331 345 this.Controls.Add(this.runButton); 332 346 this.Controls.Add(this.stepWidthBox); … … 348 362 this.Controls.SetChildIndex(this.stepWidthBox, 0); 349 363 this.Controls.SetChildIndex(this.runButton, 0); 364 this.Controls.SetChildIndex(this.skipNoopsCheckBox, 0); 350 365 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 351 366 this.execGroupBox.ResumeLayout(false); … … 370 385 private System.Windows.Forms.GroupBox booleanGroupBox; 371 386 private System.Windows.Forms.GroupBox nameGroupBox; 372 private System.Windows.Forms.ListBox execList;373 387 private System.Windows.Forms.ListBox integerList; 374 388 private System.Windows.Forms.ListBox floatList; … … 383 397 private System.Windows.Forms.NumericUpDown stepWidthBox; 384 398 private System.Windows.Forms.Button runButton; 399 private System.Windows.Forms.CheckBox skipNoopsCheckBox; 400 private System.Windows.Forms.ListView execList; 385 401 } 386 402 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views/PushProgramDebuggerView.cs
r14727 r14744 8 8 using System.Linq; 9 9 10 using HeuristicLab.BenchmarkSuite .Problems;10 using HeuristicLab.BenchmarkSuite; 11 11 using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions; 12 12 using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter; 13 13 using HeuristicLab.Problems.ProgramSynthesis.Push.Problem; 14 using HeuristicLab.Random; 14 15 15 16 [View("Push Program Debugger")] 16 17 [Content(typeof(PushSolution), true)] 17 18 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 18 25 private const string exampleSplitter = " => "; 19 private Push GpInterpreter interpreter;26 private PushInterpreter interpreter; 20 27 21 28 public PushProgramDebuggerView() { … … 28 35 resetButton.Click += ResetButtonClick; 29 36 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() { 35 113 exampleComboBox.Enabled = !ReadOnly; 36 114 execList.Enabled = !ReadOnly; … … 40 118 floatList.Enabled = !ReadOnly; 41 119 booleanList.Enabled = !ReadOnly; 120 stepButton.Enabled = !ReadOnly; 121 runButton.Enabled = !ReadOnly; 122 resetButton.Enabled = !ReadOnly; 123 skipNoopsCheckBox.Enabled = !ReadOnly; 124 stepWidthBox.Enabled = !ReadOnly; 42 125 } 43 126 … … 54 137 55 138 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); 63 142 } 64 143 … … 70 149 71 150 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(); 73 159 } 74 160 … … 114 200 interpreter.Clear(); 115 201 116 var example = Content.Data .Examples[this.exampleComboBox.SelectedIndex];202 var example = Content.DataDescriptor.Examples[this.exampleComboBox.SelectedIndex]; 117 203 118 204 interpreter.BooleanStack.Push(example.InputBoolean); … … 120 206 interpreter.FloatStack.Push(example.InputFloat); 121 207 122 interpreter.Run( Content.Program, true);208 interpreter.Run(program, true); 123 209 stepWidthBox.Maximum = interpreter.ExecStack.Count; 124 210 … … 131 217 if (Content == null) return; 132 218 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); 136 224 137 225 if (this.exampleComboBox.SelectedIndex < 0) { … … 151 239 152 240 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(); 157 243 158 244 this.execGroupBox.Text = string.Format("Exec [{0}]", this.execList.Items.Count); … … 226 312 } 227 313 228 private void UpdateExamples(Data data) { 229 const string seperator = ", "; 314 private void UpdateExamples(IBenchmarkSuiteDataDescriptor data) { 315 if (data == null) return; 316 230 317 var stringRepresentations = data.Examples.Select(e => 231 string.Join( seperator, e.InputArgs) +318 string.Join(Separator, e.InputArgs) + 232 319 exampleSplitter + 233 string.Join( seperator, e.OutputArgs));320 string.Join(Separator, e.OutputArgs)); 234 321 235 322 exampleComboBox.Items.Clear(); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Views/PushProgramDebuggerView.resx
r14727 r14744 1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <root> 3 <!-- 4 Microsoft ResX Schema 5 3 <!-- 4 Microsoft ResX Schema 5 6 6 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 11 11 associated with the data types. 12 12 13 13 Example: 14 14 15 15 ... ado.net/XML headers & schema ... 16 16 <resheader name="resmimetype">text/microsoft-resx</resheader> … … 27 27 <comment>This is a comment</comment> 28 28 </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 31 31 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 37 37 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 41 41 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 45 45 read any of the formats listed below. 46 46 47 47 mimetype: application/x-microsoft.net.object.binary.base64 48 value : The object must be serialized with 48 value : The object must be serialized with 49 49 : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter 50 50 : and then encoded with base64 encoding. 51 51 52 52 mimetype: application/x-microsoft.net.object.soap.base64 53 value : The object must be serialized with 53 value : The object must be serialized with 54 54 : System.Runtime.Serialization.Formatters.Soap.SoapFormatter 55 55 : and then encoded with base64 encoding. 56 56 57 57 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 59 59 : using a System.ComponentModel.TypeConverter 60 60 : and then encoded with base64 encoding.
Note: See TracChangeset
for help on using the changeset viewer.