Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9201


Ignore:
Timestamp:
02/03/13 16:02:58 (11 years ago)
Author:
ascheibe
Message:

#2005 merged changes from trunk into branch

Location:
branches/UnloadJobs
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/UnloadJobs

  • branches/UnloadJobs/HeuristicLab.Core/3.3/Interfaces/ILookupParameter.cs

    r7259 r9201  
    2626    string ActualName { get; set; }
    2727    string TranslatedName { get; }
     28    IExecutionContext ExecutionContext { get; set; }
    2829    event EventHandler ActualNameChanged;
    2930  }
  • branches/UnloadJobs/HeuristicLab.Core/3.3/Interfaces/IParameter.cs

    r7259 r9201  
    2727    bool Hidden { get; set; }
    2828    IItem ActualValue { get; set; }
    29     IExecutionContext ExecutionContext { get; set; }
    3029
    3130    event EventHandler HiddenChanged;
  • branches/UnloadJobs/HeuristicLab.DebugEngine.Views/3.3/OperationContentView.cs

    r7966 r9201  
    6161    private object GetParameterValue(IParameter param, IExecutionContext context, out string actualName) {
    6262      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
    6470      object value = null;
    6571      try {
    6672        value = param.ActualValue;
    67       } catch (Exception x) {
     73      }
     74      catch (Exception x) {
    6875        value = x.Message;
    6976      }
    70       ILookupParameter lookupParam = param as ILookupParameter;
    71       if (lookupParam != null)
    72         actualName = lookupParam.ActualName;
    73       else
    74         actualName = null;
    7577      return value;
    7678    }
  • branches/UnloadJobs/HeuristicLab.Operators/3.3/Operator.cs

    r7259 r9201  
    2222using System;
    2323using System.Drawing;
     24using System.Linq;
    2425using System.Threading;
    2526using HeuristicLab.Common;
     
    119120        ExecutionContext = context;
    120121        this.cancellationToken = cancellationToken;
    121         foreach (IParameter param in Parameters)
     122        foreach (ILookupParameter param in Parameters.OfType<ILookupParameter>())
    122123          param.ExecutionContext = context;
    123124        IOperation next = Apply();
     
    126127      }
    127128      finally {
    128         foreach (IParameter param in Parameters)
     129        foreach (ILookupParameter param in Parameters.OfType<ILookupParameter>())
    129130          param.ExecutionContext = null;
    130131        ExecutionContext = null;
  • branches/UnloadJobs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs

    r7967 r9201  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    49       System.Windows.Forms.DataVisualization.Charting.Series series2 = 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();
    5050      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RunCollectionBubbleChartView));
    5151      this.yJitterLabel = new System.Windows.Forms.Label();
     
    7272      this.noRunsLabel = new System.Windows.Forms.Label();
    7373      this.sizeTrackBar = new System.Windows.Forms.TrackBar();
     74      this.getDataAsMatrixToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    7475      ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit();
    7576      ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).BeginInit();
     
    188189      //
    189190      this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    190                   | System.Windows.Forms.AnchorStyles.Left)
    191                   | System.Windows.Forms.AnchorStyles.Right)));
    192       chartArea2.Name = "ChartArea1";
    193       this.chart.ChartAreas.Add(chartArea2);
     191            | System.Windows.Forms.AnchorStyles.Left)
     192            | System.Windows.Forms.AnchorStyles.Right)));
     193      chartArea1.Name = "ChartArea1";
     194      this.chart.ChartAreas.Add(chartArea1);
    194195      this.chart.Location = new System.Drawing.Point(6, 30);
    195196      this.chart.Name = "chart";
    196       series2.ChartArea = "ChartArea1";
    197       series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
    198       series2.IsVisibleInLegend = false;
    199       series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
    200       series2.Name = "Bubbles";
    201       series2.YValuesPerPoint = 2;
    202       this.chart.Series.Add(series2);
     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);
    203204      this.chart.Size = new System.Drawing.Size(843, 425);
    204205      this.chart.TabIndex = 16;
     
    215216      this.openBoxPlotViewToolStripMenuItem.Text = "Open BoxPlot View";
    216217      this.openBoxPlotViewToolStripMenuItem.Click += new System.EventHandler(this.openBoxPlotViewToolStripMenuItem_Click);
    217       //
     218      // 
    218219      // hideRunToolStripMenuItem
    219       //
     220      // 
    220221      this.hideRunToolStripMenuItem.Name = "hideRunToolStripMenuItem";
    221222      this.hideRunToolStripMenuItem.Size = new System.Drawing.Size(256, 22);
    222223      this.hideRunToolStripMenuItem.Text = "Hide Run";
    223       this.hideRunToolStripMenuItem.Click += new System.EventHandler(hideRunToolStripMenuItem_Click);
     224      this.hideRunToolStripMenuItem.Click += new System.EventHandler(this.hideRunToolStripMenuItem_Click);
    224225      //
    225226      // zoomButton
     
    325326      this.sizeTrackBar.Value = 10;
    326327      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);
    327335      //
    328336      // RunCollectionBubbleChartView
     
    386394    private System.Windows.Forms.Button colorYAxisButton;
    387395    private System.Windows.Forms.TrackBar sizeTrackBar;
     396    private System.Windows.Forms.ToolStripMenuItem getDataAsMatrixToolStripMenuItem;
    388397  }
    389398}
  • branches/UnloadJobs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r9068 r9201  
    2020#endregion
    2121
     22using HeuristicLab.Common;
     23using HeuristicLab.Core;
     24using HeuristicLab.Data;
     25using HeuristicLab.MainForm;
     26using HeuristicLab.MainForm.WindowsForms;
    2227using System;
    2328using System.Collections.Generic;
     
    2631using System.Windows.Forms;
    2732using 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;
    3333
    3434namespace HeuristicLab.Optimization.Views {
     
    5858      chart.ContextMenuStrip.Items.Insert(0, hideRunToolStripMenuItem);
    5959      chart.ContextMenuStrip.Items.Insert(1, openBoxPlotViewToolStripMenuItem);
     60      chart.ContextMenuStrip.Items.Add(getDataAsMatrixToolStripMenuItem);
    6061      chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening);
    6162
     
    688689      boxplotView.Show();
    689690    }
     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    }
    690722    #endregion
    691723
  • branches/UnloadJobs/HeuristicLab.Parameters/3.3/LookupParameter.cs

    r7259 r9201  
    2121
    2222using System;
     23using System.Threading;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    3132  [Item("LookupParameter", "A parameter whose value is retrieved from or written to a scope.")]
    3233  [StorableClass]
    33   public class LookupParameter<T> : Parameter, ILookupParameter<T> where T : class, IItem {
     34  public class LookupParameter<T> : Parameter, IStatefulItem, ILookupParameter<T> where T : class, IItem {
    3435    [Storable]
    3536    private string actualName;
     
    5960    }
    6061
     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
    6178    [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    }
    6384    protected LookupParameter(LookupParameter<T> original, Cloner cloner)
    6485      : base(original, cloner) {
    6586      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);
    6689    }
    6790    public LookupParameter()
     
    6992      this.actualName = Name;
    7093      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);
    7196    }
    7297    public LookupParameter(string name)
     
    7499      this.actualName = Name;
    75100      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);
    76103    }
    77104    public LookupParameter(string name, string description)
     
    79106      this.actualName = Name;
    80107      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);
    81110    }
    82111    public LookupParameter(string name, string description, string actualName)
     
    84113      this.actualName = string.IsNullOrWhiteSpace(actualName) ? Name : actualName;
    85114      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);
    86117    }
    87118
     
    132163    }
    133164    protected override IItem GetActualValue() {
     165      if (CachedActualValue != null) return CachedActualValue;
    134166      string name;
    135167      // try to get value from context stack
     
    146178                          typeof(T).GetPrettyName())
    147179          );
     180        cachedActualValues.Value.Value = var.Value;
    148181        return var.Value;
    149182      }
     
    156189                        typeof(T).GetPrettyName())
    157190        );
     191      cachedActualValues.Value.Value = value;
     192
    158193      // try to set value in context stack
    159194      string name;
     
    175210    }
    176211
     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
    177225    public event EventHandler ActualNameChanged;
    178226    protected virtual void OnActualNameChanged() {
  • branches/UnloadJobs/HeuristicLab.Parameters/3.3/Parameter.cs

    r7259 r9201  
    2222using System;
    2323using System.Drawing;
    24 using System.Threading;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Core;
     
    3332  [Item("Parameter", "A base class for parameters.")]
    3433  [StorableClass]
    35   public abstract class Parameter : NamedItem, IParameter, IStatefulItem {
     34  public abstract class Parameter : NamedItem, IParameter {
    3635    public override Image ItemImage {
    3736      get {
     
    6766    }
    6867
    69     private Lazy<ThreadLocal<IItem>> cachedActualValues;
    7068    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); }
    8971    }
    9072
     
    9274    protected Parameter(bool deserializing)
    9375      : 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);
    9676    }
    9777    protected Parameter(Parameter original, Cloner cloner)
     
    9979      dataType = original.dataType;
    10080      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);
    10381    }
    10482    protected Parameter()
     
    10684      dataType = typeof(IItem);
    10785      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);
    11086    }
    11187    protected Parameter(string name, Type dataType)
     
    11490      this.dataType = dataType;
    11591      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);
    11892    }
    11993    protected Parameter(string name, string description, Type dataType)
     
    12296      this.dataType = dataType;
    12397      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);
    13298    }
    13399
  • branches/UnloadJobs/HeuristicLab.Parameters/3.3/ScopeParameter.cs

    r7259 r9201  
    2121
    2222using System;
     23using System.Threading;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    3132  [Item("ScopeParameter", "A parameter which represents the current scope.")]
    3233  [StorableClass]
    33   public class ScopeParameter : Parameter {
     34  public class ScopeParameter : LookupParameter<IScope> {
    3435    public new IScope ActualValue {
    3536      get { return ExecutionContext.Scope; }
    3637    }
     38
    3739
    3840    [StorableConstructor]
     
    4042    protected ScopeParameter(ScopeParameter original, Cloner cloner) : base(original, cloner) { }
    4143    public ScopeParameter()
    42       : base("Anonymous", typeof(IScope)) {
     44      : base("Anonymous") {
    4345      this.Hidden = true;
    4446    }
    4547    public ScopeParameter(string name)
    46       : base(name, typeof(IScope)) {
     48      : base(name) {
    4749      this.Hidden = true;
    4850    }
    4951    public ScopeParameter(string name, string description)
    50       : base(name, description, typeof(IScope)) {
     52      : base(name, description) {
    5153      this.Hidden = true;
    5254    }
Note: See TracChangeset for help on using the changeset viewer.