Changeset 9201
- Timestamp:
- 02/03/13 16:02:58 (12 years ago)
- Location:
- branches/UnloadJobs
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UnloadJobs
- Property svn:mergeinfo changed
/trunk/sources merged: 9190,9195
- Property svn:mergeinfo changed
-
branches/UnloadJobs/HeuristicLab.Core/3.3/Interfaces/ILookupParameter.cs
r7259 r9201 26 26 string ActualName { get; set; } 27 27 string TranslatedName { get; } 28 IExecutionContext ExecutionContext { get; set; } 28 29 event EventHandler ActualNameChanged; 29 30 } -
branches/UnloadJobs/HeuristicLab.Core/3.3/Interfaces/IParameter.cs
r7259 r9201 27 27 bool Hidden { get; set; } 28 28 IItem ActualValue { get; set; } 29 IExecutionContext ExecutionContext { get; set; }30 29 31 30 event EventHandler HiddenChanged; -
branches/UnloadJobs/HeuristicLab.DebugEngine.Views/3.3/OperationContentView.cs
r7966 r9201 61 61 private object GetParameterValue(IParameter param, IExecutionContext context, out string actualName) { 62 62 param = (IParameter)param.Clone(); 63 param.ExecutionContext = context; 63 ILookupParameter lookupParam = param as ILookupParameter; 64 if (lookupParam != null) { 65 actualName = lookupParam.ActualName; 66 lookupParam.ExecutionContext = context; 67 } else 68 actualName = null; 69 64 70 object value = null; 65 71 try { 66 72 value = param.ActualValue; 67 } catch (Exception x) { 73 } 74 catch (Exception x) { 68 75 value = x.Message; 69 76 } 70 ILookupParameter lookupParam = param as ILookupParameter;71 if (lookupParam != null)72 actualName = lookupParam.ActualName;73 else74 actualName = null;75 77 return value; 76 78 } -
branches/UnloadJobs/HeuristicLab.Operators/3.3/Operator.cs
r7259 r9201 22 22 using System; 23 23 using System.Drawing; 24 using System.Linq; 24 25 using System.Threading; 25 26 using HeuristicLab.Common; … … 119 120 ExecutionContext = context; 120 121 this.cancellationToken = cancellationToken; 121 foreach (I Parameter param in Parameters)122 foreach (ILookupParameter param in Parameters.OfType<ILookupParameter>()) 122 123 param.ExecutionContext = context; 123 124 IOperation next = Apply(); … … 126 127 } 127 128 finally { 128 foreach (I Parameter param in Parameters)129 foreach (ILookupParameter param in Parameters.OfType<ILookupParameter>()) 129 130 param.ExecutionContext = null; 130 131 ExecutionContext = null; -
branches/UnloadJobs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs
r7967 r9201 46 46 private void InitializeComponent() { 47 47 this.components = new System.ComponentModel.Container(); 48 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea 2= new System.Windows.Forms.DataVisualization.Charting.ChartArea();49 System.Windows.Forms.DataVisualization.Charting.Series series 2= new System.Windows.Forms.DataVisualization.Charting.Series();48 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); 49 System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); 50 50 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RunCollectionBubbleChartView)); 51 51 this.yJitterLabel = new System.Windows.Forms.Label(); … … 72 72 this.noRunsLabel = new System.Windows.Forms.Label(); 73 73 this.sizeTrackBar = new System.Windows.Forms.TrackBar(); 74 this.getDataAsMatrixToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 74 75 ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit(); 75 76 ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).BeginInit(); … … 188 189 // 189 190 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 190 191 192 chartArea 2.Name = "ChartArea1";193 this.chart.ChartAreas.Add(chartArea 2);191 | System.Windows.Forms.AnchorStyles.Left) 192 | System.Windows.Forms.AnchorStyles.Right))); 193 chartArea1.Name = "ChartArea1"; 194 this.chart.ChartAreas.Add(chartArea1); 194 195 this.chart.Location = new System.Drawing.Point(6, 30); 195 196 this.chart.Name = "chart"; 196 series 2.ChartArea = "ChartArea1";197 series 2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;198 series 2.IsVisibleInLegend = false;199 series 2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;200 series 2.Name = "Bubbles";201 series 2.YValuesPerPoint = 2;202 this.chart.Series.Add(series 2);197 series1.ChartArea = "ChartArea1"; 198 series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; 199 series1.IsVisibleInLegend = false; 200 series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; 201 series1.Name = "Bubbles"; 202 series1.YValuesPerPoint = 2; 203 this.chart.Series.Add(series1); 203 204 this.chart.Size = new System.Drawing.Size(843, 425); 204 205 this.chart.TabIndex = 16; … … 215 216 this.openBoxPlotViewToolStripMenuItem.Text = "Open BoxPlot View"; 216 217 this.openBoxPlotViewToolStripMenuItem.Click += new System.EventHandler(this.openBoxPlotViewToolStripMenuItem_Click); 217 // 218 // 218 219 // hideRunToolStripMenuItem 219 // 220 // 220 221 this.hideRunToolStripMenuItem.Name = "hideRunToolStripMenuItem"; 221 222 this.hideRunToolStripMenuItem.Size = new System.Drawing.Size(256, 22); 222 223 this.hideRunToolStripMenuItem.Text = "Hide Run"; 223 this.hideRunToolStripMenuItem.Click += new System.EventHandler( hideRunToolStripMenuItem_Click);224 this.hideRunToolStripMenuItem.Click += new System.EventHandler(this.hideRunToolStripMenuItem_Click); 224 225 // 225 226 // zoomButton … … 325 326 this.sizeTrackBar.Value = 10; 326 327 this.sizeTrackBar.ValueChanged += new System.EventHandler(this.sizeTrackBar_ValueChanged); 328 // 329 // ToolStripMenuItem 330 // 331 this.getDataAsMatrixToolStripMenuItem.Name = "getDataAsMatrixToolStripMenuItem"; 332 this.getDataAsMatrixToolStripMenuItem.Size = new System.Drawing.Size(256, 22); 333 this.getDataAsMatrixToolStripMenuItem.Text = "Get Data as Matrix"; 334 this.getDataAsMatrixToolStripMenuItem.Click += new System.EventHandler(this.getDataAsMatrixToolStripMenuItem_Click); 327 335 // 328 336 // RunCollectionBubbleChartView … … 386 394 private System.Windows.Forms.Button colorYAxisButton; 387 395 private System.Windows.Forms.TrackBar sizeTrackBar; 396 private System.Windows.Forms.ToolStripMenuItem getDataAsMatrixToolStripMenuItem; 388 397 } 389 398 } -
branches/UnloadJobs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r9068 r9201 20 20 #endregion 21 21 22 using HeuristicLab.Common; 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.MainForm; 26 using HeuristicLab.MainForm.WindowsForms; 22 27 using System; 23 28 using System.Collections.Generic; … … 26 31 using System.Windows.Forms; 27 32 using System.Windows.Forms.DataVisualization.Charting; 28 using HeuristicLab.Common;29 using HeuristicLab.Core;30 using HeuristicLab.Data;31 using HeuristicLab.MainForm;32 using HeuristicLab.MainForm.WindowsForms;33 33 34 34 namespace HeuristicLab.Optimization.Views { … … 58 58 chart.ContextMenuStrip.Items.Insert(0, hideRunToolStripMenuItem); 59 59 chart.ContextMenuStrip.Items.Insert(1, openBoxPlotViewToolStripMenuItem); 60 chart.ContextMenuStrip.Items.Add(getDataAsMatrixToolStripMenuItem); 60 61 chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening); 61 62 … … 688 689 boxplotView.Show(); 689 690 } 691 692 private void getDataAsMatrixToolStripMenuItem_Click(object sender, EventArgs e) { 693 int xCol = Matrix.ColumnNames.ToList().IndexOf(xAxisValue); 694 var grouped = new Dictionary<string, List<string>>(); 695 Dictionary<double, string> reverseMapping = null; 696 if (categoricalMapping.ContainsKey(xCol)) 697 reverseMapping = categoricalMapping[xCol].ToDictionary(x => x.Value, y => y.Key.ToString()); 698 foreach (var run in Content.Where(r => r.Visible)) { 699 var x = GetValue(run, xAxisValue); 700 var y = GetValue(run, yAxisValue); 701 if (!(x.HasValue && y.HasValue)) continue; 702 703 var category = reverseMapping == null ? x.Value.ToString() : reverseMapping[x.Value]; 704 if (!grouped.ContainsKey(category)) grouped[category] = new List<string>(); 705 grouped[category].Add(y.Value.ToString()); 706 } 707 708 if (!grouped.Any()) return; 709 var matrix = new StringMatrix(grouped.Values.Max(x => x.Count), grouped.Count) { 710 ColumnNames = grouped.Keys.ToArray() 711 }; 712 int i = 0; 713 foreach (var col in matrix.ColumnNames) { 714 int j = 0; 715 foreach (var y in grouped[col]) 716 matrix[j++, i] = y; 717 i++; 718 } 719 720 MainFormManager.MainForm.ShowContent(matrix); 721 } 690 722 #endregion 691 723 -
branches/UnloadJobs/HeuristicLab.Parameters/3.3/LookupParameter.cs
r7259 r9201 21 21 22 22 using System; 23 using System.Threading; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 31 32 [Item("LookupParameter", "A parameter whose value is retrieved from or written to a scope.")] 32 33 [StorableClass] 33 public class LookupParameter<T> : Parameter, I LookupParameter<T> where T : class, IItem {34 public class LookupParameter<T> : Parameter, IStatefulItem, ILookupParameter<T> where T : class, IItem { 34 35 [Storable] 35 36 private string actualName; … … 59 60 } 60 61 62 private Lazy<ThreadLocal<IItem>> cachedActualValues; 63 private IItem CachedActualValue { 64 get { return cachedActualValues.Value.Value; } 65 } 66 67 private Lazy<ThreadLocal<IExecutionContext>> executionContexts; 68 public IExecutionContext ExecutionContext { 69 get { return executionContexts.Value.Value; } 70 set { 71 if (value != executionContexts.Value.Value) { 72 executionContexts.Value.Value = value; 73 cachedActualValues.Value.Value = null; 74 } 75 } 76 } 77 61 78 [StorableConstructor] 62 protected LookupParameter(bool deserializing) : base(deserializing) { } 79 protected LookupParameter(bool deserializing) 80 : base(deserializing) { 81 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 82 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 83 } 63 84 protected LookupParameter(LookupParameter<T> original, Cloner cloner) 64 85 : base(original, cloner) { 65 86 actualName = original.actualName; 87 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 88 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 66 89 } 67 90 public LookupParameter() … … 69 92 this.actualName = Name; 70 93 this.Hidden = true; 94 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 95 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 71 96 } 72 97 public LookupParameter(string name) … … 74 99 this.actualName = Name; 75 100 this.Hidden = true; 101 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 102 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 76 103 } 77 104 public LookupParameter(string name, string description) … … 79 106 this.actualName = Name; 80 107 this.Hidden = true; 108 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 109 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 81 110 } 82 111 public LookupParameter(string name, string description, string actualName) … … 84 113 this.actualName = string.IsNullOrWhiteSpace(actualName) ? Name : actualName; 85 114 this.Hidden = true; 115 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 116 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 86 117 } 87 118 … … 132 163 } 133 164 protected override IItem GetActualValue() { 165 if (CachedActualValue != null) return CachedActualValue; 134 166 string name; 135 167 // try to get value from context stack … … 146 178 typeof(T).GetPrettyName()) 147 179 ); 180 cachedActualValues.Value.Value = var.Value; 148 181 return var.Value; 149 182 } … … 156 189 typeof(T).GetPrettyName()) 157 190 ); 191 cachedActualValues.Value.Value = value; 192 158 193 // try to set value in context stack 159 194 string name; … … 175 210 } 176 211 212 public virtual void InitializeState() { 213 } 214 public virtual void ClearState() { 215 if (cachedActualValues.IsValueCreated) { 216 cachedActualValues.Value.Dispose(); 217 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 218 } 219 if (executionContexts.IsValueCreated) { 220 executionContexts.Value.Dispose(); 221 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication); 222 } 223 } 224 177 225 public event EventHandler ActualNameChanged; 178 226 protected virtual void OnActualNameChanged() { -
branches/UnloadJobs/HeuristicLab.Parameters/3.3/Parameter.cs
r7259 r9201 22 22 using System; 23 23 using System.Drawing; 24 using System.Threading;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; … … 33 32 [Item("Parameter", "A base class for parameters.")] 34 33 [StorableClass] 35 public abstract class Parameter : NamedItem, IParameter , IStatefulItem{34 public abstract class Parameter : NamedItem, IParameter { 36 35 public override Image ItemImage { 37 36 get { … … 67 66 } 68 67 69 private Lazy<ThreadLocal<IItem>> cachedActualValues;70 68 public IItem ActualValue { 71 get { 72 if (cachedActualValues.Value.Value == null) cachedActualValues.Value.Value = GetActualValue(); 73 return cachedActualValues.Value.Value; 74 } 75 set { 76 cachedActualValues.Value.Value = value; 77 SetActualValue(value); 78 } 79 } 80 private Lazy<ThreadLocal<IExecutionContext>> executionContexts; 81 public IExecutionContext ExecutionContext { 82 get { return executionContexts.Value.Value; } 83 set { 84 if (value != executionContexts.Value.Value) { 85 executionContexts.Value.Value = value; 86 cachedActualValues.Value.Value = null; 87 } 88 } 69 get { return GetActualValue(); } 70 set { SetActualValue(value); } 89 71 } 90 72 … … 92 74 protected Parameter(bool deserializing) 93 75 : base(deserializing) { 94 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);95 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);96 76 } 97 77 protected Parameter(Parameter original, Cloner cloner) … … 99 79 dataType = original.dataType; 100 80 hidden = original.hidden; 101 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);102 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);103 81 } 104 82 protected Parameter() … … 106 84 dataType = typeof(IItem); 107 85 hidden = false; 108 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);109 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);110 86 } 111 87 protected Parameter(string name, Type dataType) … … 114 90 this.dataType = dataType; 115 91 hidden = false; 116 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);117 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);118 92 } 119 93 protected Parameter(string name, string description, Type dataType) … … 122 96 this.dataType = dataType; 123 97 hidden = false; 124 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);125 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);126 }127 128 public virtual void InitializeState() { }129 public virtual void ClearState() {130 cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);131 executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);132 98 } 133 99 -
branches/UnloadJobs/HeuristicLab.Parameters/3.3/ScopeParameter.cs
r7259 r9201 21 21 22 22 using System; 23 using System.Threading; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 31 32 [Item("ScopeParameter", "A parameter which represents the current scope.")] 32 33 [StorableClass] 33 public class ScopeParameter : Parameter{34 public class ScopeParameter : LookupParameter<IScope> { 34 35 public new IScope ActualValue { 35 36 get { return ExecutionContext.Scope; } 36 37 } 38 37 39 38 40 [StorableConstructor] … … 40 42 protected ScopeParameter(ScopeParameter original, Cloner cloner) : base(original, cloner) { } 41 43 public ScopeParameter() 42 : base("Anonymous" , typeof(IScope)) {44 : base("Anonymous") { 43 45 this.Hidden = true; 44 46 } 45 47 public ScopeParameter(string name) 46 : base(name , typeof(IScope)) {48 : base(name) { 47 49 this.Hidden = true; 48 50 } 49 51 public ScopeParameter(string name, string description) 50 : base(name, description , typeof(IScope)) {52 : base(name, description) { 51 53 this.Hidden = true; 52 54 }
Note: See TracChangeset
for help on using the changeset viewer.