Changeset 14908 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem
- Timestamp:
- 05/02/17 22:03:01 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/BenchmarkSuitePushSolutionView.cs
r14897 r14908 37 37 38 38 ~BenchmarkSuitePushSolutionView() { 39 this.interpreter.Dispose();39 interpreter.Dispose(); 40 40 } 41 41 42 42 private void InitEvents() { 43 this.exampleComboBox.SelectedIndexChanged += this.SelectedExampleIndexChanged;44 this.pushDebugger.OnReset += this.PushDebuggerReset;43 exampleComboBox.SelectedIndexChanged += SelectedExampleIndexChanged; 44 pushDebugger.OnReset += PushDebuggerReset; 45 45 } 46 46 47 47 private void PushDebuggerReset(object sender, IPushInterpreter interpreter) { 48 if ( this.exampleComboBox.SelectedIndex < 0) return;49 50 var example = Evaluator.Data.Examples[ this.exampleComboBox.SelectedIndex];48 if (exampleComboBox.SelectedIndex < 0) return; 49 50 var example = Evaluator.Data.Examples[exampleComboBox.SelectedIndex]; 51 51 52 52 interpreter.BooleanStack.Push(example.InputBoolean); … … 62 62 63 63 private void SelectedExampleIndexChanged(object sender, EventArgs e) { 64 this.pushDebugger.ResetDebugging();64 pushDebugger.ResetDebugging(); 65 65 } 66 66 … … 80 80 81 81 protected override void OnContentChanged() { 82 if ( this.Content == null) return;83 84 this.Name = "Push Solution";85 this.nameTextBox.Text = this.Name;86 87 this.pool = new PushInterpreterPool(this.Content.Config);88 89 if ( this.interpreter != null) {90 this.interpreter.Dispose();91 } 92 93 this.interpreter = this.pool.Create(this.Content.Random);94 this.UpdateExamples(Evaluator.Data);95 96 if ( this.exampleComboBox.SelectedIndex < 0) {97 this.exampleComboBox.SelectedIndex = 0; // Triggers ResetDebugging via event98 } 99 100 this.InitResultGrid();101 this.pushDebugger.Content = this.Content;82 if (Content == null) return; 83 84 Name = "Push Solution"; 85 nameTextBox.Text = Name; 86 87 pool = new PushInterpreterPool(Content.Config); 88 89 if (interpreter != null) { 90 interpreter.Dispose(); 91 } 92 93 interpreter = pool.Create(Content.Random); 94 UpdateExamples(Evaluator.Data); 95 96 if (exampleComboBox.SelectedIndex < 0) { 97 exampleComboBox.SelectedIndex = 0; // Triggers ResetDebugging via event 98 } 99 100 InitResultGrid(); 101 pushDebugger.Content = Content; 102 102 } 103 103 104 104 private void InitResultGrid() { 105 this.resultsDataGrid.Columns.Clear();106 this.resultsDataGrid.Rows.Clear();105 resultsDataGrid.Columns.Clear(); 106 resultsDataGrid.Rows.Clear(); 107 107 108 108 var cellTemplate = new DataGridViewTextBoxCell(); … … 118 118 119 119 column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; 120 this.resultsDataGrid.Columns.Add(column);120 resultsDataGrid.Columns.Add(column); 121 121 } 122 122 … … 139 139 outputColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; 140 140 141 this.resultsDataGrid.Columns.Add(estimatedOutputColumn);142 this.resultsDataGrid.Columns.Add(outputColumn);141 resultsDataGrid.Columns.Add(estimatedOutputColumn); 142 resultsDataGrid.Columns.Add(outputColumn); 143 143 } 144 144 … … 158 158 relativeDiffColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; 159 159 160 this.resultsDataGrid.Columns.Add(absoluteDiffColumn);161 this.resultsDataGrid.Columns.Add(relativeDiffColumn);162 163 using (var pushInterpreter = this.pool.Create(this.Content.Random)) {160 resultsDataGrid.Columns.Add(absoluteDiffColumn); 161 resultsDataGrid.Columns.Add(relativeDiffColumn); 162 163 using (var pushInterpreter = pool.Create(Content.Random)) { 164 164 for (var i = 0; i < data.Examples.Length; i++) { 165 165 var example = data.Examples[i]; … … 169 169 170 170 row.HeaderCell.Value = row.Index + 1; 171 row.CreateCells( this.resultsDataGrid);171 row.CreateCells(resultsDataGrid); 172 172 173 173 for (var j = 0; j < data.InputArgumentTypes.Length; j++) { … … 177 177 for (var j = 0; j < data.OutputArgumentTypes.Length; j++) { 178 178 row.Cells[data.InputArgumentTypes.Length + j * 2].Value = ViewHelper.StringifyOutput(data.OutputArgumentTypes[j], example, Separator); 179 row.Cells[data.InputArgumentTypes.Length + j * 2 + 1].Value = this.StringifyResult(data.OutputArgumentTypes[j], pushInterpreter, example, Separator);179 row.Cells[data.InputArgumentTypes.Length + j * 2 + 1].Value = StringifyResult(data.OutputArgumentTypes[j], pushInterpreter, example, Separator); 180 180 } 181 181 … … 183 183 row.Cells[data.TotalArgumentCount + 2].Value = relativeDiff + "%"; 184 184 185 this.resultsDataGrid.Rows.Add(row);185 resultsDataGrid.Rows.Add(row); 186 186 pushInterpreter.Reset(); 187 187 } … … 192 192 switch (type) { 193 193 case ExampleArgumentType.Integer: 194 case ExampleArgumentType.IntegerVector: return interpreter.IntegerStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.IntegerStack.Peek( this.GetCount(interpreter.IntegerStack, example.OutputInteger)));194 case ExampleArgumentType.IntegerVector: return interpreter.IntegerStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.IntegerStack.Peek(GetCount(interpreter.IntegerStack, example.OutputInteger))); 195 195 196 196 case ExampleArgumentType.Float: 197 case ExampleArgumentType.FloatVector: return interpreter.FloatStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.FloatStack.Peek( this.GetCount(interpreter.FloatStack, example.OutputFloat)).Select(d => d.ToString(CultureInfo.CurrentUICulture)));197 case ExampleArgumentType.FloatVector: return interpreter.FloatStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.FloatStack.Peek(GetCount(interpreter.FloatStack, example.OutputFloat)).Select(d => d.ToString(CultureInfo.CurrentUICulture))); 198 198 199 199 case ExampleArgumentType.Boolean: return interpreter.BooleanStack.IsEmpty ? EmptySign : interpreter.BooleanStack.Top.ToString(); … … 201 201 202 202 case ExampleArgumentType.String: 203 case ExampleArgumentType.StringVector: return interpreter.StringStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.StringStack.Peek( this.GetCount(interpreter.StringStack, example.OutputString)));203 case ExampleArgumentType.StringVector: return interpreter.StringStack.IsEmpty ? EmptySign : string.Join(valueSeparator, interpreter.StringStack.Peek(GetCount(interpreter.StringStack, example.OutputString))); 204 204 default: return string.Empty; 205 205 } … … 211 211 212 212 private void UpdateExamples(ProblemData data) { 213 this.exampleComboBox.Items.Clear();213 exampleComboBox.Items.Clear(); 214 214 if (data == null) return; 215 215 … … 220 220 221 221 foreach (var str in stringRepresentations) { 222 this.exampleComboBox.Items.Add(str);222 exampleComboBox.Items.Add(str); 223 223 } 224 224 } -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/BenchmarkSuite/PushBenchmarkSuiteEvaluator.cs
r14907 r14908 69 69 70 70 public void LoadData(ProblemData data) { 71 this.Data = data;71 Data = data; 72 72 73 73 DataBounds.TrainingRange.Start = 0; -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushProblem.cs
r14897 r14908 72 72 73 73 private void EnabledExpressionsChanged(object sender, EnabledExpressionsChangedEventArgs e) { 74 this.Encoding.Bounds[0, 1] = config.EnabledExpressions.Count;75 this.Encoding.BoundsParameter.Value[0, 1] = config.EnabledExpressions.Count;74 Encoding.Bounds[0, 1] = config.EnabledExpressions.Count; 75 Encoding.BoundsParameter.Value[0, 1] = config.EnabledExpressions.Count; 76 76 } 77 77 … … 228 228 public IValueParameter<IntValue> MaxPointsInProgramParameter 229 229 { 230 get { return (IValueParameter<IntValue>) this.Parameters[MaxPointsInProgramParameterName]; }230 get { return (IValueParameter<IntValue>)Parameters[MaxPointsInProgramParameterName]; } 231 231 } 232 232 … … 250 250 public IValueParameter<IntValue> MinPointsInProgramParameter 251 251 { 252 get { return (IValueParameter<IntValue>) this.Parameters[MinPointsInProgramParameterName]; }252 get { return (IValueParameter<IntValue>)Parameters[MinPointsInProgramParameterName]; } 253 253 } 254 254 … … 287 287 public IValueParameter<BoolValue> TopLevelPushCodeParameter 288 288 { 289 get { return (IValueParameter<BoolValue>) this.Parameters[TopLevelPushCodeParameterName]; }289 get { return (IValueParameter<BoolValue>)Parameters[TopLevelPushCodeParameterName]; } 290 290 } 291 291 … … 305 305 public IValueParameter<BoolValue> TopLevelPopCodeParameter 306 306 { 307 get { return (IValueParameter<BoolValue>) this.Parameters[TopLevelPopCodeParameterName]; }307 get { return (IValueParameter<BoolValue>)Parameters[TopLevelPopCodeParameterName]; } 308 308 } 309 309
Note: See TracChangeset
for help on using the changeset viewer.