Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12865


Ignore:
Timestamp:
08/17/15 09:32:01 (9 years ago)
Author:
abeham
Message:

#2431:

  • Added label on last data point
  • Changed target in cost view to display as ratio to best-known or best found
Location:
branches/PerformanceComparison
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Analysis.Views/3.3/IndexedDataTableView.cs

    r12826 r12865  
    3636    protected List<Series> invisibleSeries;
    3737    protected Dictionary<IObservableList<Tuple<T, double>>, IndexedDataRow<T>> valuesRowsTable;
    38     /// <summary>
    39     /// Gets or sets the variable to represent visually.
    40     /// </summary>
    41     /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    42     /// No own data storage present.</remarks>
     38
    4339    public new IndexedDataTable<T> Content {
    4440      get { return (IndexedDataTable<T>)base.Content; }
     
    4642    }
    4743
    48     /// <summary>
    49     /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable".
    50     /// </summary>
    5144    public IndexedDataTableView() {
    5245      InitializeComponent();
     
    5952
    6053    #region Event Handler Registration
    61     /// <summary>
    62     /// Removes the eventhandlers from the underlying <see cref="Variable"/>.
    63     /// </summary>
    64     /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    6554    protected override void DeregisterContentEvents() {
    6655      foreach (var row in Content.Rows)
     
    7463    }
    7564
    76     /// <summary>
    77     /// Adds eventhandlers to the underlying <see cref="Variable"/>.
    78     /// </summary>
    79     /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    8065    protected override void RegisterContentEvents() {
    8166      base.RegisterContentEvents();
     
    177162      else series.Color = Color.Empty;
    178163      series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend;
     164
     165      series.SmartLabelStyle.Enabled = true;
     166      series.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes;
     167      series.SmartLabelStyle.CalloutLineAnchorCapStyle = LineAnchorCapStyle.None;
     168      series.SmartLabelStyle.CalloutLineColor = series.Color;
     169      series.SmartLabelStyle.CalloutLineWidth = 2;
     170      series.SmartLabelStyle.CalloutStyle = LabelCalloutStyle.Underlined;
     171      series.SmartLabelStyle.IsOverlappedHidden = false;
     172      series.SmartLabelStyle.MaxMovingDistance = 200;
    179173
    180174      switch (row.VisualProperties.ChartType) {
     
    564558      for (int i = 0; i < row.Values.Count; i++) {
    565559        var value = row.Values[i];
    566         DataPoint point = new DataPoint();
     560        var point = new DataPoint();
    567561        point.SetValueXY(value.Item1, value.Item2);
     562        if (i == row.Values.Count - 1) {
     563          point.Label = series.Name;
     564          point.MarkerStyle = MarkerStyle.Cross;
     565          point.MarkerSize = 15;
     566          point.MarkerBorderWidth = 1;
     567        }
    568568        series.Points.Add(point);
    569569      }
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs

    r12864 r12865  
    526526      var lineStyleCount = 0;
    527527
     528      var maximization = IsMaximization();
     529      var targetsPerProblem = (from r in Content
     530                               let pd = new ProblemDescription(r).ToString()
     531                               let target = r.Parameters.ContainsKey("BestKnownQuality")
     532                                && r.Parameters["BestKnownQuality"] is DoubleValue
     533                                  ? ((DoubleValue)r.Parameters["BestKnownQuality"]).Value
     534                                  : ((IndexedDataTable<double>)r.Results[(string)dataTableComboBox.SelectedItem]).Rows.First().Values.Last().Item2
     535                               group target by pd into g
     536                               select new { Problem = g.Key, Target = maximization ? g.Max() : g.Min() })
     537                              .ToDictionary(x => x.Problem, x => x.Target);
     538
    528539      foreach (var group in groupedRuns) {
    529540        var hits = new Dictionary<string, SortedList<double, double>>();
     
    534545
    535546            if (eachOrAllBudgetsCheckBox.Checked) {
    536               CalculateHitsForEachBudget(hits, resultsTable.Rows.First(), group.Value.Count, group.Key, problem.Value.Item2.Count);
     547              CalculateHitsForEachBudget(hits, resultsTable.Rows.First(), maximization, group.Value.Count, group.Key, problem.Value.Item2.Count, targetsPerProblem[problem.Key]);
    537548            } else {
    538               CalculateHitsForAllBudgets(hits, resultsTable.Rows.First(), group.Value.Count, group.Key, problem.Value.Item2.Count);
     549              CalculateHitsForAllBudgets(hits, resultsTable.Rows.First(), maximization, group.Value.Count, group.Key, problem.Value.Item2.Count, targetsPerProblem[problem.Key]);
    539550            }
    540551          }
     
    563574      }
    564575
    565       byCostDataTable.VisualProperties.XAxisTitle = "Targets";
     576      byCostDataTable.VisualProperties.XAxisTitle = "Targets to Best-Known Ratio";
    566577      byCostDataTable.VisualProperties.XAxisLogScale = byCostDataTable.Rows.Count > 0 && budgetLogScalingCheckBox.Checked;
    567578    }
     
    588599    }
    589600
    590     private void CalculateHitsForEachBudget(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, int groupCount, string groupName, int problemCount) {
     601    private void CalculateHitsForEachBudget(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, bool maximization, int groupCount, string groupName, int problemCount, double bestTarget) {
    591602      foreach (var b in budgets) {
    592603        var key = groupName + "-" + b;
     
    597608            // the budget may be too low to achieve any target
    598609            if (prev == null && v.Item1 != b) break;
    599             var tgt = (prev == null || v.Item1 == b) ? v.Item2 : prev.Item2;
     610            var tgt = ((prev == null || v.Item1 == b) ? v.Item2 : prev.Item2);
     611            tgt = maximization ? bestTarget / tgt : tgt / bestTarget;
    600612            if (hits[key].ContainsKey(tgt))
    601613              hits[key][tgt] += 1.0 / (groupCount * problemCount);
     
    609621    }
    610622
    611     private void CalculateHitsForAllBudgets(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, int groupCount, string groupName, int problemCount) {
     623    private void CalculateHitsForAllBudgets(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, bool maximization, int groupCount, string groupName, int problemCount, double bestTarget) {
    612624      var values = row.Values;
    613625      if (!hits.ContainsKey(groupName)) hits.Add(groupName, new SortedList<double, double>());
     
    621633          if (prev != null || current.Item1 == budgets[i]) {
    622634            var tgt = (prev == null || current.Item1 == budgets[i]) ? current.Item2 : prev.Item2;
     635            tgt = maximization ? bestTarget / tgt : tgt / bestTarget;
    623636            if (!hits[groupName].ContainsKey(tgt)) hits[groupName][tgt] = 0;
    624637            hits[groupName][tgt] += 1.0 / (groupCount * problemCount * budgets.Length);
     
    631644      }
    632645      var lastTgt = values.Last().Item2;
     646      lastTgt = maximization ? bestTarget / lastTgt : lastTgt / bestTarget;
    633647      if (i < budgets.Length && !hits[groupName].ContainsKey(lastTgt)) hits[groupName][lastTgt] = 0;
    634648      while (i < budgets.Length) {
Note: See TracChangeset for help on using the changeset viewer.