Free cookie consent management tool by TermsFeed Policy Generator

Changeset 554


Ignore:
Timestamp:
09/12/08 11:24:03 (16 years ago)
Author:
gkronber
Message:

added 'jitter' sliders to add random noise to data points (useful in scatter plots with integer values). #200 (Simple indexer for results and matching search-frontend for solution-quality)

Location:
trunk/sources/HeuristicLab.CEDMA.Core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj

    r553 r554  
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    55    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    6     <ProductVersion>9.0.21022</ProductVersion>
     6    <ProductVersion>9.0.30729</ProductVersion>
    77    <SchemaVersion>2.0</SchemaVersion>
    88    <ProjectGuid>{C27DDF6C-84DF-45EF-B82F-57A28DD51166}</ProjectGuid>
  • trunk/sources/HeuristicLab.CEDMA.Core/ResultListView.Designer.cs

    r553 r554  
    2929      this.yAxisLabel = new System.Windows.Forms.Label();
    3030      this.yAxisComboBox = new System.Windows.Forms.ComboBox();
     31      this.yTrackBar = new System.Windows.Forms.TrackBar();
     32      this.xTrackBar = new System.Windows.Forms.TrackBar();
     33      this.xJitterlabel = new System.Windows.Forms.Label();
     34      this.yJitterLabel = new System.Windows.Forms.Label();
     35      ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).BeginInit();
     36      ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit();
    3137      this.SuspendLayout();
    3238      //
     
    4854      this.xAxisLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    4955      this.xAxisLabel.AutoSize = true;
    50       this.xAxisLabel.Location = new System.Drawing.Point(305, 429);
     56      this.xAxisLabel.Location = new System.Drawing.Point(197, 429);
    5157      this.xAxisLabel.Name = "xAxisLabel";
    5258      this.xAxisLabel.Size = new System.Drawing.Size(15, 13);
     
    5864      this.xAxisComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    5965      this.xAxisComboBox.FormattingEnabled = true;
    60       this.xAxisComboBox.Location = new System.Drawing.Point(326, 426);
     66      this.xAxisComboBox.Location = new System.Drawing.Point(218, 426);
    6167      this.xAxisComboBox.Name = "xAxisComboBox";
    6268      this.xAxisComboBox.Size = new System.Drawing.Size(121, 21);
     
    8288      this.yAxisComboBox.SelectedIndexChanged += new System.EventHandler(this.yAxisComboBox_SelectedIndexChanged);
    8389      //
    84       // ResultView
     90      // yTrackBar
     91      //
     92      this.yTrackBar.Location = new System.Drawing.Point(186, 3);
     93      this.yTrackBar.Maximum = 100;
     94      this.yTrackBar.Name = "yTrackBar";
     95      this.yTrackBar.Size = new System.Drawing.Size(60, 45);
     96      this.yTrackBar.TabIndex = 10;
     97      this.yTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
     98      this.yTrackBar.ValueChanged += new System.EventHandler(this.yTrackBar_ValueChanged);
     99      //
     100      // xTrackBar
     101      //
     102      this.xTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     103      this.xTrackBar.Location = new System.Drawing.Point(387, 426);
     104      this.xTrackBar.Maximum = 100;
     105      this.xTrackBar.Name = "xTrackBar";
     106      this.xTrackBar.Size = new System.Drawing.Size(60, 45);
     107      this.xTrackBar.TabIndex = 11;
     108      this.xTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
     109      this.xTrackBar.ValueChanged += new System.EventHandler(this.xTrackBar_ValueChanged);
     110      //
     111      // xJitterlabel
     112      //
     113      this.xJitterlabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     114      this.xJitterlabel.AutoSize = true;
     115      this.xJitterlabel.Location = new System.Drawing.Point(352, 429);
     116      this.xJitterlabel.Name = "xJitterlabel";
     117      this.xJitterlabel.Size = new System.Drawing.Size(29, 13);
     118      this.xJitterlabel.TabIndex = 12;
     119      this.xJitterlabel.Text = "jitter:";
     120      //
     121      // yJitterLabel
     122      //
     123      this.yJitterLabel.AutoSize = true;
     124      this.yJitterLabel.Location = new System.Drawing.Point(151, 6);
     125      this.yJitterLabel.Name = "yJitterLabel";
     126      this.yJitterLabel.Size = new System.Drawing.Size(29, 13);
     127      this.yJitterLabel.TabIndex = 13;
     128      this.yJitterLabel.Text = "jitter:";
     129      //
     130      // ResultListView
    85131      //
    86132      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    87133      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     134      this.Controls.Add(this.yJitterLabel);
     135      this.Controls.Add(this.xJitterlabel);
     136      this.Controls.Add(this.xTrackBar);
    88137      this.Controls.Add(this.dataChart);
    89138      this.Controls.Add(this.xAxisLabel);
     
    91140      this.Controls.Add(this.yAxisLabel);
    92141      this.Controls.Add(this.yAxisComboBox);
    93       this.Name = "ResultView";
     142      this.Controls.Add(this.yTrackBar);
     143      this.Name = "ResultListView";
    94144      this.Size = new System.Drawing.Size(450, 450);
     145      ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).EndInit();
     146      ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).EndInit();
    95147      this.ResumeLayout(false);
    96148      this.PerformLayout();
     
    105157    private System.Windows.Forms.Label yAxisLabel;
    106158    private System.Windows.Forms.ComboBox yAxisComboBox;
     159    private System.Windows.Forms.TrackBar yTrackBar;
     160    private System.Windows.Forms.TrackBar xTrackBar;
     161    private System.Windows.Forms.Label xJitterlabel;
     162    private System.Windows.Forms.Label yJitterLabel;
    107163  }
    108164}
  • trunk/sources/HeuristicLab.CEDMA.Core/ResultListView.cs

    r553 r554  
    1414    private ResultList results;
    1515    private const string FREQUENCY = "<Frequency>";
     16    private double xJitterFactor = 0.0;
     17    private double yJitterFactor = 0.0;
     18    private double maxXJitterPercent = .1;
     19    private double maxYJitterPercent = .1;
    1620
    1721    public ResultListView(ResultList results) {
     
    2529
    2630    private void yAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     31      yJitterFactor = 0.0;
     32      yTrackBar.Value = 0;
    2733      UpdateChart();
    2834    }
    2935
    3036    private void xAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     37      xJitterFactor = 0.0;
     38      xTrackBar.Value = 0;
    3139      UpdateChart();
    3240    }
    3341
    3442    private void UpdateChart() {
     43      if(xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return;
     44      if(yAxisComboBox.SelectedItem.Equals(FREQUENCY)) {
     45        CreateHistogramChart();
     46      } else {
     47        CreateScatterplot();
     48      }
     49    }
     50
     51    private void CreateScatterplot() {
    3552      double minX = double.PositiveInfinity;
    3653      double minY = double.PositiveInfinity;
    3754      double maxX = double.NegativeInfinity;
    3855      double maxY = double.NegativeInfinity;
    39       if(xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return;
    40       if(yAxisComboBox.SelectedItem.Equals(FREQUENCY)) {
    41         Color curCol = Color.Blue;
    42         Pen p = new Pen(curCol);
    43         SolidBrush b = new SolidBrush(curCol);
    44         // frequency
    45         dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100);
    46         dataChart.Chart.UpdateEnabled = false;
    47         dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both));
    48         Histogram h = results.GetHistogram((string)xAxisComboBox.SelectedItem);
    49         for(int i = 0; i < h.Buckets; i++) {
    50           double lower = h.LowerValue(i);
    51           double upper = h.UpperValue(i);
    52           int freq = h.Frequency(i);
    53           if(lower < minX) minX = lower;
    54           if(upper > maxX) maxX = upper;
    55           if(freq > maxY) maxY = freq;
    56           dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Bars, p, b);
    57           dataChart.Chart.AddDataPoint(0, lower, 0);
    58           dataChart.Chart.AddDataPoint(0, upper, freq);
     56
     57      xTrackBar.Enabled = true;
     58      yTrackBar.Enabled = true;
     59      Random random = new Random();
     60      Color curCol = Color.FromArgb(30, Color.Blue);
     61      Pen p = new Pen(curCol);
     62      SolidBrush b = new SolidBrush(curCol);
     63      IList<double> xs = results.GetValues((string)xAxisComboBox.SelectedItem);
     64      IList<double> ys = results.GetValues((string)yAxisComboBox.SelectedItem);
     65      dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100);
     66      dataChart.Chart.UpdateEnabled = false;
     67      dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both));
     68      dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Points, p, b);
     69      for(int i = 0; i < xs.Count; i++) {
     70        double x = xs[i] + (random.NextDouble() * 2.0 - 1.0) * xJitterFactor;
     71        double y = ys[i] + (random.NextDouble() * 2.0 - 1.0) * yJitterFactor;
     72        if(double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
     73        if(double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN;
     74        if(!double.IsNaN(x) && !double.IsNaN(y)) {
     75          dataChart.Chart.AddDataPoint(0, x, y);
     76          if(x > maxX) maxX = x;
     77          if(y > maxY) maxY = y;
     78          if(x < minX) minX = x;
     79          if(y < minY) minY = y;
    5980        }
    60         minY = 0;
     81      }
     82      dataChart.Chart.UpdateEnabled = true;
     83      if(minX<maxX && minY<maxY) dataChart.Chart.ZoomIn(minX, minY, maxX, maxY);
     84    }
    6185
    62         dataChart.Chart.UpdateEnabled = true;
    63       } else {
    64         Color curCol = Color.FromArgb(30, Color.Blue);
    65         Pen p = new Pen(curCol);
    66         SolidBrush b = new SolidBrush(curCol);
    67         IList<double> xs = results.GetValues((string)xAxisComboBox.SelectedItem);
    68         IList<double> ys = results.GetValues((string)yAxisComboBox.SelectedItem);
    69         dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100);
    70         dataChart.Chart.UpdateEnabled = false;
    71         dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both));
    72         dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Points, p, b);
    73         for(int i = 0; i < xs.Count; i++) {
    74           double x = xs[i];
    75           double y = ys[i];
    76           if(double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
    77           if(double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN;
    78           if(!double.IsNaN(x) && !double.IsNaN(y)) {
    79             dataChart.Chart.AddDataPoint(0, x, y);
    80             if(x > maxX) maxX = x;
    81             if(y > maxY) maxY = y;
    82             if(x < minX) minX = x;
    83             if(y < minY) minY = y;
    84           }
    85         }
    86         dataChart.Chart.UpdateEnabled = true;
     86    private void CreateHistogramChart() {
     87      double minX = double.PositiveInfinity;
     88      double minY = double.PositiveInfinity;
     89      double maxX = double.NegativeInfinity;
     90      double maxY = double.NegativeInfinity;
     91
     92      xTrackBar.Enabled = false;
     93      yTrackBar.Enabled = false;
     94      Color curCol = Color.Blue;
     95      Pen p = new Pen(curCol);
     96      SolidBrush b = new SolidBrush(curCol);
     97      // frequency
     98      dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100);
     99      dataChart.Chart.UpdateEnabled = false;
     100      dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both));
     101      Histogram h = results.GetHistogram((string)xAxisComboBox.SelectedItem);
     102      for(int i = 0; i < h.Buckets; i++) {
     103        double lower = h.LowerValue(i);
     104        double upper = h.UpperValue(i);
     105        int freq = h.Frequency(i);
     106        if(lower < minX) minX = lower;
     107        if(upper > maxX) maxX = upper;
     108        if(freq > maxY) maxY = freq;
     109        dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Bars, p, b);
     110        dataChart.Chart.AddDataPoint(0, lower, 0);
     111        dataChart.Chart.AddDataPoint(0, upper, freq);
    87112      }
     113      minY = 0;
     114      dataChart.Chart.UpdateEnabled = true;
     115      if(minX < maxX && minY < maxY) dataChart.Chart.ZoomIn(minX, minY, maxX, maxY);
     116    }
    88117
    89       dataChart.Chart.ZoomIn(minX, minY, maxX, maxY);
     118    private void yTrackBar_ValueChanged(object sender, EventArgs e) {
     119      if(dataChart.Chart != null) {
     120        yJitterFactor = yTrackBar.Value / 100.0 * maxYJitterPercent * dataChart.Chart.Size.Height;
     121      }
     122      UpdateChart();
     123    }
     124
     125    private void xTrackBar_ValueChanged(object sender, EventArgs e) {
     126      if(dataChart.Chart != null) {
     127        xJitterFactor = xTrackBar.Value / 100.0 * maxXJitterPercent * dataChart.Chart.Size.Width;
     128      }
     129      UpdateChart();
    90130    }
    91131  }
Note: See TracChangeset for help on using the changeset viewer.