Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/09 15:56:05 (15 years ago)
Author:
gkronber
Message:

Implemented basic visualization of variable impacts in the CEDMA bubble chart. #286 (Variable-usage diagrams for the CEDMA frontend)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Charting/3.3/BubbleChart.cs

    r2047 r2131  
    3131using HeuristicLab.Core;
    3232using HeuristicLab.CEDMA.DB.Interfaces;
     33using System.Diagnostics;
    3334
    3435namespace HeuristicLab.CEDMA.Charting {
     
    5859    private Results results;
    5960    private Dictionary<IPrimitive, ResultsEntry> primitiveToEntryDictionary;
    60     private Dictionary<ResultsEntry, IPrimitive> entryToPrimitiveDictionary;
     61    //private Dictionary<ResultsEntry, IList<IPrimitive>> entryToPrimitivesDictionary;
    6162    private Random random = new Random();
    6263    private Group points;
     
    6667      records = new List<ResultsEntry>();
    6768      primitiveToEntryDictionary = new Dictionary<IPrimitive, ResultsEntry>();
    68       entryToPrimitiveDictionary = new Dictionary<ResultsEntry, IPrimitive>();
     69      // entryToPrimitivesDictionary = new Dictionary<ResultsEntry, IList<IPrimitive>>();
    6970      this.results = results;
    7071
     
    132133      Group.Clear();
    133134      primitiveToEntryDictionary.Clear();
    134       entryToPrimitiveDictionary.Clear();
     135      // entryToPrimitivesDictionary.Clear();
    135136      points = new Group(this);
    136137      Group.Add(new Axis(this, 0, 0, AxisType.Both));
    137138      UpdateViewSize(0, 0, 5);
    138139      foreach (ResultsEntry r in records) {
    139         double x, y;
     140        List<double> xs = new List<double>();
     141        List<double> ys = new List<double>();
    140142        int size;
    141143        if (results.OrdinalVariables.Contains(xDimension)) {
    142           x = Convert.ToDouble(r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor;
     144          xs.Add(Convert.ToDouble(r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor);
    143145        } else if (results.CategoricalVariables.Contains(xDimension)) {
    144           x = results.IndexOfCategoricalValue(xDimension, r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor;
     146          xs.Add(results.IndexOfCategoricalValue(xDimension, r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor);
     147        } else if (results.MultiDimensionalCategoricalVariables.Contains(xDimension)) {
     148          var path = xDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
     149          IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
     150          foreach (ResultsEntry subEntry in subEntries) {
     151            xs.Add(results.IndexOfCategoricalValue(xDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor);
     152          }
     153        } else if (results.MultiDimensionalOrdinalVariables.Contains(xDimension)) {
     154          var path = xDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
     155          IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
     156          foreach (ResultsEntry subEntry in subEntries) {
     157            xs.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor);
     158          }
    145159        } else {
    146           x = double.NaN;
     160          xs.Add(double.NaN);
    147161        }
    148162        if (results.OrdinalVariables.Contains(yDimension)) {
    149           y = Convert.ToDouble(r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor;
     163          ys.Add(Convert.ToDouble(r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor);
    150164        } else if (results.CategoricalVariables.Contains(yDimension)) {
    151           y = results.IndexOfCategoricalValue(yDimension, r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor;
     165          ys.Add(results.IndexOfCategoricalValue(yDimension, r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor);
     166        } else if (results.MultiDimensionalCategoricalVariables.Contains(yDimension)) {
     167          var path = yDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
     168          IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
     169          foreach (ResultsEntry subEntry in subEntries) {
     170            ys.Add(results.IndexOfCategoricalValue(yDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor);
     171          }
     172        } else if (results.MultiDimensionalOrdinalVariables.Contains(yDimension)) {
     173          var path = yDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
     174          IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
     175          foreach (ResultsEntry subEntry in subEntries) {
     176            ys.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor);
     177          }
    152178        } else {
    153           y = double.NaN;
     179          ys.Add(double.NaN);
    154180        }
    155181        size = CalculateSize(Convert.ToDouble(r.Get(sizeDimension)), minSize, maxSize);
    156 
    157         if (double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
    158         if (double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN;
    159         if (!double.IsNaN(x) && !double.IsNaN(y)) {
    160           UpdateViewSize(x, y, size);
    161           int alpha = CalculateAlpha(size);
    162           Pen pen = new Pen(Color.FromArgb(alpha, r.Selected ? selectionColor : defaultColor));
    163           Brush brush = pen.Brush;
    164           FixedSizeCircle c = new FixedSizeCircle(this, x, y, size, pen, brush);
    165           c.ToolTipText = r.GetToolTipText();
    166           points.Add(c);
    167           if (!r.Selected) c.IntoBackground();
    168           primitiveToEntryDictionary[c] = r;
    169           entryToPrimitiveDictionary[r] = c;
     182        Debug.Assert(xs.Count() == ys.Count() || xs.Count() == 1 || ys.Count() == 1);
     183        int n = Math.Max(xs.Count(), ys.Count());
     184        for (int i = 0; i < n; i++) {
     185          double x = xs[Math.Min(i, xs.Count()-1)];
     186          double y = ys[Math.Min(i, ys.Count()-1)];
     187          if (double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
     188          if (double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN;
     189          if (!double.IsNaN(x) && !double.IsNaN(y)) {
     190            UpdateViewSize(x, y, size);
     191            int alpha = CalculateAlpha(size);
     192            Pen pen = new Pen(Color.FromArgb(alpha, r.Selected ? selectionColor : defaultColor));
     193            Brush brush = pen.Brush;
     194            FixedSizeCircle c = new FixedSizeCircle(this, x, y, size, pen, brush);
     195            c.ToolTipText = r.GetToolTipText();
     196            points.Add(c);
     197            if (!r.Selected) c.IntoBackground();
     198            primitiveToEntryDictionary[c] = r;
     199            //if (!entryToPrimitivesDictionary.ContainsKey(r)) entryToPrimitivesDictionary[r] = new List<IPrimitive>();
     200            //entryToPrimitivesDictionary[r].Add(c);
     201          }
    170202        }
    171203      }
Note: See TracChangeset for help on using the changeset viewer.