- Timestamp:
- 12/18/15 12:42:13 (9 years ago)
- Location:
- branches/PerformanceComparison
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionIteratedSamplingView.cs
r13475 r13485 26 26 using System.Linq; 27 27 using System.Windows.Forms.DataVisualization.Charting; 28 using HeuristicLab.MainForm.WindowsForms;29 using HeuristicLab.MainForm;30 28 using HeuristicLab.Analysis; 31 29 using HeuristicLab.Common; 32 30 using HeuristicLab.Data; 31 using HeuristicLab.MainForm; 32 using HeuristicLab.MainForm.WindowsForms; 33 33 34 34 namespace HeuristicLab.Optimization.Views.RunCollectionViews { … … 268 268 bestProbability = 1.0; 269 269 var bestProbabilityEffort = 0.0; 270 var succ = 0; 270 271 foreach (var d in data) { 271 272 if (double.IsNaN(d.Item2)) continue; 272 double succ = 0.0, unsucc = 0.0; 273 foreach (var e in data) { 274 if (e.Item1 <= d.Item1 && HasAchievedTarget(maximization, e, target)) succ++; 275 else if (e.Item1 >= d.Item1) unsucc++; 276 } 273 if (HasAchievedTarget(maximization, d, target)) succ++; 277 274 // probability of having no successful run with effort d.Item1 278 var prob = (1.0 - succ / ( succ + unsucc));275 var prob = (1.0 - succ / (double)data.Count); 279 276 // normalizing probability to effort 1 (assuming exponential convergence) 280 277 prob = Math.Pow(prob, 1.0 / d.Item1); … … 293 290 private void UpdateGraph(double cutoff, double bestProbability, double target, bool maximization) { 294 291 var table = (string)dataTableComboBox.SelectedItem; 295 var result = ExpectedRuntimeHelper.CalculateErt(GetRunsFiltered().ToList(), table, target, maximization);296 var lambda = 1.0 / result.ExpectedRuntime;297 292 var runs = GetRunsFiltered().Select(x => (IndexedDataTable<double>)x.Results[table]).ToList(); 298 293 var evaluations = runs.SelectMany(x => x.Rows.First().Values.Select(y => y.Item1)).Distinct().OrderBy(x => x).ToList(); … … 332 327 } 333 328 334 var minimum = hits.First(x => x.Value > 0).Key;335 336 329 enhancedChart.SuspendRepaint(); 337 330 … … 346 339 var series2 = enhancedChart.Series["rldApproximationSeries"]; 347 340 series2.Points.Clear(); 348 foreach (var e in Enumerable.Range(0, (int)Math.Ceiling(evaluations.Max()))) { 349 series2.Points.AddXY(e, Math.Max(0, 1.0 - Math.Exp(-lambda * (e - minimum)))); 341 var evalMax = evaluations.Max(); 342 var steps = evalMax / 100.0; 343 344 var result = ExpectedRuntimeHelper.CalculateErt(GetRunsFiltered().ToList(), table, target, maximization); 345 var lambda = 1.0 / result.ExpectedRuntime; 346 foreach (var e in Enumerable.Range(0, 100)) { 347 var x = e * steps; 348 series2.Points.AddXY(x, Math.Max(0, 1.0 - Math.Exp(-lambda * x))); 350 349 } 351 350 var series3 = enhancedChart.Series["optimalSeries"]; 352 351 series3.Points.Clear(); 353 lambda = -Math.Log(bestProbability); 354 foreach (var e in Enumerable.Range(0, (int)Math.Ceiling(evaluations.Max()))) 355 series3.Points.AddXY(e, Math.Max(0, 1.0 - Math.Exp(-lambda * (e - minimum)))); 352 if (bestProbability <= 0) bestProbability = 1 - lambda; 353 foreach (var e in Enumerable.Range(0, 100)) { 354 var x = e * steps; 355 series3.Points.AddXY(x, Math.Max(0, 1.0 - Math.Pow(bestProbability, x))); 356 } 356 357 357 358 enhancedChart.Annotations.Clear(); … … 359 360 var annotation = new VerticalLineAnnotation(); 360 361 annotation.AnchorDataPoint = series.Points[cutOffIdx]; 361 annotation.Height = -20;362 annotation.Height = series.Points[cutOffIdx].YValues[0] > enhancedChart.ChartAreas[series.ChartArea].AxisY.Maximum / 2.0 ? 10 : -10; 362 363 annotation.LineWidth = 2; 363 364 annotation.StartCap = LineAnchorCapStyle.Arrow; -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.Designer.cs
r13475 r13485 47 47 this.suggestedInstancesComboBox = new System.Windows.Forms.ComboBox(); 48 48 this.runsTabPage = new System.Windows.Forms.TabPage(); 49 this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();50 49 this.okbTabPage = new System.Windows.Forms.TabPage(); 51 50 this.algorithmInstancesViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); … … 57 56 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 58 57 this.okbDownloadButton = new System.Windows.Forms.Button(); 58 this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView(); 59 this.progressPanel = new System.Windows.Forms.Panel(); 59 60 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 60 61 this.tabControl.SuspendLayout(); … … 230 231 this.runsTabPage.UseVisualStyleBackColor = true; 231 232 // 232 // runsView233 //234 this.runsView.Caption = "RunCollection View";235 this.runsView.Content = null;236 this.runsView.Dock = System.Windows.Forms.DockStyle.Fill;237 this.runsView.Location = new System.Drawing.Point(3, 3);238 this.runsView.Name = "runsView";239 this.runsView.ReadOnly = false;240 this.runsView.Size = new System.Drawing.Size(532, 329);241 this.runsView.TabIndex = 1;242 //243 233 // okbTabPage 244 234 // 235 this.okbTabPage.Controls.Add(this.progressPanel); 245 236 this.okbTabPage.Controls.Add(this.okbDownloadButton); 246 237 this.okbTabPage.Controls.Add(this.algorithmInstancesViewHost); … … 351 342 this.okbDownloadButton.UseVisualStyleBackColor = true; 352 343 this.okbDownloadButton.Click += new System.EventHandler(this.okbDownloadButton_Click); 344 // 345 // runsView 346 // 347 this.runsView.Caption = "RunCollection View"; 348 this.runsView.Content = null; 349 this.runsView.Dock = System.Windows.Forms.DockStyle.Fill; 350 this.runsView.Location = new System.Drawing.Point(3, 3); 351 this.runsView.Name = "runsView"; 352 this.runsView.ReadOnly = false; 353 this.runsView.Size = new System.Drawing.Size(532, 329); 354 this.runsView.TabIndex = 1; 355 // 356 // progressPanel 357 // 358 this.progressPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 359 | System.Windows.Forms.AnchorStyles.Left) 360 | System.Windows.Forms.AnchorStyles.Right))); 361 this.progressPanel.Location = new System.Drawing.Point(6, 35); 362 this.progressPanel.Name = "progressPanel"; 363 this.progressPanel.Size = new System.Drawing.Size(526, 294); 364 this.progressPanel.TabIndex = 2; 365 this.progressPanel.Visible = false; 353 366 // 354 367 // ExpertSystemView … … 405 418 private MainForm.WindowsForms.ViewHost problemInstancesView; 406 419 private System.Windows.Forms.Button okbDownloadButton; 420 private System.Windows.Forms.Panel progressPanel; 407 421 } 408 422 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs
r13475 r13485 23 23 using System.Collections; 24 24 using System.ComponentModel; 25 using System.IO;26 25 using System.Linq; 27 26 using System.Windows.Forms; 28 using HeuristicLab.Clients.OKB.Administration;29 using HeuristicLab.Clients.OKB.Query;30 27 using HeuristicLab.Common; 31 28 using HeuristicLab.Common.Resources; 32 using HeuristicLab.Core;33 29 using HeuristicLab.Core.Views; 34 30 using HeuristicLab.MainForm; 35 31 using HeuristicLab.Optimization; 36 using HeuristicLab.Persistence.Default.Xml;37 32 using HeuristicLab.PluginInfrastructure; 38 33 … … 43 38 protected TypeSelectorDialog problemTypeSelectorDialog; 44 39 protected virtual bool SuppressEvents { get; set; } 40 private bool okbDownloadInProgress; 45 41 46 42 public new ExpertSystem Content { … … 85 81 base.OnContentChanged(); 86 82 SuppressEvents = true; 83 okbDownloadInProgress = false; 87 84 try { 88 85 if (Content == null) { … … 114 111 algorithmViewHost.Enabled = Content != null && !ReadOnly && !Locked; 115 112 runsView.Enabled = Content != null; 116 algorithmInstancesViewHost.Enabled = Content != null ;113 algorithmInstancesViewHost.Enabled = Content != null && !okbDownloadInProgress; 117 114 refreshMapButton.Enabled = Content != null; 118 okbDownloadButton.Enabled = Content != null && Content.Problem != null && !ReadOnly && !Locked ;115 okbDownloadButton.Enabled = Content != null && Content.Problem != null && !ReadOnly && !Locked && !okbDownloadInProgress; 119 116 } 120 117 … … 293 290 294 291 private void okbDownloadButton_Click(object sender, EventArgs e) { 295 var queryClient = QueryClient.Instance; 296 queryClient.Refresh(); 297 298 var problemTypeFilter = (StringComparisonAvailableValuesFilter)queryClient.Filters.Single(x => x.Label == "Problem Data Type Name"); 299 problemTypeFilter.Value = Content.Problem.GetType().Name; 300 301 var runIds = queryClient.GetRunIds(problemTypeFilter).ToList(); 302 var count = queryClient.GetNumberOfRuns(problemTypeFilter); 303 if (count > 0) { 304 var list = new ItemList<IAlgorithm>(); 305 var adminClient = AdministrationClient.Instance; 306 adminClient.Refresh(); 307 var runs = queryClient.GetRuns(runIds, true).ToList(); 308 foreach (var rGroup in runs.GroupBy(x => x.Algorithm.Id)) { 309 var data = AdministrationClient.GetAlgorithmData(rGroup.Key); 310 if (data != null) { 311 using (var stream = new MemoryStream(data)) { 312 try { 313 var alg = (IAlgorithm)XmlParser.Deserialize<IContent>(stream); 314 alg.Runs.AddRange(rGroup.Select(x => queryClient.ConvertToOptimizationRun(x))); 315 list.Add(alg); 316 } catch (Exception) { } 317 stream.Close(); 318 } 319 } 320 } 321 Content.AlgorithmInstances = list; 292 var progress = new Progress(); 293 progress.ProgressStateChanged += OkbDownloadProgressOnStateChanged; 294 Content.UpdateKnowledgeBaseAsync(progress); 295 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(progressPanel, progress); 296 progressPanel.Visible = true; 297 SetEnabledStateOfControls(); 298 } 299 300 private void OkbDownloadProgressOnStateChanged(object sender, EventArgs eventArgs) { 301 var progress = (IProgress)sender; 302 okbDownloadInProgress = progress.ProgressState == ProgressState.Started; 303 SetEnabledStateOfControls(); 304 if (!okbDownloadInProgress) { 305 progressPanel.Visible = false; 306 progress.ProgressStateChanged -= OkbDownloadProgressOnStateChanged; 322 307 } 323 308 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.resx
r13475 r13485 121 121 <value>17, 17</value> 122 122 </metadata> 123 <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 124 <value>17, 17</value> 125 </metadata> 123 126 <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 124 127 <value>140, 17</value> … … 128 131 <value> 129 132 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6 130 JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAs PAAALDwGS+QOlAAACeUlE133 JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsMAAALDAE/QCLIAAACeUlE 131 134 QVQ4T6WSWUiUURiG/4suurJIjUIwskQsEAMjqosQpUVNKbdCSRPKrQVDMddmXEedGdcpFXNGnUYdrSzF 132 135 sEIoFInQcqHE1CwoKsXUUMnt6XfEye0munjgnO+c9+HjO0cA/osNi2tJLdA6SXN13MwoI12lJ06uiV8+ … … 145 148 <value> 146 149 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6 147 JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAs PAAALDwGS+QOlAAABmElE150 JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsMAAALDAE/QCLIAAABmElE 148 151 QVQ4T42QTUsCURSGJWgVtWkb9AfatKhN1L4I2rRoX9BvEIJ+QG4qFNKKCAMtEPqAUMiKamESEmpoWiKa 149 152 YuZnmuOo83bufKUYgy+8c849957n3jk6ALJXOWAxBAulfrKwEAOW+L/9/y0locEzXs9SI3BB8UXKxVp1 -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/ExpertSystem.cs
r13475 r13485 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.ComponentModel; 24 using System.Collections.Generic;25 25 using System.Drawing; 26 using System.IO; 26 27 using System.Linq; 28 using System.Threading.Tasks; 27 29 using HeuristicLab.Analysis; 30 using HeuristicLab.Common; 31 using HeuristicLab.Common.Resources; 28 32 using HeuristicLab.Core; 33 using HeuristicLab.Data; 34 using HeuristicLab.MainForm; 29 35 using HeuristicLab.Optimization; 30 36 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Common; 32 using HeuristicLab.Common.Resources; 33 using HeuristicLab.Data; 37 using HeuristicLab.Persistence.Default.Xml; 34 38 35 39 namespace HeuristicLab.OptimizationExpertSystem { … … 222 226 } 223 227 } finally { ProblemInstances.UpdateOfRunsInProgress = false; } 228 } 229 230 private static readonly HashSet<string> InterestingValueNames = new HashSet<string>() { 231 "QualityPerEvaluations", "Problem Name", "Problem Type", "Algorithm Name", "Algorithm Type", "Maximization" 232 }; 233 234 public async void UpdateKnowledgeBaseAsync(IProgress progress) { 235 progress.Start("Updating Knowledge Base from OKB"); 236 await Task.Factory.StartNew(() => { DoUpdateKnowledgeBase(progress); }, TaskCreationOptions.LongRunning); 237 } 238 239 public void UpdateKnowledgeBase() { 240 DoUpdateKnowledgeBase(new Progress(string.Empty, ProgressState.Started)); 241 } 242 243 private void DoUpdateKnowledgeBase(IProgress progress) { 244 var queryClient = Clients.OKB.Query.QueryClient.Instance; 245 var adminClient = Clients.OKB.Administration.AdministrationClient.Instance; 246 try { 247 progress.Status = "Refreshing query client..."; 248 queryClient.Refresh(); 249 var interestingValues = queryClient.ValueNames.Where(x => InterestingValueNames.Contains(x.Name)).ToList(); 250 251 var problemTypeFilter = (Clients.OKB.Query.StringComparisonAvailableValuesFilter)queryClient.Filters.Single(x => x.Label == "Problem Data Type Name"); 252 problemTypeFilter.Value = Problem.GetType().Name; 253 254 progress.Status = "Obtaining number of runs..."; 255 var count = queryClient.GetNumberOfRuns(problemTypeFilter); 256 if (count == 0) return; 257 258 var runIds = queryClient.GetRunIds(problemTypeFilter).ToList(); 259 adminClient.Refresh(); 260 var i = 0; 261 var conversions = new List<Task>(); 262 var runGroup = new Dictionary<Tuple<long, string>, List<IRun>>(); 263 while (i < count) { 264 var nextIds = runIds.Skip(i).Take(500).ToList(); 265 progress.Status = string.Format("Downloading runs {0} to {1} of {2}...", i, i + nextIds.Count, count); 266 var okbRuns = queryClient.GetRunsWithValues(nextIds, true, interestingValues); 267 conversions.Add(Task.Factory.StartNew(() => { 268 var hlRuns = okbRuns.AsParallel().Select(x => new { Id = x.Algorithm.Id, Name = x.Algorithm.Name, Run = queryClient.ConvertToOptimizationRun(x) }) 269 .GroupBy(x => Tuple.Create(x.Id, x.Name)).ToList(); 270 lock (runGroup) { 271 foreach (var hr in hlRuns) { 272 List<IRun> runList; 273 if (!runGroup.TryGetValue(hr.Key, out runList)) { 274 runList = new List<IRun>(); 275 runGroup[hr.Key] = runList; 276 } 277 runList.AddRange(hr.Select(x => x.Run)); 278 } 279 } 280 })); 281 i += nextIds.Count; 282 progress.ProgressValue = 0.8 * (i / (double)count); 283 } 284 Task.WaitAll(conversions.ToArray()); 285 var list = new ItemList<IAlgorithm>(); 286 i = 0; 287 foreach (var rGroup in runGroup) { 288 progress.Status = string.Format("Downloading algorithm {0}...", rGroup.Key.Item2); 289 var data = Clients.OKB.Administration.AdministrationClient.GetAlgorithmData(rGroup.Key.Item1); 290 if (data != null) { 291 using (var stream = new MemoryStream(data)) { 292 try { 293 var alg = (IAlgorithm)XmlParser.Deserialize<IContent>(stream); 294 alg.Runs.AddRange(rGroup.Value); 295 list.Add(alg); 296 } catch (Exception) { } 297 stream.Close(); 298 } 299 } 300 i++; 301 progress.ProgressValue = 0.8 + 0.2 * (i / (double)runGroup.Count); 302 } 303 AlgorithmInstances = list; 304 } finally { progress.Finish(); } 224 305 } 225 306 -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/HeuristicLab.OptimizationExpertSystem-3.3.csproj
r12957 r13485 78 78 <Private>False</Private> 79 79 </Reference> 80 <Reference Include="HeuristicLab.Clients.OKB-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 81 <SpecificVersion>False</SpecificVersion> 82 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Clients.OKB-3.3.dll</HintPath> 83 <Private>False</Private> 84 </Reference> 80 85 <Reference Include="HeuristicLab.Collections-3.3"> 81 86 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath> … … 99 104 <Private>False</Private> 100 105 </Reference> 106 <Reference Include="HeuristicLab.MainForm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 107 <SpecificVersion>False</SpecificVersion> 108 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm-3.3.dll</HintPath> 109 <Private>False</Private> 110 </Reference> 101 111 <Reference Include="HeuristicLab.Persistence-3.3"> 102 112 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath> … … 110 120 <Reference Include="System.Core" /> 111 121 <Reference Include="System.Drawing" /> 122 <Reference Include="System.Runtime.Serialization" /> 112 123 <Reference Include="System.Xml.Linq" /> 113 124 <Reference Include="System.Data.DataSetExtensions" /> -
branches/PerformanceComparison/PerformanceComparison.sln
r12842 r13485 2 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 3 # Visual Studio 2013 4 VisualStudioVersion = 12.0. 31101.04 VisualStudioVersion = 12.0.40629.0 5 5 MinimumVisualStudioVersion = 10.0.40219.1 6 6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Analysis-3.3", "HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj", "{887425B4-4348-49ED-A457-B7D2C26DDBF9}" … … 102 102 HideSolutionNode = FALSE 103 103 EndGlobalSection 104 GlobalSection(Performance) = preSolution 105 HasPerformanceSessions = true 106 EndGlobalSection 104 107 EndGlobal
Note: See TracChangeset
for help on using the changeset viewer.