Changeset 4639
- Timestamp:
- 10/22/10 03:17:02 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 3 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis.Views/3.3/AlleleFrequencyCollectionView.Designer.cs
r4638 r4639 21 21 22 22 namespace HeuristicLab.Analysis.Views { 23 partial class AlleleFrequency ArrayView {23 partial class AlleleFrequencyCollectionView { 24 24 /// <summary> 25 25 /// Required designer variable. … … 61 61 chartArea1.AxisX.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.VariableCount; 62 62 chartArea1.AxisX.LabelAutoFitStyle = ((System.Windows.Forms.DataVisualization.Charting.LabelAutoFitStyles)((System.Windows.Forms.DataVisualization.Charting.LabelAutoFitStyles.IncreaseFont | System.Windows.Forms.DataVisualization.Charting.LabelAutoFitStyles.DecreaseFont))); 63 chartArea1.AxisX.LabelStyle.Angle = 90;64 63 chartArea1.AxisX.Title = "Alleles"; 65 64 chartArea1.AxisY.Maximum = 1D; 66 65 chartArea1.AxisY.Minimum = 0D; 67 66 chartArea1.AxisY.Title = "Relative Frequency"; 68 chartArea1.AxisY2.Title = "Average Solution Quality ";67 chartArea1.AxisY2.Title = "Average Solution Quality / Average Impact"; 69 68 chartArea1.CursorX.IsUserEnabled = true; 70 69 chartArea1.CursorX.IsUserSelectionEnabled = true; … … 90 89 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 91 90 // 92 // AlleleFrequency ArrayView91 // AlleleFrequencyCollectionView 93 92 // 94 93 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 95 94 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 96 95 this.Controls.Add(this.chart); 97 this.Name = "AlleleFrequency ArrayView";96 this.Name = "AlleleFrequencyCollectionView"; 98 97 this.Size = new System.Drawing.Size(498, 359); 99 98 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); -
trunk/sources/HeuristicLab.Analysis.Views/3.3/AlleleFrequencyCollectionView.cs
r4638 r4639 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Drawing; … … 29 30 30 31 namespace HeuristicLab.Analysis.Views { 31 [View("AlleleFrequency ArrayView")]32 [Content(typeof(AlleleFrequency Array), true)]33 public partial class AlleleFrequency ArrayView : ItemView {32 [View("AlleleFrequencyCollection View")] 33 [Content(typeof(AlleleFrequencyCollection), true)] 34 public partial class AlleleFrequencyCollectionView : ItemView { 34 35 private List<Series> invisibleSeries; 35 36 36 public new AlleleFrequency ArrayContent {37 get { return (AlleleFrequency Array)base.Content; }37 public new AlleleFrequencyCollection Content { 38 get { return (AlleleFrequencyCollection)base.Content; } 38 39 set { base.Content = value; } 39 40 } 40 41 41 public AlleleFrequency ArrayView() {42 public AlleleFrequencyCollectionView() { 42 43 InitializeComponent(); 43 44 invisibleSeries = new List<Series>(); … … 49 50 if (Content == null) { 50 51 chart.Series.Clear(); 51 chart.DataSource = null;52 52 invisibleSeries.Clear(); 53 53 } else { 54 54 if (chart.Series.Count == 0) CreateSeries(); 55 chart.DataSource = Content.Select(x => new {56 Id = x.Id,57 BestKnownFrequency = x.ContainedInBestKnownSolution ? x.Frequency : 0,58 Frequency = !x.ContainedInBestKnownSolution ? x.Frequency : 0,59 Quality = x.AverageSolutionQuality,60 Impact = x.AverageImpact61 }).OrderBy(x => x.Impact).ToArray();62 55 UpdateSeries(); 63 56 } … … 71 64 protected virtual void CreateSeries() { 72 65 Series bestKnown = new Series("Alleles of Best Known Solution"); 73 bestKnown.ChartType = SeriesChartType.StackedColumn; 74 bestKnown.XValueMember = "Id"; 66 bestKnown.ChartType = SeriesChartType.Column; 75 67 bestKnown.XValueType = ChartValueType.String; 76 bestKnown.YValueMembers = "BestKnownFrequency";77 68 bestKnown.YValueType = ChartValueType.Double; 78 69 bestKnown.YAxisType = AxisType.Primary; 79 bestKnown.ToolTip = "X = #LABEL, Y = #VAL";80 70 chart.Series.Add(bestKnown); 81 71 82 72 Series others = new Series("Other Alleles"); 83 others.ChartType = SeriesChartType.StackedColumn; 84 others.XValueMember = "Id"; 73 others.ChartType = SeriesChartType.Column; 85 74 others.XValueType = ChartValueType.String; 86 others.YValueMembers = "Frequency";87 75 others.YValueType = ChartValueType.Double; 88 76 others.YAxisType = AxisType.Primary; 89 others.ToolTip = "X = #LABEL, Y = #VAL";90 77 chart.Series.Add(others); 78 invisibleSeries.Add(others); 91 79 92 80 Series qualities = new Series("Average Solution Qualities"); 93 qualities.ChartType = SeriesChartType.FastLine; 94 qualities.XValueMember = "Id"; 81 qualities.ChartType = SeriesChartType.FastPoint; 95 82 qualities.XValueType = ChartValueType.String; 96 qualities.YValueMembers = "Quality";97 83 qualities.YValueType = ChartValueType.Double; 98 84 qualities.YAxisType = AxisType.Secondary; 99 qualities.ToolTip = " X = #LABEL, Y =#VAL";85 qualities.ToolTip = "#VAL"; 100 86 chart.Series.Add(qualities); 101 87 102 88 Series impacts = new Series("Average Impact"); 103 impacts.ChartType = SeriesChartType.FastLine; 104 impacts.XValueMember = "Id"; 89 impacts.ChartType = SeriesChartType.FastPoint; 105 90 impacts.XValueType = ChartValueType.String; 106 impacts.YValueMembers = "Impact";107 91 impacts.YValueType = ChartValueType.Double; 108 92 impacts.YAxisType = AxisType.Secondary; 109 impacts.ToolTip = " X = #LABEL, Y =#VAL";93 impacts.ToolTip = "#VAL"; 110 94 chart.Series.Add(impacts); 111 95 } 112 96 113 97 protected virtual void UpdateSeries() { 114 chart.DataBind(); 98 int index = 1; 99 Series bestKnown = chart.Series["Alleles of Best Known Solution"]; 100 Series others = chart.Series["Other Alleles"]; 101 Series qualities = chart.Series["Average Solution Qualities"]; 102 Series impacts = chart.Series["Average Impact"]; 103 bestKnown.Points.Clear(); 104 others.Points.Clear(); 105 qualities.Points.Clear(); 106 impacts.Points.Clear(); 115 107 116 if (invisibleSeries.Contains(chart.Series["Alleles of Best Known Solution"])) 117 chart.Series["Alleles of Best Known Solution"].Points.Clear(); 118 chart.DataManipulator.Filter(CompareMethod.EqualTo, 0, chart.Series["Alleles of Best Known Solution"]); 108 if (!invisibleSeries.Contains(bestKnown)) { 109 foreach (AlleleFrequency af in Content.Where(x => x.ContainedInBestKnownSolution).OrderBy(x => x.AverageImpact)) { 110 bestKnown.Points.Add(CreateFrequencyDataPoint(index, af)); 111 if (!invisibleSeries.Contains(qualities)) qualities.Points.AddXY(index, af.AverageSolutionQuality); 112 if (!invisibleSeries.Contains(impacts)) impacts.Points.AddXY(index, af.AverageImpact); 113 index++; 114 } 115 } 116 if (!invisibleSeries.Contains(others)) { 117 foreach (AlleleFrequency af in Content.Where(x => !x.ContainedInBestKnownSolution).OrderBy(x => x.AverageImpact)) { 118 others.Points.Add(CreateFrequencyDataPoint(index, af)); 119 if (!invisibleSeries.Contains(qualities)) qualities.Points.AddXY(index, af.AverageSolutionQuality); 120 if (!invisibleSeries.Contains(impacts)) impacts.Points.AddXY(index, af.AverageImpact); 121 index++; 122 } 123 } 124 } 119 125 120 if (invisibleSeries.Contains(chart.Series["Other Alleles"])) 121 chart.Series["Other Alleles"].Points.Clear(); 122 chart.DataManipulator.Filter(CompareMethod.EqualTo, 0, chart.Series["Other Alleles"]); 126 protected virtual DataPoint CreateFrequencyDataPoint(int index, AlleleFrequency af) { 127 string nl = Environment.NewLine; 123 128 124 if (invisibleSeries.Contains(chart.Series["Average Solution Qualities"])) 125 chart.Series["Average Solution Qualities"].Points.Clear(); 126 chart.DataManipulator.Filter(CompareMethod.EqualTo, 0, chart.Series["Average Solution Qualities"]); 127 128 if (invisibleSeries.Contains(chart.Series["Average Impact"])) 129 chart.Series["Average Impact"].Points.Clear(); 130 chart.DataManipulator.Filter(CompareMethod.EqualTo, 0, chart.Series["Average Impact"]); 129 DataPoint p = new DataPoint(index, af.Frequency); 130 p.AxisLabel = af.Id; 131 p.ToolTip = string.Format("Id: {0}" + nl + 132 "Relative Frequency: {1}" + nl + 133 "Average Solution Quality: {2}" + nl + 134 "Average Impact: {3}" + nl + 135 "Contained in Best Known Solution: {4}" + nl + 136 "Contained in Best Solution: {5}", 137 af.Id, af.Frequency, af.AverageSolutionQuality, af.AverageImpact, af.ContainedInBestKnownSolution, af.ContainedInBestSolution); 138 return p; 131 139 } 132 140 -
trunk/sources/HeuristicLab.Analysis.Views/3.3/HeuristicLab.Analysis.Views-3.3.csproj
r4631 r4639 117 117 <ItemGroup> 118 118 <None Include="HeuristicLabAnalysisViewsPlugin.cs.frame" /> 119 <Compile Include="AlleleFrequencyArrayView.cs"> 120 <SubType>UserControl</SubType> 121 </Compile> 122 <Compile Include="AlleleFrequencyArrayView.Designer.cs"> 123 <DependentUpon>AlleleFrequencyArrayView.cs</DependentUpon> 119 <Compile Include="AlleleFrequencyCollectionView.cs" /> 120 <Compile Include="AlleleFrequencyCollectionView.Designer.cs"> 121 <DependentUpon>AlleleFrequencyCollectionView.cs</DependentUpon> 124 122 </Compile> 125 123 <Compile Include="HeuristicLabAnalysisViewsPlugin.cs" /> -
trunk/sources/HeuristicLab.Analysis/3.3/AlleleFrequencyAnalyzer.cs
r4631 r4639 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Linq; 23 24 using HeuristicLab.Core; … … 72 73 } 73 74 75 private class AlleleFrequencyEqualityComparer : IEqualityComparer<AlleleFrequency> { 76 public bool Equals(AlleleFrequency x, AlleleFrequency y) { 77 return x.Id == y.Id; 78 } 79 public int GetHashCode(AlleleFrequency obj) { 80 return obj.GetHashCode(); 81 } 82 } 83 74 84 public override IOperation Apply() { 75 85 int updateInterval = UpdateIntervalParameter.Value.Value; … … 110 120 bestAlleles.Any(a => a.Id == x.Key))); 111 121 122 // calculate dummy allele frequencies of alleles of best known solution which did not occur 123 var bestKnownFrequencies = bestKnownAlleles.Select(x => new AlleleFrequency(x.Id, 0, x.Impact, 0, true, false)).Except(frequencies, new AlleleFrequencyEqualityComparer()); 124 112 125 // fetch results collection 113 126 ResultCollection results; … … 120 133 121 134 // store allele frequencies 122 AlleleFrequency Array frequenciesArray = new AlleleFrequencyArray(frequencies);135 AlleleFrequencyCollection frequenciesCollection = new AlleleFrequencyCollection(bestKnownFrequencies.Concat(frequencies)); 123 136 if (!results.ContainsKey("Allele Frequencies")) 124 results.Add(new Result("Allele Frequencies", frequencies Array));137 results.Add(new Result("Allele Frequencies", frequenciesCollection)); 125 138 else 126 results["Allele Frequencies"].Value = frequencies Array;139 results["Allele Frequencies"].Value = frequenciesCollection; 127 140 128 141 // store allele frequencies history 129 142 if (storeHistory) { 130 143 if (!results.ContainsKey("Allele Frequencies History")) { 131 ItemCollection<AlleleFrequencyArray> history = new ItemCollection<AlleleFrequencyArray>();132 history.Add(frequencies Array);144 AlleleFrequencyCollectionCollection history = new AlleleFrequencyCollectionCollection(); 145 history.Add(frequenciesCollection); 133 146 results.Add(new Result("Allele Frequencies History", history)); 134 147 } else { 135 (( ItemCollection<AlleleFrequencyArray>)results["Allele Frequencies History"].Value).Add(frequenciesArray);148 ((AlleleFrequencyCollectionCollection)results["Allele Frequencies History"].Value).Add(frequenciesCollection); 136 149 } 137 150 } … … 146 159 allelesTable = (DataTable)results["Alleles"].Value; 147 160 } 148 allelesTable.Rows["Unique Alleles"].Values.Add(frequencies Array.Length);161 allelesTable.Rows["Unique Alleles"].Values.Add(frequenciesCollection.Count); 149 162 } 150 163 return base.Apply(); -
trunk/sources/HeuristicLab.Analysis/3.3/AlleleFrequencyCollection.cs
r4638 r4639 26 26 namespace HeuristicLab.Analysis { 27 27 /// <summary> 28 /// Represents a n arrayof allele frequencies.28 /// Represents a collection of allele frequencies. 29 29 /// </summary> 30 [Item("AlleleFrequency Array", "Represents an arrayof allele frequencies.")]30 [Item("AlleleFrequencyCollection", "Represents a collection of allele frequencies.")] 31 31 [StorableClass] 32 public class AlleleFrequency Array : ReadOnlyItemArray<AlleleFrequency> {33 public AlleleFrequency Array() : base() { }34 public AlleleFrequency Array(IEnumerable<AlleleFrequency> frequencies) : base(new ItemArray<AlleleFrequency>(frequencies)) { }32 public class AlleleFrequencyCollection : ReadOnlyItemCollection<AlleleFrequency> { 33 public AlleleFrequencyCollection() : base() { } 34 public AlleleFrequencyCollection(IEnumerable<AlleleFrequency> frequencies) : base(new ItemCollection<AlleleFrequency>(frequencies)) { } 35 35 [StorableConstructor] 36 protected AlleleFrequency Array(bool deserializing) : base(deserializing) { }36 protected AlleleFrequencyCollection(bool deserializing) : base(deserializing) { } 37 37 } 38 38 } -
trunk/sources/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r4623 r4639 110 110 <ItemGroup> 111 111 <None Include="HeuristicLabAnalysisPlugin.cs.frame" /> 112 <Compile Include="AlleleFrequencyCollection.cs" /> 112 113 <Compile Include="BestAverageWorstQualityAnalyzer.cs" /> 113 114 <Compile Include="BestAverageWorstQualityCalculator.cs" /> … … 116 117 <Compile Include="Allele.cs" /> 117 118 <Compile Include="AlleleFrequency.cs" /> 118 <Compile Include="AlleleFrequency Array.cs" />119 <Compile Include="AlleleFrequencyCollectionCollection.cs" /> 119 120 <Compile Include="QualityAnalyzer.cs" /> 120 121 <Compile Include="MinAverageMaxValueAnalyzer.cs" />
Note: See TracChangeset
for help on using the changeset viewer.